use of org.dcm4chee.arc.exporter.Exporter in project dcm4chee-arc-light by dcm4che.
the class ExportTaskProcessor method process.
@Override
public Outcome process(Task task) throws Exception {
Outcome outcome;
ExportContext exportContext = null;
try {
ExporterDescriptor exporterDesc = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class).getExporterDescriptorNotNull(task.getExporterID());
Attributes attrs = queryService.queryExportTaskInfo(task, device.getApplicationEntity(exporterDesc.getAETitle(), true));
if (attrs != null) {
task.setModalities(attrs.getStrings(Tag.ModalitiesInStudy));
task.setNumberOfInstances(attrs.getInt(Tag.NumberOfStudyRelatedInstances, -1));
ejb.merge(task);
} else {
LOG.info("No Export Task Info found for {}", task);
}
Exporter exporter = exporterFactory.getExporter(exporterDesc);
exportContext = exporter.createExportContext();
exportContext.setTaskPK(task.getPk());
exportContext.setBatchID(task.getBatchID());
exportContext.setStudyInstanceUID(task.getStudyInstanceUID());
exportContext.setSeriesInstanceUID(StringUtils.nullify(task.getSeriesInstanceUID(), "*"));
exportContext.setSopInstanceUID(StringUtils.nullify(task.getSOPInstanceUID(), "*"));
exportContext.setAETitle(exporterDesc.getAETitle());
exportContext.setHttpServletRequestInfo(HttpServletRequestInfo.valueOf(task.getRequesterUserID(), task.getRequesterHost(), task.getRequestURI()));
outcome = exporter.export(exportContext);
exportContext.setOutcome(outcome);
} catch (Throwable e) {
if (exportContext != null)
exportContext.setException(e);
LOG.warn("Failed to process {}", task, e);
throw e;
} finally {
if (exportContext != null)
try {
exportEvent.fire(exportContext);
} catch (Exception e) {
LOG.warn("Failed on firing export context {}", task, e);
}
}
return outcome;
}
Aggregations