@Override protected DataWriter createDataWriter(InstanceLocator inst, String tsuid) throws IOException { Attributes attrs; DicomInputStream in = new DicomInputStream(inst.getFile()); try { if (withoutBulkData) { in.setIncludeBulkData(false); attrs = in.readDataset(-1, Tag.PixelData); } else { in.setIncludeBulkDataLocator(true); attrs = in.readDataset(-1, -1); } } finally { SafeClose.close(in); } attrs.addAll((Attributes) inst.getObject()); adjustPatientID(attrs); adjustAccessionNumber(attrs); ArchiveApplicationEntity ae = (ArchiveApplicationEntity) as.getApplicationEntity(); try { Templates tpl = ae.getAttributeCoercionTemplates( inst.cuid, Dimse.C_STORE_RQ, Role.SCU, as.getRemoteAET()); if (tpl != null) attrs.update(SAXTransformer.transform(attrs, tpl, false, false), null); } catch (Exception e) { throw new IOException(e); } return new DataWriterAdapter(attrs); }
private void process(ObjectMessage msg) throws JMSException { String remoteAET = msg.getStringProperty("RemoteAET"); String localAET = msg.getStringProperty("LocalAET"); String iuid = msg.getStringProperty("SOPInstancesUID"); boolean ncreate = msg.getBooleanProperty("N_CREATE_RQ"); int retries = msg.getIntProperty("Retries"); Attributes rqAttrs = (Attributes) msg.getObject(); ArchiveApplicationEntity localAE = (ArchiveApplicationEntity) device.getApplicationEntity(localAET); if (localAE == null) { LOG.warn("Failed to forward MPPS to {} - no such local AE: {}", remoteAET, localAET); return; } TransferCapability tc = localAE.getTransferCapabilityFor( UID.ModalityPerformedProcedureStepSOPClass, TransferCapability.Role.SCU); if (tc == null) { LOG.warn( "Failed to forward MPPS to {} - local AE: {} does not support Modality Performed Procedure Step SOP Class in SCU Role", remoteAET, localAET); return; } AAssociateRQ aarq = new AAssociateRQ(); aarq.addPresentationContext( new PresentationContext( 1, UID.ModalityPerformedProcedureStepSOPClass, tc.getTransferSyntaxes())); try { ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET); Association as = localAE.connect(remoteAE, aarq); DimseRSP rsp = ncreate ? as.ncreate(UID.ModalityPerformedProcedureStepSOPClass, iuid, rqAttrs, null) : as.nset(UID.ModalityPerformedProcedureStepSOPClass, iuid, rqAttrs, null); rsp.next(); try { as.release(); } catch (IOException e) { LOG.info("{}: Failed to release association to {}", as, remoteAET); } if (!ncreate && rsp.getCommand().getInt(Tag.Status, -1) == Status.NoSuchObjectInstance) { throw new DicomServiceException(Status.NoSuchObjectInstance); } } catch (Exception e) { if (retries < localAE.getForwardMPPSMaxRetries()) { int delay = localAE.getForwardMPPSRetryInterval(); LOG.info("Failed to forward MPPS to " + remoteAET + " - retry in " + delay + "s", e); scheduleForwardMPPS(localAET, remoteAET, iuid, rqAttrs, ncreate, retries + 1, delay); } else { LOG.warn("Failed to forward MPPS to " + remoteAET, e); } } }
private void process(ObjectMessage msg) throws JMSException { String remoteAET = msg.getStringProperty("RemoteAET"); String localAET = msg.getStringProperty("LocalAET"); int retries = msg.getIntProperty("Retries"); Attributes ian = (Attributes) msg.getObject(); ArchiveApplicationEntity localAE = (ArchiveApplicationEntity) device.getApplicationEntity(localAET); if (localAE == null) { LOG.warn("Failed to send IAN to {} - no such local AE: {}", remoteAET, localAET); return; } TransferCapability tc = localAE.getTransferCapabilityFor( UID.InstanceAvailabilityNotificationSOPClass, TransferCapability.Role.SCU); if (tc == null) { LOG.warn( "Failed to send IAN to {} - local AE: {} does not support Instance Availability Notification SOP Class in SCU Role", remoteAET, localAET); return; } AAssociateRQ aarq = new AAssociateRQ(); aarq.addPresentationContext( new PresentationContext( 1, UID.InstanceAvailabilityNotificationSOPClass, tc.getTransferSyntaxes())); try { ApplicationEntity remoteAE = aeCache.findApplicationEntity(remoteAET); Association as = localAE.connect(remoteAE, aarq); DimseRSP rsp = as.ncreate(UID.InstanceAvailabilityNotificationSOPClass, UIDUtils.createUID(), ian, null); rsp.next(); try { as.release(); } catch (IOException e) { LOG.info("{}: Failed to release association to {}", as, remoteAET); } } catch (Exception e) { if (retries < localAE.getIANMaxRetries()) { int delay = localAE.getIANRetryInterval(); LOG.info("Failed to send IAN to " + remoteAET + " - retry in " + delay + "s", e); scheduleIAN(localAET, remoteAET, ian, retries + 1, delay); } else { LOG.warn("Failed to send IAN to " + remoteAET, e); } } }