Search in sources :

Example 16 with DimseRSP

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

the class UPSIANSCU method processA.

@Override
protected void processA(UPSContext upsCtx, Attributes ups) throws Exception {
    String destinationAE = destinationAEOf(ups);
    ApplicationEntity ae = Objects.requireNonNull(device.getApplicationEntity(rule.getAETitle(), true), () -> String.format("No such Archive AE - %s", rule.getAETitle()));
    for (Map.Entry<String, IanInfo> entry : studyIanInfoFrom(ups).entrySet()) {
        IanInfo ianInfo = entry.getValue();
        Attributes ian = queryService.createIAN(ae, entry.getKey(), ianInfo.getSeriesRefSOPSeq().keySet().toArray(new String[0]), null, null, null, null);
        if (ian == null) {
            LOG.info("Ignore IAN of Study[uid={}] without referenced objects.", entry.getKey());
            continue;
        }
        ianInfo.setIan(ian);
        String sopInstanceUID = UIDUtils.createUID();
        DimseRSP dimseRSP = ianSCU.sendIANRQ(rule.getAETitle(), destinationAE, sopInstanceUID, ianInfo.getIan());
        dimseRSP.next();
        Attributes cmd = dimseRSP.getCommand();
        int status = cmd.getInt(Tag.Status, -1);
        getPerformedProcedureStep(upsCtx).setString(Tag.PerformedProcedureStepDescription, VR.LO, outcomeDesc(status, cmd.getString(Tag.ErrorComment), sopInstanceUID, destinationAE));
    }
}
Also used : ApplicationEntity(org.dcm4che3.net.ApplicationEntity) DimseRSP(org.dcm4che3.net.DimseRSP) Attributes(org.dcm4che3.data.Attributes) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with DimseRSP

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

the class CFindSCUImpl method find.

private List<Attributes> find(Association as, int priority, Attributes keys) throws Exception {
    List<Attributes> list = new ArrayList<>();
    DimseRSP rsp = query(as, priority, coerceCFindRQ(as, keys), 0, 1, null);
    rsp.next();
    Attributes match = rsp.getDataset();
    String defaultCharacterSet = as.getApplicationEntity().getAEExtensionNotNull(ArchiveAEExtension.class).defaultCharacterSet();
    while (rsp.next()) {
        if (defaultCharacterSet != null && !match.containsValue(Tag.SpecificCharacterSet)) {
            LOG.info("{}: No Specific Character Set (0008,0005) in received C-FIND RSP - " + "supplement configured Default Character Set: {}", as, defaultCharacterSet);
            match.setString(Tag.SpecificCharacterSet, VR.CS, defaultCharacterSet);
        }
        list.add(coerceCFindRSP(as, match));
        match = rsp.getDataset();
    }
    Attributes cmd = rsp.getCommand();
    int status = cmd.getInt(Tag.Status, -1);
    if (status != Status.Success)
        throw new DicomServiceException(status, cmd.getString(Tag.ErrorComment));
    return list;
}
Also used : ArrayList(java.util.ArrayList) DicomServiceException(org.dcm4che3.net.service.DicomServiceException)

Example 18 with DimseRSP

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

the class StgCmtImpl method sendNActionRQ.

@Override
public DimseRSP sendNActionRQ(String localAET, String remoteAET, String studyInstanceUID, String seriesInstanceUID, String sopInstanceUID, String exporterID, Long taskPK, String batchID, Attributes actionInfo) throws Exception {
    ApplicationEntity localAE = device.getApplicationEntity(localAET, true);
    ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET);
    AAssociateRQ aarq = mkAAssociateRQ(localAE, TransferCapability.Role.SCU);
    if (!localAE.isMasqueradeCallingAETitle(remoteAET))
        aarq.setCallingAET(localAET);
    Association as = localAE.connect(remoteAE, aarq);
    try {
        StgCmtResult result = new StgCmtResult();
        result.setStgCmtRequest(actionInfo);
        result.setStudyInstanceUID(studyInstanceUID);
        result.setSeriesInstanceUID(seriesInstanceUID);
        result.setSopInstanceUID(sopInstanceUID);
        result.setExporterID(exporterID);
        result.setTaskPK(taskPK);
        result.setBatchID(batchID);
        result.setDeviceName(device.getDeviceName());
        ejb.persistStgCmtResult(result);
        DimseRSP dimseRSP = as.naction(UID.StorageCommitmentPushModel, UID.StorageCommitmentPushModelInstance, 1, actionInfo, null);
        dimseRSP.next();
        if (dimseRSP.getCommand().getInt(Tag.Status, -1) != Status.Success)
            ejb.deleteStgCmt(actionInfo.getString(Tag.TransactionUID));
        return dimseRSP;
    } catch (Exception e) {
        ejb.deleteStgCmt(actionInfo.getString(Tag.TransactionUID));
        throw e;
    } finally {
        try {
            as.release();
        } catch (IOException e) {
            LOG.info("{}: Failed to release association to {}", as, remoteAET);
        }
    }
}
Also used : AAssociateRQ(org.dcm4che3.net.pdu.AAssociateRQ) StgCmtResult(org.dcm4chee.arc.entity.StgCmtResult) IOException(java.io.IOException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) ConfigurationNotFoundException(org.dcm4che3.conf.api.ConfigurationNotFoundException) IOException(java.io.IOException)

