Search in sources :

Example 1 with DimseRSP

use of org.dcm4che3.net.DimseRSP in project dcm4chee-arc-light by dcm4che.

the class UPSStgCmtSCU method processA.

@Override
protected void processA(UPSContext upsCtx, Attributes ups) throws Exception {
    String destinationAE = destinationAEOf(ups);
    for (Map.Entry<String, StgCmtInfo> entry : seriesStgCmtInfoFrom(ups).entrySet()) {
        String seriesIUID = entry.getKey();
        StgCmtInfo stgCmtInfo = entry.getValue();
        DimseRSP dimseRSP = stgCmtSCU.sendNActionRQ(rule.getAETitle(), destinationAE, stgCmtInfo.getStudyIUID(), seriesIUID, null, null, null, ups.getString(Tag.ProcedureStepLabel), stgCmtInfo.getActionInfo());
        Attributes cmd = dimseRSP.getCommand();
        int status = cmd.getInt(Tag.Status, -1);
        getPerformedProcedureStep(upsCtx).setString(Tag.PerformedProcedureStepDescription, VR.LO, outcomeDesc(status, cmd.getString(Tag.ErrorComment), destinationAE));
    }
}
Also used : DimseRSP(org.dcm4che3.net.DimseRSP)

Example 2 with DimseRSP

use of org.dcm4che3.net.DimseRSP in project dcm4chee-arc-light by dcm4che.

the class UPSMoveSCU method processA.

@Override
protected void processA(UPSContext upsCtx, Attributes ups) throws Exception {
    String moveDest = moveDestOf(ups);
    String retrieveAET = retrieveAETOf(ups);
    List<Attributes> keyss = new KeysBuilder(ups).keys();
    Association as = moveSCU.openAssociation(upsCtx.getApplicationEntity(), retrieveAET);
    try {
        Sum sum = new Sum();
        for (Attributes keys : keyss) {
            DimseRSP rsp = moveSCU.cmove(as, 0, moveDest, keys);
            while (rsp.next()) ;
            sum.add(rsp);
        }
        getPerformedProcedureStep(upsCtx).setString(Tag.PerformedProcedureStepDescription, VR.LO, toDescription(retrieveAET, moveDest, sum));
        if (sum.getStatus() != Status.Success) {
            throw new DicomServiceException(sum.getStatus(), sum.getErrorComment());
        }
        if (sum.getNumberOfCompletedSuboperations() == 0 && sum.getNumberOfWarningSuboperations() == 0) {
            throw new UPSProcessorException(NOOP_UPS, "No DICOM instances transferred from " + retrieveAET + " to " + moveDest);
        }
    } finally {
        try {
            as.release();
        } catch (IOException e) {
            LOG.info("{}: Failed to release association:\\n", as, e);
        }
    }
}
Also used : Association(org.dcm4che3.net.Association) DimseRSP(org.dcm4che3.net.DimseRSP) IOException(java.io.IOException) UPSProcessorException(org.dcm4chee.arc.ups.process.UPSProcessorException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException)

Example 3 with DimseRSP

use of org.dcm4che3.net.DimseRSP in project dcm4chee-arc-light by dcm4che.

the class RetrieveRS method export.

private Response export(String destAET, Attributes keys) throws Exception {
    ApplicationEntity localAE = device.getApplicationEntity(aet, true);
    if (localAE == null || !localAE.isInstalled())
        throw new ConfigurationException("No such Application Entity: " + aet);
    Association as = moveSCU.openAssociation(localAE, externalAET);
    try {
        final DimseRSP rsp = moveSCU.cmove(as, priority(), destAET, keys);
        while (rsp.next()) ;
        Attributes cmd = rsp.getCommand();
        instancesRetrievedEvent.fire(createExtRetrieveCtx(destAET, keys).setRemoteHostName(ReverseDNS.hostNameOf(as.getSocket().getInetAddress())).setResponse(cmd));
        return status(cmd).entity(entity(cmd)).build();
    } finally {
        try {
            as.release();
        } catch (IOException e) {
            LOG.info("{}: Failed to release association:\\n", as, e);
        }
    }
}
Also used : ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) Attributes(org.dcm4che3.data.Attributes)

