org.apache.jackrabbit.oak.spi.blob.BlobStore.getInputStream()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.jackrabbit.oak.spi.blob.BlobStore.getInputStream()方法的一些代码示例,展示了BlobStore.getInputStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.getInputStream()方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.spi.blob.BlobStore
类名称:BlobStore
方法名:getInputStream

BlobStore.getInputStream介绍

[英]Returns a new stream for given blobId. The streams returned from multiple calls to this method are byte wise equals. That is, subsequent calls to java.io.InputStream#read()return the same sequence of bytes as long as neither call throws an exception.
[中]返回给定blobId的新流。对该方法的多次调用返回的流是字节相等的。也就是说,对java的后续调用。木卫一。InputStream#read()返回相同的字节序列,只要两个调用都不会引发异常。

代码示例

代码示例来源:origin: apache/jackrabbit-oak

@Override
public InputStream readBlob(String blobId) {
  if (store == null) {
    return null;
  }
  try {
    return store.getInputStream(blobId);
  } catch (IOException e) {
    log.warn("Error while reading blob content", e);
  }
  return null;
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
@NotNull
public InputStream getNewStream() {
  try {
    return blobStore.getInputStream(blobId);
  } catch (IOException e) {
    throw new RuntimeException("Error occurred while obtaining " +
        "InputStream for blobId ["+ blobId +"]",e);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
@Nonnull
public InputStream getNewStream() {
  try {
    return blobStore.getInputStream(blobId);
  } catch (IOException e) {
    throw new RuntimeException("Error occurred while obtaining " +
        "InputStream for blobId ["+ blobId +"]",e);
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob-plugins

@Override
@NotNull
public InputStream getNewStream() {
  try {
    return blobStore.getInputStream(blobId);
  } catch (IOException e) {
    throw new RuntimeException("Error occurred while obtaining " +
        "InputStream for blobId ["+ blobId +"]",e);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public InputStream getInputStream(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getInputStream(blobId);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public InputStream getInputStream(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getInputStream(blobId);
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob

@Override
public InputStream getInputStream(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getInputStream(blobId);
}

代码示例来源:origin: apache/jackrabbit-oak

@NotNull
@Override
public InputStream getNewStream() {
  try {
    return blobStore.getInputStream(id);
  } catch (IOException e) {
    log.error("Error in getNewStream", e);
  }
  return null;
}

代码示例来源:origin: apache/jackrabbit-oak

data = blobStore.getInputStream(blobId);
} catch (Exception e) {
  return true;

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void shouldReturnNullIfBlobDoesNotExist() throws Exception {
  BlobStore s = mock(BlobStore.class);
  when(s.getInputStream("id")).thenThrow(new IOException("blob not found"));
  DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
  assertNull(r.readBlob("id"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test(expected = NullPointerException.class)
public void getInputStreamShouldAlwaysThrowAnExceptionWhenNullBlobIdIsPassed()
    throws IOException {
  given:
  {
    final BlobStore store = new LoopbackBlobStore();
    when:
    {
      store.getInputStream(null);
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void shouldReturnBlobContent() throws Exception {
  BlobStore s = mock(BlobStore.class);
  when(s.getInputStream("id")).thenReturn(new ByteArrayInputStream(new byte[]{1, 2, 3}));
  when(s.getBlobLength("id")).thenReturn(3L);
  DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
  assertEquals(3, r.getBlobLength("id"));
  assertArrayEquals(new byte[]{1, 2, 3}, IOUtils.toByteArray(r.readBlob("id")));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testGetInputStream() throws IOException {
  for (String id : oldBlobIds) {
    assertStreamEquals(oldBlobStore.getInputStream(id), splitBlobStore.getInputStream(id));
  }
  for (String id : newBlobIds) {
    assertStreamEquals(newBlobStore.getInputStream(id), splitBlobStore.getInputStream(id));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

private void assertPropertyOnTheNewStore(Blob blob) throws IOException {
  String blobId = blob.getContentIdentity();
  assertStreamEquals(blob.getNewStream(), newBlobStore.getInputStream(blobId));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
@Parameters(method = "blobIds")
public void shouldAlwaysReturnStreamOfRequestedBlobIdUtf8BinRepresentation(
    final String blobId) throws IOException {
  given:
  {
    final String encoding = "UTF-8";
    final BlobStore store = new LoopbackBlobStore();
    when:
    {
      final InputStream inputStream = store.getInputStream(blobId);
      then:
      {
        assertNotNull(inputStream);
      }
      and:
      {
        final String actualInputStreamAsString = IOUtils.toString(
            inputStream, encoding);
        then:
        {
          assertEquals(actualInputStreamAsString, blobId);
        }
      }
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void readOnly() throws Exception{
  FileDataStore fds = new FileDataStore();
  fds.setPath(temporaryFolder.getRoot().getAbsolutePath());
  fds.init(null);
  DataStoreBlobStore writableBS = new DataStoreBlobStore(fds);
  BlobStore readOnly = ReadOnlyBlobStoreWrapper.wrap(writableBS);
  try {
    readOnly.writeBlob(new ByteArrayInputStream("foo".getBytes()));
    fail();
  } catch (Exception ignore) {
  }
  String blobId = writableBS.writeBlob(new ByteArrayInputStream("foo".getBytes()));
  try(InputStream is = readOnly.getInputStream(blobId)) {
    assertNotNull(is);
  }
}

相关文章