use of org.jclouds.blobstore.InputStreamMap in project qi4j-sdk by Qi4j.
the class JCloudsMapEntityStoreMixin method get.
@Override
public Reader get(EntityReference entityReference) throws EntityStoreException {
InputStreamMap isMap = storeContext.createInputStreamMap(container);
InputStream input = isMap.get(entityReference.identity());
if (input == null) {
throw new EntityNotFoundException(entityReference);
}
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Inputs.byteBuffer(input, 4096).transferTo(Outputs.byteBuffer(baos));
return new StringReader(baos.toString("UTF-8"));
} catch (IOException ex) {
throw new EntityStoreException("Unable to read entity state for: " + entityReference, ex);
} finally {
try {
input.close();
} catch (IOException ignored) {
}
}
}
Aggregations