private static Dimse[] dimseArray(Preferences prefs, String key) { int n = prefs.getInt(key + ".#", 0); if (n == 0) return new Dimse[] {}; Dimse[] dimse = new Dimse[n]; for (int i = 0; i < n; i++) dimse[i] = Dimse.valueOf(prefs.get(key + '.' + (i + 1), null)); return dimse; }
private void storeForwardRuleDimse(ForwardRule rule, Preferences prefs) { List<String> dimseList = new ArrayList<String>(); for (Dimse dimse : rule.getDimse()) dimseList.add(dimse.toString()); PreferencesUtils.storeNotEmpty(prefs, "dcmForwardRuleDimse", dimseList.toArray(new String[dimseList.size()])); }
switch (this) { case C_STORE_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); promptMoveOriginatorTo(cmdAttrs, sb); break; case C_GET_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); promptAttributeIdentifierListTo(cmdAttrs, sb); break; case C_FIND_RQ: case C_MOVE_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); break; case C_GET_RSP: case C_MOVE_RSP: promptNumberOfSubOpsTo(cmdAttrs, sb); break; case N_EVENT_REPORT_RQ: case N_EVENT_REPORT_RSP: promptIntTo(cmdAttrs, ", eventID=", Tag.EventTypeID, sb); break; case N_ACTION_RQ: case N_ACTION_RSP: promptIntTo(cmdAttrs, ", actionID=", Tag.ActionTypeID, sb); break; if (isRSP()) { sb.append(", status=") .append(Integer.toHexString(cmdAttrs.getInt(Tag.Status, -1)))
public static Attributes mkRSP(Attributes rq, int status, Dimse rqCmd) { Attributes rsp = new Attributes(); rsp.setInt(Tag.CommandField, VR.US, rqCmd.commandFieldOfRSP()); rsp.setInt(Tag.Status, VR.US, status); rsp.setInt(Tag.MessageIDBeingRespondedTo, VR.US, rq.getInt(Tag.MessageID, 0)); rsp.setString(Tag.AffectedSOPClassUID, VR.UI, rq.getString(rqCmd.tagOfSOPClassUID())); int tagOfIUID = rqCmd.tagOfSOPInstanceUID(); if (tagOfIUID != 0) rsp.setString(Tag.AffectedSOPInstanceUID, VR.UI, rq.getString(tagOfIUID)); return rsp; }
int pcid = pc.getPCID(); String tsuid = pc.getTransferSyntax(); Dimse dimse = Dimse.valueOf(cmd.getInt(Tag.CommandField, -1)); if (!dimse.isRSP() || !Status.isPending(cmd.getInt(Tag.Status, -1))) as.incSentCount(dimse); if (Dimse.LOG.isInfoEnabled()) { Dimse.LOG.info("{} << {}", as, dimse.toString(cmd, pcid, tsuid)); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} << {} Command:\n{}", as, dimse.toString(cmd), cmd); if (Dimse.LOG.isDebugEnabled()) { if (dataWriter instanceof DataWriterAdapter) Dimse.LOG.debug("{} << {} Dataset:\n{}", as, dimse.toString(cmd), ((DataWriterAdapter) dataWriter).getDataset()); else Dimse.LOG.debug("{} << {} Dataset sending...", as, dimse.toString(cmd)); Dimse.LOG.debug("{} << {} Dataset sent", as, dimse.toString(cmd)); close();
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, PDVInputStream data) throws IOException { try { lookupService(as, dimse, cmd).onDimseRQ(as, pc, dimse, cmd, data); } catch (DicomServiceException e) { Association.LOG.info("{}: processing {} failed. Caused by:\t", as, dimse.toString(cmd, pc.getPCID(), pc.getTransferSyntax()), e); Attributes rsp = e.mkRSP(dimse.commandFieldOfRSP(), cmd.getInt(Tag.MessageID, 0)); as.tryWriteDimseRSP(pc, rsp, e.getDataset()); } }
private DicomMessage(Dimse dimse, Attributes cmd, Object data) { this.cmd = cmd; setMessageId(cmd.getString(Tag.MessageID)); setHeader("dimse", dimse); setHeader("sopclass", cmd.getString(dimse.tagOfSOPClassUID())); setHeader("sopinstance", cmd.getString(dimse.tagOfSOPInstanceUID())); setBody(data); }
private DimseRQHandler lookupService(Association as, Dimse dimse, Attributes cmd) throws DicomServiceException { String cuid = cmd.getString(dimse.tagOfSOPClassUID()); if (cuid == null) throw new DicomServiceException(Status.MistypedArgument); DimseRQHandler service = services.get(cuid); if (service != null) return service; if (dimse == Dimse.C_STORE_RQ) { CommonExtendedNegotiation commonExtNeg = as .getCommonExtendedNegotiationFor(cuid); if (commonExtNeg != null) { for (String uid : commonExtNeg.getRelatedGeneralSOPClassUIDs()) { service = services.get(uid); if (service != null) return service; } service = services.get(commonExtNeg.getServiceClassUID()); if (service != null) return service; } service = services.get("*"); if (service != null) return service; } throw new DicomServiceException(dimse.isCService() ? Status.SOPclassNotSupported : Status.NoSuchSOPclass); }
String tsuid = pc.getTransferSyntax(); if (Dimse.LOG.isInfoEnabled()) { Dimse.LOG.info("{} >> {}", as, dimse.toString(cmd, pcid, tsuid)); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} >> {} Command:\n{}", as, dimse.toString(cmd), cmd); } else if (Commands.hasDataset(cmd)) { nextPDV(PDVType.DATA, pcid); if (dimse.isRSP()) { Attributes data = readDataset(tsuid); Dimse.LOG.debug("Dataset:\n{}", data); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} >> {} Dataset:\n{}", as, dimse.toString(cmd), data); Dimse.LOG.debug("{} >> {} Dataset receiving...", as, dimse.toString(cmd)); if (dimse.isRSP()) { as.onDimseRSP(dimse, cmd, null); } else {
void incSentCount(Dimse dimse) { dimseCounters.getAndIncrement(dimse.ordinal()); }
@Override public void done(boolean doneSync) { Attributes cmd; Attributes data; if (exchange.getException() != null) { DicomServiceException dse; Exception ex = exchange.getException(); if (ex instanceof DicomServiceException) { dse = (DicomServiceException) ex; } else { dse = new DicomServiceException(Status.ProcessingFailure, ex); } cmd = dse.mkRSP(dimse.commandFieldOfRSP(), msgId); data = dse.getDataset(); } else { DicomMessage out = exchange.getOut(DicomMessage.class); cmd = out.getCommand(); data = out.getBody(Attributes.class); } as.tryWriteDimseRSP(pc, cmd, data); }
public static Attributes mkCCancelRQ(int msgId) { Attributes rq = new Attributes(); rq.setInt(Tag.CommandField, VR.US, Dimse.C_CANCEL_RQ.commandField()); rq.setInt(Tag.CommandDataSetType, VR.US, NO_DATASET); rq.setInt(Tag.MessageIDBeingRespondedTo, VR.US, msgId); return rq; }
public static Attributes mkRSP(Attributes rq, int status, Dimse rqCmd) { Attributes rsp = new Attributes(); rsp.setInt(Tag.CommandField, VR.US, rqCmd.commandFieldOfRSP()); rsp.setInt(Tag.Status, VR.US, status); rsp.setInt(Tag.MessageIDBeingRespondedTo, VR.US, rq.getInt(Tag.MessageID, 0)); rsp.setString(Tag.AffectedSOPClassUID, VR.UI, rq.getString(rqCmd.tagOfSOPClassUID())); int tagOfIUID = rqCmd.tagOfSOPInstanceUID(); if (tagOfIUID != 0) rsp.setString(Tag.AffectedSOPInstanceUID, VR.UI, rq.getString(tagOfIUID)); return rsp; }
int pcid = pc.getPCID(); String tsuid = pc.getTransferSyntax(); Dimse dimse = Dimse.valueOf(cmd.getInt(Tag.CommandField, -1)); if (!dimse.isRSP() || !Status.isPending(cmd.getInt(Tag.Status, -1))) as.incSentCount(dimse); if (Dimse.LOG.isInfoEnabled()) { Dimse.LOG.info("{} << {}", as, dimse.toString(cmd, pcid, tsuid)); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} << {} Command:\n{}", as, dimse.toString(cmd), cmd); if (Dimse.LOG.isDebugEnabled()) { if (dataWriter instanceof DataWriterAdapter) Dimse.LOG.debug("{} << {} Dataset:\n{}", as, dimse.toString(cmd), ((DataWriterAdapter) dataWriter).getDataset()); else Dimse.LOG.debug("{} << {} Dataset sending...", as, dimse.toString(cmd)); Dimse.LOG.debug("{} << {} Dataset sent", as, dimse.toString(cmd)); close();
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, PDVInputStream data) throws IOException { try { lookupService(as, dimse, cmd).onDimseRQ(as, pc, dimse, cmd, data); } catch (DicomServiceException e) { Association.LOG.info("{}: processing {} failed. Caused by:\t", as, dimse.toString(cmd, pc.getPCID(), pc.getTransferSyntax()), e); Attributes rsp = e.mkRSP(dimse.commandFieldOfRSP(), cmd.getInt(Tag.MessageID, 0)); as.tryWriteDimseRSP(pc, rsp, e.getDataset()); } }
private DimseRQHandler lookupService(Association as, Dimse dimse, Attributes cmd) throws DicomServiceException { String cuid = cmd.getString(dimse.tagOfSOPClassUID()); if (cuid == null) throw new DicomServiceException(Status.MistypedArgument); DimseRQHandler service = services.get(cuid); if (service != null) return service; if (dimse == Dimse.C_STORE_RQ) { CommonExtendedNegotiation commonExtNeg = as .getCommonExtendedNegotiationFor(cuid); if (commonExtNeg != null) { for (String uid : commonExtNeg.getRelatedGeneralSOPClassUIDs()) { service = services.get(uid); if (service != null) return service; } service = services.get(commonExtNeg.getServiceClassUID()); if (service != null) return service; } service = services.get("*"); if (service != null) return service; } throw new DicomServiceException(dimse.isCService() ? Status.SOPclassNotSupported : Status.NoSuchSOPclass); }
String tsuid = pc.getTransferSyntax(); if (Dimse.LOG.isInfoEnabled()) { Dimse.LOG.info("{} >> {}", as, dimse.toString(cmd, pcid, tsuid)); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} >> {} Command:\n{}", as, dimse.toString(cmd), cmd); } else if (Commands.hasDataset(cmd)) { nextPDV(PDVType.DATA, pcid); if (dimse.isRSP()) { Attributes data = readDataset(tsuid); Dimse.LOG.debug("Dataset:\n{}", data); if (Dimse.LOG.isDebugEnabled()) { Dimse.LOG.debug("{} >> {} Dataset:\n{}", as, dimse.toString(cmd), data); Dimse.LOG.debug("{} >> {} Dataset receiving...", as, dimse.toString(cmd)); if (dimse.isRSP()) { as.onDimseRSP(dimse, cmd, null); } else {
public int getNumberOfSent(Dimse dimse) { return dimseCounters.get(dimse.ordinal()); }
public static Attributes mkCCancelRQ(int msgId) { Attributes rq = new Attributes(); rq.setInt(Tag.CommandField, VR.US, Dimse.C_CANCEL_RQ.commandField()); rq.setInt(Tag.CommandDataSetType, VR.US, NO_DATASET); rq.setInt(Tag.MessageIDBeingRespondedTo, VR.US, msgId); return rq; }
switch (this) { case C_STORE_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); promptMoveOriginatorTo(cmdAttrs, sb); break; case C_GET_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); promptAttributeIdentifierListTo(cmdAttrs, sb); break; case C_FIND_RQ: case C_MOVE_RQ: promptIntTo(cmdAttrs, ", prior=", Tag.Priority, sb); break; case C_GET_RSP: case C_MOVE_RSP: promptNumberOfSubOpsTo(cmdAttrs, sb); break; case N_EVENT_REPORT_RQ: case N_EVENT_REPORT_RSP: promptIntTo(cmdAttrs, ", eventID=", Tag.EventTypeID, sb); break; case N_ACTION_RQ: case N_ACTION_RSP: promptIntTo(cmdAttrs, ", actionID=", Tag.ActionTypeID, sb); break; if (isRSP()) { sb.append(", status=") .append(Integer.toHexString(cmdAttrs.getInt(Tag.Status, -1)))