use of nikita.common.util.exceptions.StorageFileNotFoundException in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectService method loadAsResource.
@Override
public Resource loadAsResource(DocumentObject documentObject) {
String filename = documentObject.getReferenceDocumentFile();
try {
Path file = load(filename);
Resource resource = new UrlResource(file.toUri());
if (resource.exists() || resource.isReadable()) {
return resource;
} else {
throw new StorageFileNotFoundException("Could not read file: " + filename);
}
} catch (MalformedURLException e) {
throw new StorageFileNotFoundException("Could not read file: " + filename);
}
}
Aggregations