Search in sources :

Example 36 with ArchiveAEExtension

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;
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) StoreService(org.dcm4chee.arc.store.StoreService)

Example 37 with ArchiveAEExtension

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);
        }
    }
}
Also used : UID(org.dcm4che3.data.UID) Attributes(org.dcm4che3.data.Attributes) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) MPPSSCU(org.dcm4chee.arc.mpps.scu.MPPSSCU) Inject(javax.inject.Inject) Calendar(java.util.Calendar) AuditMessages(org.dcm4che3.audit.AuditMessages) ProcedureContext(org.dcm4chee.arc.procedure.ProcedureContext) Observes(javax.enterprise.event.Observes) IApplicationEntityCache(org.dcm4che3.conf.api.IApplicationEntityCache) Event(javax.enterprise.event.Event) Logger(org.slf4j.Logger) MPPSForwardRule(org.dcm4chee.arc.conf.MPPSForwardRule) Task(org.dcm4chee.arc.entity.Task) TaskManager(org.dcm4chee.arc.qmgt.TaskManager) Set(java.util.Set) org.dcm4che3.net(org.dcm4che3.net) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AAssociateRQ(org.dcm4che3.net.pdu.AAssociateRQ) MPPSContext(org.dcm4chee.arc.mpps.MPPSContext) Stream(java.util.stream.Stream) Tag(org.dcm4che3.data.Tag) ProcedureService(org.dcm4chee.arc.procedure.ProcedureService) IDWithIssuer(org.dcm4che3.data.IDWithIssuer) Outcome(org.dcm4chee.arc.qmgt.Outcome) ApplicationScoped(javax.enterprise.context.ApplicationScoped) PresentationContext(org.dcm4che3.net.pdu.PresentationContext) MPPSForwardRule(org.dcm4chee.arc.conf.MPPSForwardRule) IDWithIssuer(org.dcm4che3.data.IDWithIssuer) Task(org.dcm4chee.arc.entity.Task) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) Calendar(java.util.Calendar) Attributes(org.dcm4che3.data.Attributes) Date(java.util.Date) IOException(java.io.IOException)

Example 38 with ArchiveAEExtension

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);
    }
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) StudyMgtContext(org.dcm4chee.arc.study.StudyMgtContext) NoResultException(javax.persistence.NoResultException) StudyMissingException(org.dcm4chee.arc.study.StudyMissingException) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException) DateTimeParseException(java.time.format.DateTimeParseException) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) JsonParsingException(javax.json.stream.JsonParsingException) StudyMissingException(org.dcm4chee.arc.study.StudyMissingException)

Example 39 with ArchiveAEExtension

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());
}
Also used : InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) java.util(java.util) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) UID(org.dcm4che3.data.UID) Attributes(org.dcm4che3.data.Attributes) KeycloakContext(org.dcm4chee.arc.keycloak.KeycloakContext) DicomImageReadParam(org.dcm4che3.imageio.plugins.dcm.DicomImageReadParam) LoggerFactory(org.slf4j.LoggerFactory) DecimalMin(javax.validation.constraints.DecimalMin) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) Inject(javax.inject.Inject) HttpServletRequest(javax.servlet.http.HttpServletRequest) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) Digits(javax.validation.constraints.Digits) DicomObjectOutput(org.dcm4chee.arc.retrieve.stream.DicomObjectOutput) URI(java.net.URI) Event(javax.enterprise.event.Event) PrintWriter(java.io.PrintWriter) Logger(org.slf4j.Logger) ICCProfile(org.dcm4che3.image.ICCProfile) AsyncResponse(javax.ws.rs.container.AsyncResponse) StringWriter(java.io.StringWriter) RetrieveService(org.dcm4chee.arc.retrieve.RetrieveService) org.dcm4che3.net(org.dcm4che3.net) IOException(java.io.IOException) javax.ws.rs.core(javax.ws.rs.core) NotNull(javax.validation.constraints.NotNull) InstanceLocations(org.dcm4chee.arc.store.InstanceLocations) org.dcm4chee.arc.validation.constraints(org.dcm4chee.arc.validation.constraints) Suspended(javax.ws.rs.container.Suspended) StringUtils(org.dcm4che3.util.StringUtils) java.awt(java.awt) MediaTypes(org.dcm4che3.ws.rs.MediaTypes) List(java.util.List) Stream(java.util.stream.Stream) RetrieveWADO(org.dcm4chee.arc.retrieve.RetrieveWADO) javax.ws.rs(javax.ws.rs) Tag(org.dcm4che3.data.Tag) CompletionCallback(javax.ws.rs.container.CompletionCallback) DicomInputStream(org.dcm4che3.io.DicomInputStream) HttpServletRequestInfo(org.dcm4chee.arc.keycloak.HttpServletRequestInfo) RequestScoped(javax.enterprise.context.RequestScoped) Pattern(javax.validation.constraints.Pattern) IWebApplicationCache(org.dcm4che3.conf.api.IWebApplicationCache) RetrieveContext(org.dcm4chee.arc.retrieve.RetrieveContext) ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) IOException(java.io.IOException)

Example 40 with ArchiveAEExtension

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);
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension)

Aggregations

ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)40 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)17 JsonParsingException (javax.json.stream.JsonParsingException)15 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)11 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)10 ConnectException (java.net.ConnectException)9 ConfigurationNotFoundException (org.dcm4che3.conf.api.ConfigurationNotFoundException)9 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)9 SAXException (org.xml.sax.SAXException)9 Attributes (org.dcm4che3.data.Attributes)8 ArchiveDeviceExtension (org.dcm4chee.arc.conf.ArchiveDeviceExtension)7 StudyNotEmptyException (org.dcm4chee.arc.delete.StudyNotEmptyException)7 StudyNotFoundException (org.dcm4chee.arc.delete.StudyNotFoundException)7 DateTimeParseException (java.time.format.DateTimeParseException)6 NoResultException (javax.persistence.NoResultException)6 ApplicationEntity (org.dcm4che3.net.ApplicationEntity)6 Patient (org.dcm4chee.arc.entity.Patient)6 Inject (javax.inject.Inject)5 QueryContext (org.dcm4chee.arc.query.QueryContext)5 IOException (java.io.IOException)4