use of org.codice.ddf.catalog.async.data.impl.ProcessResourceImpl in project ddf by codice.
the class ProcessingPostIngestPlugin method getProcessResource.
private ProcessResource getProcessResource(Metacard metacard, Subject subject) {
LOGGER.trace("Attempting to retrieve process resource metacard with id \"{}\" and sourceId \"{}\".", metacard.getId(), metacard.getSourceId());
ResourceRequest request = new ResourceRequestById(metacard.getId());
if (subject == null) {
LOGGER.debug("No available subject to fetch metacard resource. Returning null");
return null;
}
return subject.execute(() -> {
try {
ResourceResponse response = catalogFramework.getResource(request, metacard.getSourceId());
Resource resource = response.getResource();
ProcessResource processResource = new ProcessResourceImpl(metacard.getId(), resource.getInputStream(), resource.getMimeTypeValue(), resource.getName(), resource.getSize(), false);
return processResource;
} catch (IOException | ResourceNotFoundException | ResourceNotSupportedException | RuntimeException e) {
LOGGER.debug("Unable to get resource id:{}, sourceId:{}. Returning null", metacard.getId(), metacard.getSourceId(), e);
}
return null;
});
}
Aggregations