@Override public RetrievedContent getContent(String spaceId, String contentId) { String path = baseDirectory + "/" + spaceId + "/" + contentId; ConnectOperation co = new ConnectOperation(host, port, username, password, zone); try { ObjTypeEnum type = new IrodsOperations(co).stat(path).getObjType(); log.trace("Opening inputstream to irods path: " + path + " type " + type); RetrievedContent content = new RetrievedContent(); content.setContentStream(new BufferedInputStream( new IrodsProxyInputStream(path, co.getConnection()), BLOCK_SIZE)); content.setContentProperties(getContentProperties(spaceId, contentId)); return content; } catch (IOException e) { log.error("Could not connect to iRODS", e); throw new StorageException(e); } }
/** * Returns snapshot from the snapshot properties file if it exists * * @param spaceId * @return snapshot from the snapshot properties file if it exists, otherwise null */ protected String getSnapshotIdFromProperties(String spaceId) { Properties props = new Properties(); try (InputStream is = this.snapshotProvider.getContent(spaceId, Constants.SNAPSHOT_PROPS_FILENAME) .getContentStream()) { props.load(is); return props.getProperty(Constants.SNAPSHOT_ID_PROP); } catch (NotFoundException ex) { return null; } catch (Exception e) { throw new TaskException( MessageFormat.format("Call to create snapshot failed, unable to determine existence of " + "snapshot properties file in {0}. Error: {1}", spaceId, e.getMessage())); } }
RetrievedContent retrievedContent = new RetrievedContent(); retrievedContent.setContentStream(contentItem.getObjectContent()); retrievedContent.setContentProperties(prepContentProperties(contentItem.getObjectMetadata()));
/** * Retrieves string data given its token. * * If no data is associated with the provided token, returns null * * @param token * @return */ public String retrieveData(String token) { try { RetrievedContent data = this.s3StorageProvider.getContent(this.hiddenSpaceName, token); return IOUtil.readStringFromStream(data.getContentStream()); } catch (NotFoundException ex) { return null; } catch (Exception ex) { throw new DuraCloudRuntimeException(ex); } }