Example 4 with DimseRSP

use of org.dcm4che3.net.DimseRSP in project dcm4chee-arc-light by dcm4che.

the class MPPSSCUImpl method forwardMPPS.

@Override
public Outcome forwardMPPS(String localAET, String remoteAET, Dimse dimse, String sopInstanceUID, Attributes attrs, Attributes procAttrs) throws Exception {
    ApplicationEntity localAE = device.getApplicationEntity(localAET, true);
    ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET);
    AAssociateRQ aarq = mkAAssociateRQ(localAE);
    Association as = localAE.connect(remoteAE, aarq);
    ProcedureContext pCtx = createProcedureCtx(sopInstanceUID, attrs.getString(Tag.PerformedProcedureStepStatus), as, dimse, procAttrs);
    try {
        DimseRSP rsp = dimse == Dimse.N_CREATE_RQ ? as.ncreate(UID.ModalityPerformedProcedureStep, sopInstanceUID, attrs, null) : as.nset(UID.ModalityPerformedProcedureStep, sopInstanceUID, attrs, null);
        rsp.next();
        return outcome(rsp.getCommand().getInt(Tag.Status, -1), dimse, sopInstanceUID, remoteAET, pCtx);
    } finally {
        try {
            as.release();
        } catch (IOException e) {
            LOG.info("{}: Failed to release association to {}", as, remoteAET);
        } finally {
            procedureEvent.fire(pCtx);
        }
    }
}
Also used : AAssociateRQ(org.dcm4che3.net.pdu.AAssociateRQ) ProcedureContext(org.dcm4chee.arc.procedure.ProcedureContext) IOException(java.io.IOException)

Example 5 with DimseRSP

use of org.dcm4che3.net.DimseRSP in project dcm4chee-arc-light by dcm4che.

the class StgCmtImpl method sendNAction.

@Override
public Outcome sendNAction(String localAET, String remoteAET, String studyInstanceUID, String seriesInstanceUID, String sopInstanceUID, String exporterID, Long taskPK, String batchID, Attributes actionInfo) throws Exception {
    DimseRSP dimseRSP = sendNActionRQ(localAET, remoteAET, studyInstanceUID, seriesInstanceUID, sopInstanceUID, exporterID, taskPK, batchID, actionInfo);
    Attributes cmd = dimseRSP.getCommand();
    int status = cmd.getInt(Tag.Status, -1);
    if (status != Status.Success) {
        return new Outcome(Task.Status.WARNING, "Request Storage Commitment from AE: " + remoteAET + " failed with status: " + TagUtils.shortToHexString(status) + "H, error comment: " + cmd.getString(Tag.ErrorComment));
    }
    return new Outcome(Task.Status.COMPLETED, "Request Storage Commitment from AE: " + remoteAET);
}
Also used : Outcome(org.dcm4chee.arc.qmgt.Outcome) Attributes(org.dcm4che3.data.Attributes)

Aggregations

IOException (java.io.IOException)12 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)8 Attributes (org.dcm4che3.data.Attributes)8 DimseRSP (org.dcm4che3.net.DimseRSP)5 AAssociateRQ (org.dcm4che3.net.pdu.AAssociateRQ)5 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)5 Response (javax.ws.rs.core.Response)4 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)4 ApplicationEntity (org.dcm4che3.net.ApplicationEntity)3 Outcome (org.dcm4chee.arc.qmgt.Outcome)3 JsonGenerator (javax.json.stream.JsonGenerator)2 StreamingOutput (javax.ws.rs.core.StreamingOutput)2 JSONWriter (org.dcm4che3.json.JSONWriter)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1