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));
}
}
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;
}
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);
}
}
}
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());
}
}
}
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);
}
}
Aggregations