Search in sources :

Example 1 with ArchiveAEExtension

use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.

the class RejectionServiceImpl method rejectionNoteObjectStorageID.

private String rejectionNoteObjectStorageID(StoreSession storeSession) {
    String rejectionNoteStorageAET = device.getDeviceExtension(ArchiveDeviceExtension.class).getRejectionNoteStorageAET();
    if (rejectionNoteStorageAET == null)
        return null;
    ApplicationEntity rjAE = getApplicationEntity(rejectionNoteStorageAET);
    ArchiveAEExtension rjArcAE;
    if (rjAE == null || !rjAE.isInstalled() || (rjArcAE = rjAE.getAEExtension(ArchiveAEExtension.class)) == null) {
        LOG.warn("Rejection Note Storage Application Entity with an Archive AE Extension not configured: {}", rejectionNoteStorageAET);
        return null;
    }
    String[] objectStorageIDs;
    if ((objectStorageIDs = rjArcAE.getObjectStorageIDs()).length > 0)
        return objectStorageIDs[0];
    LOG.warn("Object storage for rejection notes shall fall back on those configured for AE: {} since none are " + "configured for RejectionNoteStorageAE: {}", storeSession.getLocalApplicationEntity().getAETitle(), rejectionNoteStorageAET);
    return null;
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) ApplicationEntity(org.dcm4che3.net.ApplicationEntity)

Example 2 with ArchiveAEExtension

use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.

the class UPSQueryTask method run0.

private void run0() {
    try {
        QueryContext ctx = query.getQueryContext();
        ArchiveAEExtension arcAE = ctx.getArchiveAEExtension();
        ArchiveDeviceExtension arcdev = arcAE.getArchiveDeviceExtension();
        query.executeQuery(arcdev.getQueryFetchSize());
        super.run();
    } catch (Exception e) {
        writeDimseRSP(new DicomServiceException(Status.UnableToProcess, e));
    } finally {
        query.close();
    }
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) QueryContext(org.dcm4chee.arc.query.QueryContext) IOException(java.io.IOException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException)

Example 3 with ArchiveAEExtension

use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.

the class UpsMatchingRS method createWorkitemsMatching.

private Response createWorkitemsMatching(String method, QueryRetrieveLevel2 qrlevel, String studyIUID, String seriesIUID, InputStream in) {
    InputType inputType = InputType.valueOf(headers.getMediaType());
    if (inputType == null)
        return notAcceptable();
    try {
        ArchiveDeviceExtension arcDev = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
        ArchiveAEExtension arcAE = getArchiveAE();
        Attributes upsTemplateAttrs = inputType.parse(in);
        upsTemplateAttrs.setDate(Tag.ScheduledProcedureStepStartDateTime, VR.DT, scheduledTime());
        if (upsLabel != null)
            upsTemplateAttrs.setString(Tag.ProcedureStepLabel, VR.LO, upsLabel);
        QueryContext ctx = queryContext(method, qrlevel, studyIUID, seriesIUID, arcAE.getApplicationEntity());
        String warning = null;
        AtomicInteger count = new AtomicInteger();
        Response.Status status = Response.Status.ACCEPTED;
        Attributes ups = new Attributes(upsTemplateAttrs);
        int matches = 0;
        try (Query query = queryService.createQuery(ctx)) {
            try {
                query.executeQuery(arcDev.getQueryFetchSize());
                while (query.hasMoreMatches()) {
                    Attributes match = query.nextMatch();
                    if (match == null)
                        continue;
                    ups = studyIUID == null ? new Attributes(upsTemplateAttrs) : ups;
                    UPSUtils.updateUPSAttributes(ups, match, studyIUID, seriesIUID, aet);
                    matches++;
                    if (studyIUID == null)
                        createUPS(arcAE, ups, count);
                }
                if (matches > 0 && studyIUID != null)
                    createUPS(arcAE, ups, count);
            } catch (Exception e) {
                warning = e.getMessage();
                status = Response.Status.INTERNAL_SERVER_ERROR;
            }
        }
        if (count.get() == 0) {
            warning = "No matching Instances found. No Workitem was created.";
            status = Response.Status.NO_CONTENT;
        }
        Response.ResponseBuilder builder = Response.status(status);
        if (warning != null) {
            LOG.warn("Response {} caused by {}", status, warning);
            builder.header("Warning", warning);
        }
        return builder.entity("{\"count\":" + count + '}').build();
    } catch (IllegalStateException e) {
        return errResponse(Response.Status.NOT_FOUND, e.getMessage());
    } catch (Exception e) {
        return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) Query(org.dcm4chee.arc.query.Query) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) QueryContext(org.dcm4chee.arc.query.QueryContext) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 4 with ArchiveAEExtension

