@Override public BlobDataSource read(final URI uri) throws IOException { logger.debug("Reading blob {} from Cassandra", uri); BlobURI blobUri = new BlobURI().fromURI(uri); Assert.isTrue(blobUri.getProfile().equals(DATABASE_PROFILE), "Blob store profile does not match database."); UUID messageId = UUID.fromString(blobUri.getName()); byte[] messageBlock = BlobPersistence.readBlock(messageId, DATABASE_DEFAULT_BLOCK_ID); InputStream in = ByteStreams.newInputStreamSupplier(messageBlock).getInput(); return new BlobDataSource(uri, in); }
@Override public BlobDataSource read(final URI uri) throws IOException { InputStream in; BlobURI blobUri = new BlobURI().fromURI(uri); String keyAlias = blobUri.getEncryptionKey(); if (keyAlias != null) { // currently we only support AES encryption, use by default EncryptionHandler eh = new AESEncryptionHandler(); try { logger.debug("Decrypting object {} with key {}", uri, keyAlias); byte[] iv = getCipherIVFromBlobName(BlobUtils.relativize(uri.getPath())); in = eh.decrypt(CloudStoreProxy.read(uri), Configurator.getEncryptionKey(keyAlias), iv); } catch (GeneralSecurityException gse) { throw new IOException("Unable to decrypt message blob: ", gse); } } else { in = CloudStoreProxy.read(uri); } return new BlobDataSource(uri, in); }
public BlobDataSource read(final URI uri) throws IOException { // check if blob was stored for the message Assert.notNull(uri, "URI cannot be null"); BlobDataSource blobDS; BlobURI blobUri = new BlobURI().fromURI(uri); if (blobUri.getProfile().equals(DatabaseConstants.DATABASE_PROFILE)) { blobDS = dbBlobStorage.read(uri); } else { blobDS = cloudBlobStorage.read(uri); } // if compressed, add compression handler to data source if ((blobUri.getCompression() != null && blobUri.getCompression() .equals(DeflateCompressionHandler.COMPRESSION_TYPE_DEFLATE)) || // TODO: deprecated suffix based compression detection // kept for backward compatibility with 0.3 blobUri.getName().endsWith(BlobStoreConstants.COMPRESS_SUFFIX)) { CompressionHandler ch = new DeflateCompressionHandler(); return new BlobDataSource(uri, blobDS.getInputStream(), ch); } else { return blobDS; } }