/** * Returns the {@link Blob} with the given blobId. * * @param blobId the blobId of the blob. * @return the blob. */ public Blob getBlobFromBlobId(String blobId){ return new BlobStoreBlob(blobStore, blobId); }
/** * Returns the {@link Blob} with the given blobId. * * @param blobId the blobId of the blob. * @return the blob. */ public Blob getBlobFromBlobId(String blobId){ return new BlobStoreBlob(blobStore, blobId); }
private Blob getBlob(String blobId) { if (blobStore != null) { return new BlobStoreBlob(blobStore, blobId); } throw new IllegalStateException("Attempt to read external blob with blobId [" + blobId + "] " + "without specifying BlobStore"); }
@Override public Blob deserialize(String value) { if (value.startsWith(PREFIX)) { return base64.deserialize(value.substring(PREFIX.length())); } return new BlobStoreBlob(blobStore, value); }
@Override public Blob deserialize(String value) { if (value.startsWith(PREFIX)) { return base64.deserialize(value.substring(PREFIX.length())); } return new BlobStoreBlob(blobStore, value); }
@Override public Blob deserialize(String value) { if (value.startsWith(PREFIX)) { return base64.deserialize(value.substring(PREFIX.length())); } return new BlobStoreBlob(blobStore, value); }
@Override @NotNull public BlobStoreBlob createBlob(InputStream inputStream) throws IOException { return new BlobStoreBlob(blobStore, blobStore.writeBlob(inputStream)); }
@Override @NotNull public BlobStoreBlob createBlob(InputStream inputStream) throws IOException { return new BlobStoreBlob(blobStore, blobStore.writeBlob(inputStream)); }
@Override public Blob deserialize(String value) { if (errorBlob(value)){ return new ErrorBlob(value); } return new BlobStoreBlob(dataStore, value); }
@Nullable @Override public Blob completeBlobUpload(@NotNull String uploadToken) throws IllegalArgumentException { if (delegate instanceof DataRecordAccessProvider) { try { DataRecord record = ((DataRecordAccessProvider) delegate).completeDataRecordUpload(uploadToken); return new BlobStoreBlob(this, record.getIdentifier().toString()); } catch (DataStoreException | DataRecordUploadException e) { log.warn("Unable to complete direct upload for upload token {}", uploadToken, e); } } return null; }
@Override public Blob deserialize(String value) { if (errorBlob(value)){ return new ErrorBlob(value); } return new BlobStoreBlob(dataStore, value); }
@Override public Blob deserialize(String value) { if (errorBlob(value)){ return new ErrorBlob(value); } return new BlobStoreBlob(dataStore, value); }
private Blob blobOf(String content, BlobStore bs) throws IOException { String id = bs.writeBlob(new ByteArrayInputStream(content.getBytes())); return new BlobStoreBlob(bs, id); }
static BlobFactory getBlobStoreBlobFactory(final BlobStore store) { return in -> { String blobId; if (!ENABLE_ASYNC_DS) { blobId = store.writeBlob(in, new BlobOptions().setUpload(SYNCHRONOUS)); } else { blobId = store.writeBlob(in); } return new BlobStoreBlob(store, blobId); }; } }
static BlobFactory getBlobStoreBlobFactory(final BlobStore store) { return in -> { String blobId; if (!ENABLE_ASYNC_DS) { blobId = store.writeBlob(in, new BlobOptions().setUpload(SYNCHRONOUS)); } else { blobId = store.writeBlob(in); } return new BlobStoreBlob(store, blobId); }; } }
private PropertyState migrateProperty(PropertyState propertyState) throws IOException { Blob oldBlob = propertyState.getValue(Type.BINARY); String blobId = getIdentity(oldBlob); if (blobStore.isMigrated(blobId)) { return null; } String newBlobId = blobStore.writeBlob(oldBlob.getNewStream()); Blob newBlob = new BlobStoreBlob(blobStore, newBlobId); PropertyBuilder<Blob> builder = new PropertyBuilder<Blob>(Type.BINARY); builder.assignFrom(propertyState); builder.setValue(newBlob); return builder.getPropertyState(); }
private PropertyState migrateProperty(PropertyState propertyState) throws IOException { Blob oldBlob = propertyState.getValue(Type.BINARY); String blobId = getIdentity(oldBlob); if (blobStore.isMigrated(blobId)) { return null; } String newBlobId = blobStore.writeBlob(oldBlob.getNewStream()); Blob newBlob = new BlobStoreBlob(blobStore, newBlobId); PropertyBuilder<Blob> builder = new PropertyBuilder<Blob>(Type.BINARY); builder.assignFrom(propertyState); builder.setValue(newBlob); return builder.getPropertyState(); }
private PropertyState migrateProperty(PropertyState propertyState) throws IOException { Blob oldBlob = propertyState.getValue(Type.BINARY); String blobId = getIdentity(oldBlob); if (blobStore.isMigrated(blobId)) { return null; } String newBlobId = blobStore.writeBlob(oldBlob.getNewStream()); Blob newBlob = new BlobStoreBlob(blobStore, newBlobId); PropertyBuilder<Blob> builder = new PropertyBuilder<Blob>(Type.BINARY); builder.assignFrom(propertyState); builder.setValue(newBlob); return builder.getPropertyState(); }
@Test public void inMemoryRecord() throws Exception{ File fdsDir = temporaryFolder.newFolder(); FileDataStore fds = DataStoreUtils.createFDS(fdsDir, 10000); DataStoreBlobStore dbs = new DataStoreBlobStore(fds); ByteArrayInputStream is = new ByteArrayInputStream("".getBytes()); String blobId = dbs.writeBlob(is); File writerDir = temporaryFolder.newFolder(); PreExtractedTextProvider textProvider = new DataStoreTextWriter(writerDir, true); assertNull(textProvider.getText("/content", new BlobStoreBlob(dbs, blobId))); }
@Test public void blobStoreBlob() throws Exception{ Blob b = new ArrayBasedBlob("hello world".getBytes()); String value = blobStore.writeBlob(b.getNewStream()); String serValue = serializer.serialize(new BlobStoreBlob(blobStore, value)); Blob b2 = serializer.deserialize(serValue); assertTrue(AbstractBlob.equal(b, b2)); }