use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.

the class ImportStorageRS method reimportStudy.

@POST
@Path("/studies/{study}/reimport")
public void reimportStudy(@Suspended AsyncResponse ar, @PathParam("study") String studyUID) {
    Output output = selectMediaType();
    ApplicationEntity ae = getApplicationEntity();
    try {
        ArchiveAEExtension arcAE = ae.getAEExtensionNotNull(ArchiveAEExtension.class);
        List<Location> locations = deletionService.reimportStudy(studyUID, HttpServletRequestInfo.valueOf(request), arcAE);
        Attributes coerce = new QueryAttributes(uriInfo, null).getQueryKeys();
        Date now = reasonForModification != null && !coerce.isEmpty() ? new Date() : null;
        Attributes.UpdatePolicy updatePolicy = Attributes.UpdatePolicy.valueOf(this.updatePolicy);
        for (Location location : locations) {
            if (location.getObjectType() == Location.ObjectType.METADATA)
                continue;
            Storage storage = storageFactory.getStorage(getStorageDesc(location.getStorageID()));
            final StoreSession session = service.newStoreSession(HttpServletRequestInfo.valueOf(request), ae, aet, null).withObjectStorageID(location.getStorageID());
            StoreContext ctx = service.newStoreContext(session);
            ctx.getLocations().add(location);
            importInstanceOnStorage(storage, ctx, coerce, updatePolicy, now, location.getStoragePath());
        }
        rsForward.forward(RSOperation.ReimportStudy, arcAE, null, request);
    } catch (StudyNotFoundException e) {
        throw new WebApplicationException(e.getMessage(), Response.Status.NOT_FOUND);
    } catch (StudyNotEmptyException e) {
        throw new WebApplicationException(e.getMessage(), Response.Status.FORBIDDEN);
    } catch (Exception e) {
        throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
    }
    response.setString(Tag.RetrieveURL, VR.UR, retrieveURL());
    Response.ResponseBuilder responseBuilder = Response.status(status());
    ar.resume(responseBuilder.entity(output.entity(response, ae)).header("Warning", response.getString(Tag.ErrorComment)).build());
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) AsyncResponse(javax.ws.rs.container.AsyncResponse) QueryAttributes(org.dcm4chee.arc.query.util.QueryAttributes) Storage(org.dcm4chee.arc.storage.Storage) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) StudyNotFoundException(org.dcm4chee.arc.delete.StudyNotFoundException) Location(org.dcm4chee.arc.entity.Location) StoreSession(org.dcm4chee.arc.store.StoreSession) StoreContext(org.dcm4chee.arc.store.StoreContext) StudyNotEmptyException(org.dcm4chee.arc.delete.StudyNotEmptyException)

Example 5 with ArchiveAEExtension

use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.

the class QueryAETs method writeTo.

private void writeTo(ApplicationEntity ae, JsonGenerator gen) {
    ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
    JsonWriter writer = new JsonWriter(gen);
    gen.writeStartObject();
    gen.write("dicomAETitle", ae.getAETitle());
    writer.writeNotNullOrDef("dicomDescription", ae.getDescription(), null);
    writer.writeNotEmpty("dcmOtherAETitle", ae.getOtherAETitles());
    if (arcAE != null) {
        QueryRetrieveView queryRetrieveView = arcAE.getQueryRetrieveView();
        writer.writeNotDef("dcmHideNotRejectedInstances", queryRetrieveView != null && queryRetrieveView.isHideNotRejectedInstances(), false);
        writer.writeNotNullOrDef("dcmAllowDeletePatient", arcAE.allowDeletePatient(), null);
        writer.writeNotNullOrDef("dcmAllowDeleteStudyPermanently", arcAE.allowDeleteStudy(), null);
    }
    gen.writeEnd();
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) QueryRetrieveView(org.dcm4chee.arc.conf.QueryRetrieveView) JsonWriter(org.dcm4che3.conf.json.JsonWriter)

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