Example 19 with DimseRSP

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

the class StgCmtImpl method sendNEventReport.

@Override
public Outcome sendNEventReport(String localAET, ApplicationEntity remoteAE, Attributes eventInfo) throws Exception {
    ApplicationEntity localAE = device.getApplicationEntity(localAET, true);
    AAssociateRQ aarq = mkAAssociateRQ(localAE, TransferCapability.Role.SCP);
    aarq.setCallingAET(localAET);
    Association as = localAE.connect(remoteAE, aarq);
    try {
        int successful = sequenceSizeOf(eventInfo, Tag.ReferencedSOPSequence);
        int failed = sequenceSizeOf(eventInfo, Tag.FailedSOPSequence);
        DimseRSP neventReport = as.neventReport(UID.StorageCommitmentPushModel, UID.StorageCommitmentPushModelInstance, failed > 0 ? 2 : 1, eventInfo, null);
        neventReport.next();
        return new Outcome(failed > 0 ? Task.Status.WARNING : Task.Status.COMPLETED, "Return Storage Commitment Result[successful: " + successful + ", failed: " + failed + "] to AE: " + remoteAE.getAETitle());
    } finally {
        try {
            as.release();
        } catch (IOException e) {
            LOG.info("{}: Failed to release association to {}", as, remoteAE.getAETitle());
        }
    }
}
Also used : AAssociateRQ(org.dcm4che3.net.pdu.AAssociateRQ) Outcome(org.dcm4chee.arc.qmgt.Outcome) IOException(java.io.IOException)

Example 20 with DimseRSP

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

the class StgCmtSCURS method storageCommit.

private Response storageCommit(String studyUID, String seriesUID, String sopUID, String externalAET) {
    logRequest();
    ApplicationEntity ae = device.getApplicationEntity(aet, true);
    if (ae == null || !ae.isInstalled())
        return errResponse("No such Application Entity: " + aet, Response.Status.NOT_FOUND);
    try {
        aeCache.findApplicationEntity(externalAET);
    } catch (ConfigurationException e) {
        return errResponse(e.getMessage(), Response.Status.NOT_FOUND);
    }
    try {
        Response.Status rspStatus = Response.Status.BAD_GATEWAY;
        Attributes actionInfo = queryService.createActionInfo(studyUID, seriesUID, sopUID, ae);
        if (actionInfo == null || actionInfo.getSequence(Tag.ReferencedSOPSequence).isEmpty())
            return errResponse("No matching instances", Response.Status.NOT_FOUND);
        DimseRSP dimseRSP = stgCmtSCU.sendNActionRQ(aet, externalAET, studyUID, seriesUID, sopUID, null, null, null, actionInfo);
        if (dimseRSP.getCommand().getInt(Tag.Status, -1) == Status.Success)
            rspStatus = Response.Status.OK;
        return Response.status(rspStatus).entity(entity(actionInfo, dimseRSP)).build();
    } catch (IOException e) {
        return errResponse(e.getMessage(), Response.Status.BAD_GATEWAY);
    } catch (Exception e) {
        return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : Response(javax.ws.rs.core.Response) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) DimseRSP(org.dcm4che3.net.DimseRSP) Attributes(org.dcm4che3.data.Attributes) IOException(java.io.IOException) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) IOException(java.io.IOException)

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