use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class IocmUtils method copyMove.
static Attributes copyMove(StoreSession session, RetrieveService retrieveService, QueryService queryService, String studyInstanceUID, Attributes coerceAttrs, RejectionNote rjNote, InputStream in) throws Exception {
ArchiveAEExtension arcAE = session.getArchiveAEExtension();
StoreService storeService = session.getStoreService();
Attributes instanceRefs = parseSOPInstanceReferences(in);
restoreInstances(session, instanceRefs);
Collection<InstanceLocations> instanceLocations = retrieveService.queryInstances(session, instanceRefs, studyInstanceUID);
if (instanceLocations.isEmpty())
return null;
Attributes sopInstanceRefs = getSOPInstanceRefs(instanceRefs, instanceLocations, arcAE.getApplicationEntity());
moveSequence(sopInstanceRefs, Tag.ReferencedSeriesSequence, instanceRefs);
session.setAcceptConflictingPatientID(AcceptConflictingPatientID.YES);
session.setPatientUpdatePolicy(Attributes.UpdatePolicy.PRESERVE);
session.setStudyUpdatePolicy(arcAE.copyMoveUpdatePolicy());
Attributes result = storeService.copyInstances(session, instanceLocations, coerceAttrs, Attributes.UpdatePolicy.MERGE);
if (rjNote != null)
rejectInstances(instanceRefs, queryService, rjNote, session, result);
return result;
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class MPPSSCUImpl method onMPPSReceive.
void onMPPSReceive(@Observes MPPSContext ctx) {
if (ctx.getException() != null)
return;
ArchiveAEExtension arcAE = ctx.getArchiveAEExtension();
Calendar now = Calendar.getInstance();
Attributes mppsAttrs = ctx.getMPPS().getAttributes();
Set<String> remoteAETs = arcAE.mppsForwardRule().filter(rule -> rule.match(now, ctx.getRemoteHostName(), ctx.getCallingAET(), ctx.getLocalHostName(), ctx.getCalledAET(), mppsAttrs)).map(MPPSForwardRule::getDestinations).flatMap(Stream::of).collect(Collectors.toSet());
for (String remoteAET : arcAE.mppsForwardDestinations()) {
remoteAETs.add(remoteAET);
}
Attributes ssAttrs = mppsAttrs.getNestedDataset(Tag.ScheduledStepAttributesSequence);
Attributes patAttrs = ctx.getMPPS().getPatient().getAttributes();
IDWithIssuer idWithIssuer = IDWithIssuer.pidOf(patAttrs);
for (String remoteAET : remoteAETs) {
try {
Task task = new Task();
task.setDeviceName(device.getDeviceName());
task.setQueueName(QUEUE_NAME);
task.setScheduledTime(new Date());
task.setLocalAET(ctx.getLocalApplicationEntity().getAETitle());
task.setType(Task.Type.MPPS);
task.setRemoteAET(remoteAET);
task.setDIMSE(ctx.getDimse().name());
task.setSOPInstanceUID(ctx.getSopInstanceUID());
task.setAccessionNumber(ssAttrs.getString(Tag.AccessionNumber));
task.setStudyInstanceUID(ssAttrs.getString(Tag.StudyInstanceUID));
task.setPatientID(idWithIssuer != null ? idWithIssuer.toString() : null);
task.setPatientName(patAttrs.getString(Tag.PatientName));
task.setPayload(ctx.getAttributes());
task.setStatus(Task.Status.SCHEDULED);
taskManager.scheduleTask(task);
} catch (Exception e) {
LOG.warn("Failed to Schedule Forward of {} MPPS[uid={}] to AE: {}", ctx.getDimse(), ctx.getSopInstanceUID(), remoteAET, e);
}
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class StudyMgtRS method updateStudyAccessControlID.
@PUT
@Path("/studies/{StudyInstanceUID}/access/{accessControlID}")
public Response updateStudyAccessControlID(@PathParam("StudyInstanceUID") String studyUID, @PathParam("accessControlID") String accessControlID) {
logRequest();
ArchiveAEExtension arcAE = getArchiveAE();
try {
StudyMgtContext ctx = studyService.createStudyMgtContextWEB(HttpServletRequestInfo.valueOf(request), arcAE.getApplicationEntity());
ctx.setStudyInstanceUID(studyUID);
ctx.setAccessControlID("null".equals(accessControlID) ? "*" : accessControlID);
studyService.updateAccessControlID(ctx);
rsForward.forward(RSOperation.UpdateStudyAccessControlID, arcAE, null, request);
return Response.noContent().build();
} catch (StudyMissingException e) {
return errResponse(e.getMessage(), Response.Status.NOT_FOUND);
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class WadoURI method buildResponse.
private void buildResponse(@Suspended AsyncResponse ar, final RetrieveContext ctx, Date lastModified) throws IOException {
LOG.debug("Query for requested instance");
if (!service.calculateMatches(ctx)) {
ArchiveAEExtension arcAE = ctx.getArchiveAEExtension();
String webAppName = arcAE.fallbackWadoURIWebApplication();
if (webAppName != null) {
try {
ar.resume(Response.status(arcAE.fallbackWadoURIHttpStatusCode()).location(redirectURI(webAppName)).build());
return;
} catch (Exception e) {
LOG.warn("Failed to redirect to {}:\n", webAppName, e);
}
}
throw new WebApplicationException(errResponse("No matches found.", Response.Status.NOT_FOUND));
}
List<InstanceLocations> matches = ctx.getMatches();
int numMatches = matches.size();
if (numMatches > 1)
LOG.debug("{} matches found. Return {}. match", numMatches, numMatches >>> 1);
InstanceLocations inst = matches.get(numMatches >>> 1);
int frame = frame(inst.getAttributes());
ObjectType objectType = ObjectType.objectTypeOf(ctx, inst, frame);
MediaType mimeType = selectMimeType(objectType).orElseThrow(() -> new WebApplicationException(errResponse("Supported Media Types for " + objectType + " not acceptable", Response.Status.NOT_ACCEPTABLE)));
if (lastModified == null)
lastModified = service.getLastModifiedFromMatches(ctx, ignorePatientUpdates());
StreamingOutput entity = entityOf(ctx, inst, objectType, mimeType, frame);
ar.register((CompletionCallback) throwable -> {
ctx.getRetrieveService().updateLocations(ctx);
ctx.setException(throwable);
retrieveWado.fire(ctx);
});
ar.resume(Response.ok(entity, mimeType == MediaTypes.APPLICATION_DICOM_TYPE ? new MediaType(mimeType.getType(), mimeType.getSubtype(), parameters(inst)) : mimeType).lastModified(lastModified).tag(String.valueOf(lastModified.hashCode())).build());
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class DicomXSLTOutput method templates.
private Templates templates() throws TransformerConfigurationException {
ArchiveAEExtension arcAE = ctx.getArchiveAEExtension();
String uri = StringUtils.replaceSystemProperties(mediaType.isCompatible(MediaType.TEXT_HTML_TYPE) ? arcAE.wadoSR2HtmlTemplateURI() : arcAE.wadoSR2TextTemplateURI());
return TemplatesCache.getDefault().get(uri);
}
Aggregations