boolean loadedData = false;
if (Helper.isLocalIdentifier(uid)) {
log.info("Sample object is from local filesystem {}", uid);
try {
InputStream sampleStream = new FileInputStream((new URL(uid)).getFile());
ByteStream bsSample = this.convertToByteStream(sampleStream);
sample.setData(bsSample);
digitalObjectManager.moveDataToStorage(sample);
addedBytestreams.add(sample.getPid());
loadedData = true;
} catch (FileNotFoundException e) {
log.error("An error occurred while downloading sample {}", sample.getFullname(), e);
} catch (MalformedURLException e) {
log.error("An error occurred while downloading sample {}", sample.getFullname(), e);
}
} else {
log.info("Sample object is from repository {}. Downloading {}", repo.getRepositoryIdentifier(), uid);
try {
InputStream sampleStream = repo.downloadFile(uid);
log.info("To bytestream: sample {}", sample.getFullname());
ByteStream bsSample = this.convertToByteStream(sampleStream);
sample.setData(bsSample);
log.info("Moving to storage: sample {}", sample.getFullname());
digitalObjectManager.moveDataToStorage(sample);
addedBytestreams.add(sample.getPid());