@Transactional(propagation = Propagation.REQUIRED)
public ResourceId handle(IdentificationResultCollection results) {
//log.debug(String.format("handling result for job [%s]", results.getUri()));
ProfileResourceNode node = new ProfileResourceNode(results.getUri());
RequestMetaData requestMetaData = results.getRequestMetaData();
NodeMetaData metaData = new NodeMetaData();
metaData.setLastModified(requestMetaData.getTime());
metaData.setSize(results.getFileLength());
metaData.setName(requestMetaData.getName());
metaData.setExtension(ResourceUtils.getExtension(requestMetaData.getName()));
metaData.setResourceType(results.isArchive() ? ResourceType.CONTAINER : ResourceType.FILE);
metaData.setHash(requestMetaData.getHash());
metaData.setNodeStatus(NodeStatus.DONE);
node.setMetaData(metaData);
node.setExtensionMismatch(results.getExtensionMismatch());
node.setFinished(new Date());
ResourceId parentId = results.getCorrelationId();
resultHandlerDao.save(node, parentId);
if (results.getResults().isEmpty()) {
node.addFormatIdentification(Format.NULL);
node.setZeroIdentifications();
} else {
for (IdentificationResult result : results.getResults()) {
node.getMetaData().setIdentificationMethod(result.getMethod());
//log.debug(String.format("Handling ID puid[%s]; uri[%s]", result.getPuid(), results.getUri()));
Format format = resultHandlerDao.loadFormat(result.getPuid());
node.addFormatIdentification(format);
}
}
progressMonitor.stopJob(node);
return new ResourceId(node.getId(), node.getPrefix());
}