try { if (pendingRSPInterval > 0) startWritePendingRSP(); for (Iterator<T> iter = insts.iterator(); iter.hasNext();) { T inst = iter.next(); writePendingRSP(); String tsuid; DataWriter dataWriter; try { tsuid = selectTransferSyntaxFor(storeas, inst); dataWriter = createDataWriter(inst, tsuid); } catch (Exception e) { status = Status.OneOrMoreFailures; cstore(storeas, inst, tsuid, dataWriter); } catch (Exception e) { status = Status.UnableToPerformSubOperations; waitForOutstandingCStoreRSP(storeas); if (isCMove()) releaseStoreAssociation(storeas); stopWritePendingRSP(); writeRSP(status); } finally { rqas.removeCancelRQHandler(msgId); try { close(); } catch (Throwable e) {
private void writeRSP(int status) { Attributes cmd = Commands.mkRSP(rqCmd, status, rq); if (status == Status.Pending || status == Status.Cancel) cmd.setInt(Tag.NumberOfRemainingSuboperations, VR.US, remaining()); cmd.setInt(Tag.NumberOfCompletedSuboperations, VR.US, completed.size()); cmd.setInt(Tag.NumberOfFailedSuboperations, VR.US, failed.size()); cmd.setInt(Tag.NumberOfWarningSuboperations, VR.US, warning.size()); Attributes data = null; if (!failed.isEmpty() && status != Status.Pending) { data = new Attributes(1); String[] iuids = new String[failed.size()]; for (int i = 0; i < iuids.length; i++) { iuids[i] = failed.get(0).iuid; } data.setString(Tag.FailedSOPInstanceUIDList, VR.UI, iuids); } writeRSP(cmd, data); }
private void writeRSP(Attributes cmd, Attributes data) { try { rqas.writeDimseRSP(pc, cmd, data); } catch (IOException e) { pendingRSP = false; stopWritePendingRSP(); LOG.warn("{}: Unable to send C-GET or C-MOVE RSP on association to {}", rqas, rqas.getRemoteAET(), e); } }
protected void cstore(Association storeas, T inst, String tsuid, DataWriter dataWriter) throws IOException, InterruptedException { DimseRSPHandler rspHandler = new CStoreRSPHandler(storeas.nextMessageID(), inst); if (isCMove()) storeas.cstore(inst.cuid, inst.iuid, priority, rqas.getRemoteAET(), msgId, dataWriter, tsuid, rspHandler); else storeas.cstore(inst.cuid, inst.iuid, priority, dataWriter, tsuid, rspHandler); synchronized (outstandingRSPLock) { outstandingRSP++; } }
@Override protected RetrieveTask calculateMatches(Association as, PresentationContext pc, final Attributes rq, Attributes keys) throws DicomServiceException { QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(keys, qrLevels); level.validateRetrieveKeys(keys, rootLevel, relational(as, rq)); String moveDest = rq.getString(Tag.MoveDestination); final Connection remote = getRemoteConnection(moveDest); if (remote == null) throw new DicomServiceException(Status.MoveDestinationUnknown, "Move Destination: " + moveDest + " unknown"); List<InstanceLocator> matches = DcmQRSCP.this.calculateMatches(keys); if (matches.isEmpty()) return null; AAssociateRQ aarq = makeAAssociateRQ(as.getLocalAET(), moveDest, matches); Association storeas = openStoreAssociation(as, remote, aarq); BasicRetrieveTask retrieveTask = new RetrieveTaskImpl( Dimse.C_MOVE_RQ, as, pc, rq, matches, storeas, false, delayCStore); retrieveTask.setSendPendingRSPInterval(getSendPendingCMoveInterval()); return retrieveTask; }
private void writeRSP(Attributes cmd, Attributes data) { try { rqas.writeDimseRSP(pc, cmd, data); } catch (IOException e) { pendingRSP = false; stopWritePendingRSP(); LOG.warn("{}: Unable to send C-GET or C-MOVE RSP on association to {}", rqas, rqas.getRemoteAET(), e); } }
protected void cstore(Association storeas, T inst, String tsuid, DataWriter dataWriter) throws IOException, InterruptedException { DimseRSPHandler rspHandler = new CStoreRSPHandler(storeas.nextMessageID(), inst); if (isCMove()) storeas.cstore(inst.cuid, inst.iuid, priority, rqas.getRemoteAET(), msgId, dataWriter, tsuid, rspHandler); else storeas.cstore(inst.cuid, inst.iuid, priority, dataWriter, tsuid, rspHandler); synchronized (outstandingRSPLock) { outstandingRSP++; } }
@Override protected RetrieveTask calculateMatches(Association as, PresentationContext pc, final Attributes rq, Attributes keys) throws DicomServiceException { QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(keys, qrLevels); level.validateRetrieveKeys(keys, rootLevel, relational(as, rq)); String moveDest = rq.getString(Tag.MoveDestination); final Connection remote = getRemoteConnection(moveDest); if (remote == null) throw new DicomServiceException(Status.MoveDestinationUnknown, "Move Destination: " + moveDest + " unknown"); List<InstanceLocator> matches = DcmQRSCP.this.calculateMatches(keys); if (matches.isEmpty()) return null; AAssociateRQ aarq = makeAAssociateRQ(as.getLocalAET(), moveDest, matches); Association storeas = openStoreAssociation(as, remote, aarq); BasicRetrieveTask retrieveTask = new RetrieveTaskImpl( Dimse.C_MOVE_RQ, as, pc, rq, matches, storeas, false, delayCStore); retrieveTask.setSendPendingRSPInterval(getSendPendingCMoveInterval()); return retrieveTask; }
try { if (pendingRSPInterval > 0) startWritePendingRSP(); for (Iterator<T> iter = insts.iterator(); iter.hasNext();) { T inst = iter.next(); writePendingRSP(); String tsuid; DataWriter dataWriter; try { tsuid = selectTransferSyntaxFor(storeas, inst); dataWriter = createDataWriter(inst, tsuid); } catch (Exception e) { status = Status.OneOrMoreFailures; cstore(storeas, inst, tsuid, dataWriter); } catch (Exception e) { status = Status.UnableToPerformSubOperations; waitForOutstandingCStoreRSP(storeas); if (isCMove()) releaseStoreAssociation(storeas); stopWritePendingRSP(); writeRSP(status); } finally { rqas.removeCancelRQHandler(msgId); try { close(); } catch (Throwable e) {
private void writeRSP(int status) { Attributes cmd = Commands.mkRSP(rqCmd, status, rq); if (status == Status.Pending || status == Status.Cancel) cmd.setInt(Tag.NumberOfRemainingSuboperations, VR.US, remaining()); cmd.setInt(Tag.NumberOfCompletedSuboperations, VR.US, completed.size()); cmd.setInt(Tag.NumberOfFailedSuboperations, VR.US, failed.size()); cmd.setInt(Tag.NumberOfWarningSuboperations, VR.US, warning.size()); Attributes data = null; if (!failed.isEmpty() && status != Status.Pending) { data = new Attributes(1); String[] iuids = new String[failed.size()]; for (int i = 0; i < iuids.length; i++) { iuids[i] = failed.get(0).iuid; } data.setString(Tag.FailedSOPInstanceUIDList, VR.UI, iuids); } writeRSP(cmd, data); }