private void wrappedFindNextInstance() throws DicomServiceException { try { findNextInstance(); } catch (IOException e) { throw new DicomServiceException(Status.UnableToProcess, e); } }
private static DicomServiceException identifierDoesNotMatchSOPClass(String comment, int tag) { return new DicomServiceException(Status.IdentifierDoesNotMatchSOPClass, comment) .setOffendingElements(tag); } }
public static void mayNoLongerBeUpdated() throws DicomServiceException { throw new DicomServiceException(Status.ProcessingFailure, "Performed Procedure Step Object may no longer be updated") .setErrorID(0xA710); }
public static DicomServiceException valueOf(ValidationResult result, Attributes attrs) { if (result.hasNotAllowedAttributes()) return new DicomServiceException(Status.NoSuchAttribute) .setAttributeIdentifierList(result.tagsOfNotAllowedAttributes()); if (result.hasMissingAttributes()) return new DicomServiceException(Status.MissingAttribute) .setAttributeIdentifierList(result.tagsOfMissingAttributes()); if (result.hasMissingAttributeValues()) return new DicomServiceException(Status.MissingAttributeValue) .setDataset(new Attributes(attrs, result.tagsOfMissingAttributeValues())); if (result.hasInvalidAttributeValues()) return new DicomServiceException(Status.InvalidAttributeValue) .setDataset(new Attributes(attrs, result.tagsOfInvalidAttributeValues())); return null; } }
@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); }
ValidationResult result = rqAttrs.validate(mppsNCreateIOD); if (!result.isValid()) throw DicomServiceException.valueOf(result, rqAttrs); File file = new File(storageDir, iuid); if (file.exists()) throw new DicomServiceException(Status.DuplicateSOPinstance). setUID(Tag.AffectedSOPInstanceUID, iuid); DicomOutputStream out = null; LOG.info("{}: M-WRITE {}", as, file); } catch (IOException e) { LOG.warn(as + ": Failed to store MPPS:", e); throw new DicomServiceException(Status.ProcessingFailure, e); } finally { SafeClose.close(out);
private Attributes create(Association as, Attributes rq, Attributes rqAttrs) throws DicomServiceException { if (storageDir == null) return null; String cuid = rq.getString(Tag.AffectedSOPClassUID); String iuid = rq.getString(Tag.AffectedSOPInstanceUID); File file = new File(storageDir, iuid); if (file.exists()) throw new DicomServiceException(Status.DuplicateSOPinstance). setUID(Tag.AffectedSOPInstanceUID, iuid); DicomOutputStream out = null; LOG.info("{}: M-WRITE {}", as, file); try { out = new DicomOutputStream(file); out.writeDataset( Attributes.createFileMetaInformation(iuid, cuid, UID.ExplicitVRLittleEndian), rqAttrs); } catch (IOException e) { LOG.warn(as + ": Failed to store Instance Available Notification:", e); throw new DicomServiceException(Status.ProcessingFailure, e); } finally { SafeClose.close(out); } return null; } }
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, Attributes data) throws IOException { if (dimse != Dimse.N_EVENT_REPORT_RQ) throw new DicomServiceException(Status.UnrecognizedOperation); int eventTypeID = cmd.getInt(Tag.EventTypeID, 0); if (eventTypeID != 1 && eventTypeID != 2) throw new DicomServiceException(Status.NoSuchEventType) .setEventTypeID(eventTypeID); String tuid = data.getString(Tag.TransactionUID); try { Attributes rsp = Commands.mkNEventReportRSP(cmd, status); Attributes rspAttrs = StgCmtSCU.this.eventRecord(as, cmd, data); as.writeDimseRSP(pc, rsp, rspAttrs); } catch (AssociationStateException e) { LOG.warn("{} << N-EVENT-RECORD-RSP failed: {}", as, e.getMessage()); } finally { removeOutstandingResult(tuid); } } };
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes rq, Attributes actionInfo) throws IOException { if (dimse != Dimse.N_ACTION_RQ) throw new DicomServiceException(Status.UnrecognizedOperation); int actionTypeID = rq.getInt(Tag.ActionTypeID, 0); if (actionTypeID != 1) throw new DicomServiceException(Status.NoSuchActionType) .setActionTypeID(actionTypeID); Attributes rsp = Commands.mkNActionRSP(rq, Status.Success); String callingAET = as.getCallingAET(); String calledAET = as.getCalledAET(); Connection remoteConnection = getRemoteConnection(callingAET); if (remoteConnection == null) throw new DicomServiceException(Status.ProcessingFailure, "Unknown Calling AET: " + callingAET); Attributes eventInfo = calculateStorageCommitmentResult(calledAET, actionInfo); try { as.writeDimseRSP(pc, rsp, null); device.execute(new SendStgCmtResult(as, eventInfo, stgCmtOnSameAssoc, remoteConnection)); } catch (AssociationStateException e) { LOG.warn("{} << N-ACTION-RSP failed: {}", as, e.getMessage()); } }
@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 static DicomServiceException identifierDoesNotMatchSOPClass(String comment, int tag) { return new DicomServiceException(Status.IdentifierDoesNotMatchSOPClass, comment) .setOffendingElements(tag); } }
ValidationResult result = rqAttrs.validate(mppsNSetIOD); if (!result.isValid()) throw DicomServiceException.valueOf(result, rqAttrs); File file = new File(storageDir, iuid); if (!file.exists()) throw new DicomServiceException(Status.NoSuchObjectInstance). setUID(Tag.AffectedSOPInstanceUID, iuid); LOG.info("{}: M-UPDATE {}", as, file); Attributes data; } catch (IOException e) { LOG.warn(as + ": Failed to read MPPS:", e); throw new DicomServiceException(Status.ProcessingFailure, e); } finally { SafeClose.close(in); } catch (IOException e) { LOG.warn(as + ": Failed to update MPPS:", e); throw new DicomServiceException(Status.ProcessingFailure, e); } finally { SafeClose.close(out);
public static DicomServiceException valueOf(ValidationResult result, Attributes attrs) { if (result.hasNotAllowedAttributes()) return new DicomServiceException(Status.NoSuchAttribute) .setAttributeIdentifierList(result.tagsOfNotAllowedAttributes()); if (result.hasMissingAttributes()) return new DicomServiceException(Status.MissingAttribute) .setAttributeIdentifierList(result.tagsOfMissingAttributes()); if (result.hasMissingAttributeValues()) return new DicomServiceException(Status.MissingAttributeValue) .setDataset(new Attributes(attrs, result.tagsOfMissingAttributeValues())); if (result.hasInvalidAttributeValues()) return new DicomServiceException(Status.InvalidAttributeValue) .setDataset(new Attributes(attrs, result.tagsOfInvalidAttributeValues())); return null; } }
private Attributes create(Association as, Attributes rq, Attributes rqAttrs) throws DicomServiceException { if (storageDir == null) return null; String cuid = rq.getString(Tag.AffectedSOPClassUID); String iuid = rq.getString(Tag.AffectedSOPInstanceUID); File file = new File(storageDir, iuid); if (file.exists()) throw new DicomServiceException(Status.DuplicateSOPinstance). setUID(Tag.AffectedSOPInstanceUID, iuid); DicomOutputStream out = null; LOG.info("{}: M-WRITE {}", as, file); try { out = new DicomOutputStream(file); out.writeDataset( Attributes.createFileMetaInformation(iuid, cuid, UID.ExplicitVRLittleEndian), rqAttrs); } catch (IOException e) { LOG.warn(as + ": Failed to store Instance Available Notification:", e); throw new DicomServiceException(Status.ProcessingFailure, e); } finally { SafeClose.close(out); } return null; } }
public static void mayNoLongerBeUpdated() throws DicomServiceException { throw new DicomServiceException(Status.ProcessingFailure, "Performed Procedure Step Object may no longer be updated") .setErrorID(0xA710); }
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes cmd, Attributes data) throws IOException { if (dimse != Dimse.N_EVENT_REPORT_RQ) throw new DicomServiceException(Status.UnrecognizedOperation); int eventTypeID = cmd.getInt(Tag.EventTypeID, 0); if (eventTypeID != 1 && eventTypeID != 2) throw new DicomServiceException(Status.NoSuchEventType) .setEventTypeID(eventTypeID); String tuid = data.getString(Tag.TransactionUID); try { Attributes rsp = Commands.mkNEventReportRSP(cmd, status); Attributes rspAttrs = StgCmtSCU.this.eventRecord(as, cmd, data); as.writeDimseRSP(pc, rsp, rspAttrs); } catch (AssociationStateException e) { LOG.warn("{} << N-EVENT-RECORD-RSP failed: {}", as, e.getMessage()); } finally { removeOutstandingResult(tuid); } } };
@Override public void onDimseRQ(Association as, PresentationContext pc, Dimse dimse, Attributes rq, Attributes actionInfo) throws IOException { if (dimse != Dimse.N_ACTION_RQ) throw new DicomServiceException(Status.UnrecognizedOperation); int actionTypeID = rq.getInt(Tag.ActionTypeID, 0); if (actionTypeID != 1) throw new DicomServiceException(Status.NoSuchActionType) .setActionTypeID(actionTypeID); Attributes rsp = Commands.mkNActionRSP(rq, Status.Success); String callingAET = as.getCallingAET(); String calledAET = as.getCalledAET(); Connection remoteConnection = getRemoteConnection(callingAET); if (remoteConnection == null) throw new DicomServiceException(Status.ProcessingFailure, "Unknown Calling AET: " + callingAET); Attributes eventInfo = calculateStorageCommitmentResult(calledAET, actionInfo); try { as.writeDimseRSP(pc, rsp, null); device.execute(new SendStgCmtResult(as, eventInfo, stgCmtOnSameAssoc, remoteConnection)); } catch (AssociationStateException e) { LOG.warn("{} << N-ACTION-RSP failed: {}", as, e.getMessage()); } }
@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 void wrappedFindNextSeries() throws DicomServiceException { try { findNextSeries(); } catch (IOException e) { throw new DicomServiceException(Status.UnableToProcess, e); } }
private static void check(ValidationResult result) throws DicomServiceException { if (!result.isValid()) throw new DicomServiceException( Status.IdentifierDoesNotMatchSOPClass, result.getErrorComment()) .setOffendingElements(result.getOffendingElements()); } }