Esempio n. 1
0
  private int store(String aet, String cuid, DicomObject dataset)
      throws IOException, InterruptedException, GeneralSecurityException {
    if (cuid == null) {
      cuid = dataset.getString(Tag.SOPClassUID);
    }

    setTransferCapability(
        new TransferCapability[] {
          new TransferCapability(cuid, NATIVE_LE_TS, TransferCapability.SCU)
        });
    Association assoc = open(aet);
    TransferCapability tc = assoc.getTransferCapabilityAsSCU(cuid);
    if (tc == null) {
      throw new NoPresentationContextException(
          UIDDictionary.getDictionary().prompt(UID.KeyObjectSelectionDocumentStorage));
    }
    String tsuid = tc.getTransferSyntax()[0];
    LOG.debug("Send C-STORE request to {}:\n{}", aet, dataset);
    RspHandler rspHandler = new RspHandler();
    assoc.cstore(
        cuid,
        dataset.getString(Tag.SOPInstanceUID),
        priority,
        new DataWriterAdapter(dataset),
        tsuid,
        rspHandler);
    assoc.waitForDimseRSP();
    try {
      assoc.release(true);
    } catch (InterruptedException t) {
      LOG.error("Failed to release association! aet:" + aet, t);
    }
    return rspHandler.getStatus();
  }
Esempio n. 2
0
 private File getDir(Association as) {
   File dir = cache.getCacheRootDir();
   if (called2dir != null) {
     dir = new File(dir, called2dir.getProperty(as.getCalledAET(), calleddefdir));
   }
   if (calling2dir != null) {
     dir = new File(dir, calling2dir.getProperty(as.getCallingAET(), callingdefdir));
   }
   return dir;
 }
Esempio n. 3
0
 private NetworkApplicationEntity mkStgCmtAE(Association as) {
   NetworkApplicationEntity stgcmtAE = new NetworkApplicationEntity();
   NetworkConnection stgcmtNC = new NetworkConnection();
   stgcmtNC.setHostname(as.getSocket().getInetAddress().getHostAddress());
   stgcmtNC.setPort(stgcmtPort);
   stgcmtNC.setTlsCipherSuite(nc.getTlsCipherSuite());
   stgcmtAE.setNetworkConnection(stgcmtNC);
   stgcmtAE.setAETitle(as.getRemoteAET());
   stgcmtAE.setTransferCapability(
       new TransferCapability[] {
         new TransferCapability(
             UID.StorageCommitmentPushModelSOPClass, ONLY_DEF_TS, TransferCapability.SCU)
       });
   return stgcmtAE;
 }
Esempio n. 4
0
 void sendStgCmtResult(NetworkApplicationEntity stgcmtAE, DicomObject result) throws Exception {
   synchronized (ae) {
     ae.setReuseAssocationFromAETitle(
         stgcmtReuseFrom ? new String[] {stgcmtAE.getAETitle()} : new String[] {});
     ae.setReuseAssocationToAETitle(
         stgcmtReuseTo ? new String[] {stgcmtAE.getAETitle()} : new String[] {});
     Association as = ae.connect(stgcmtAE, executor);
     as.nevent(
         UID.StorageCommitmentPushModelSOPClass,
         UID.StorageCommitmentPushModelSOPInstance,
         eventTypeIdOf(result),
         result,
         UID.ImplicitVRLittleEndian,
         nEventReportRspHandler);
     if (!stgcmtReuseFrom && !stgcmtReuseTo) {
       as.release(true);
     }
   }
 }
Esempio n. 5
0
    @Override
    public void onDimseRSP(Association as, DicomObject cmd, DicomObject data) {
      int status = cmd.getInt(Tag.Status);

      switch (status) {
        case 0x0000:
        case 0x0001:
        case 0x0002:
        case 0x0003:
          break;
        case 0x0116:
          LOG.warn(
              "Received Warning Status 116H (=Attribute Value Out of Range) from remote AE {}",
              as.getCalledAET());
          break;
        default:
          LOG.error(
              "Sending IAN(SCN) failed with status {}H at calledAET:{}",
              StringUtils.shortToHex(status),
              as.getCalledAET());
      }
    }
Esempio n. 6
0
 @Override
 public void onDimseRSP(Association as, DicomObject cmd, DicomObject data) {
   int status = cmd.getInt(Tag.Status);
   switch (status) {
     case 0:
       {
         LOG.debug("Dataset stored at {}", as.getCalledAET());
         break;
       }
     case 0xA700:
       {
         LOG.error(
             "Failed to store dataset - Out Of Resources! (status: {}H, calledAET:{}, comment:{})",
             new Object[] {
               StringUtils.shortToHex(status), as.getCalledAET(), cmd.getString(Tag.ErrorComment)
             });
         break;
       }
     case 0xA900:
       {
         LOG.error(
             "Failed to store dataset - Dataset doesn't match SOP class! (status: {}H, calledAET:{}, comment:{})",
             new Object[] {
               StringUtils.shortToHex(status), as.getCalledAET(), cmd.getString(Tag.ErrorComment)
             });
         break;
       }
     case 0xC000:
       {
         LOG.error(
             "Failed to store dataset - Can't understand! (status: {}H, calledAET:{}, comment:{})",
             new Object[] {
               StringUtils.shortToHex(status), as.getCalledAET(), cmd.getString(Tag.ErrorComment)
             });
         break;
       }
     case 0xB000:
     case 0xB006:
     case 0xB007:
       LOG.warn(
           "Dataset stored at {} with status {}H",
           as.getCalledAET(),
           StringUtils.shortToHex(status));
       break;
     default:
       LOG.error(
           "Failed to store dataset! (status: {}H, calledAET:{}, comment:{})",
           new Object[] {
             StringUtils.shortToHex(status), as.getCalledAET(), cmd.getString(Tag.ErrorComment)
           });
   }
 }
Esempio n. 7
0
 private int sendIAN(String aet, DicomObject ian)
     throws IOException, InterruptedException, GeneralSecurityException {
   String iuid = UIDUtils.createUID();
   Association assoc = open(aet);
   TransferCapability tc =
       assoc.getTransferCapabilityAsSCU(UID.InstanceAvailabilityNotificationSOPClass);
   RspHandler rspHandler = new RspHandler();
   if (tc == null) {
     tc = assoc.getTransferCapabilityAsSCU(UID.BasicStudyContentNotificationSOPClassRetired);
     if (tc == null) {
       throw new NoPresentationContextException(
           UIDDictionary.getDictionary()
               .prompt(
                   isOfferStudyContentNotification()
                       ? UID.BasicStudyContentNotificationSOPClassRetired
                       : UID.InstanceAvailabilityNotificationSOPClass));
     }
     String tsuid = tc.getTransferSyntax()[0];
     DicomObject scn = toSCN(ian);
     scn.putString(Tag.SOPInstanceUID, VR.UI, iuid);
     scn.putString(Tag.SOPClassUID, VR.UI, UID.BasicStudyContentNotificationSOPClassRetired);
     LOG.debug("Study Content Notification to {}:\n{}", aet, scn);
     assoc.cstore(
         UID.BasicStudyContentNotificationSOPClassRetired,
         iuid,
         priority,
         new DataWriterAdapter(scn),
         tsuid,
         rspHandler);
   } else {
     String tsuid = tc.getTransferSyntax()[0];
     LOG.debug("Instance Availability Notification to {}:\n{}", aet, ian);
     assoc.ncreate(UID.InstanceAvailabilityNotificationSOPClass, iuid, ian, tsuid, rspHandler);
   }
   assoc.waitForDimseRSP();
   try {
     assoc.release(true);
   } catch (InterruptedException t) {
     LOG.error("Association release failed! aet:" + aet, t);
   }
   return rspHandler.getStatus();
 }
  public void testRetrieveInputObjectsFromObjectStore() {
    String[] DEF_TS = {UID.ImplicitVRLittleEndian, UID.ExplicitVRLittleEndian};

    PlanArchiveSim pas = new PlanArchiveSim("PAS", "localhost", 40406);
    try {
      pas.start();
    } catch (IOException e1) {
      e1.printStackTrace();
      assertTrue(false);
    }

    PlanHolderSim phs = new PlanHolderSim("PHS", "localhost", 40407);
    try {
      phs.start();
    } catch (IOException e1) {
      e1.printStackTrace();
      assertTrue(false);
    }

    String name = "TestSCUCMovePlan";
    Device device = new Device(name);

    Executor executor = new NewThreadExecutor(name);
    NetworkApplicationEntity ae = new NetworkApplicationEntity();
    NetworkConnection localConn = new NetworkConnection();

    device.setNetworkApplicationEntity(ae);
    device.setNetworkConnection(localConn);

    ae.setNetworkConnection(localConn);
    ae.setAssociationInitiator(true);
    ae.setAssociationAcceptor(false);
    ae.setAETitle(name);
    ae.setTransferCapability(
        new TransferCapability[] {
          new TransferCapability(
              UID.StudyRootQueryRetrieveInformationModelMOVE, DEF_TS, TransferCapability.SCU)
        });

    NetworkApplicationEntity remoteAE = new NetworkApplicationEntity();
    NetworkConnection remoteConn = new NetworkConnection();

    remoteAE.setInstalled(true);
    remoteAE.setAssociationAcceptor(true);
    remoteConn.setHostname("localhost");
    remoteConn.setPort(40406);
    remoteAE.setNetworkConnection(remoteConn);
    remoteAE.setAETitle("PAS");

    // **
    // start Cmove Association
    // **
    String abstractSyntaxUID = UID.StudyRootQueryRetrieveInformationModelMOVE;
    DicomObject attrs = setCmoveAttributes();
    String transferSyntaxUid = UID.ImplicitVRLittleEndian;
    DimseRSP rsp = null;
    String movedUID = "";

    Association assoc = null;
    try {
      assoc = ae.connect(remoteAE, executor);
    } catch (ConfigurationException e) {
      assertTrue(false);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(false);
    } catch (InterruptedException e) {
      assertTrue(false);
    }
    movedUID = phs.getPlanUID();
    assertTrue(movedUID.equalsIgnoreCase("empty"));
    try {
      rsp = assoc.cmove(abstractSyntaxUID, 0, attrs, transferSyntaxUid, "PHS");
      while (!rsp.next()) {}
    } catch (IOException e) {
      System.out.println(e.getMessage());
      assertTrue(false);
    } catch (InterruptedException e) {
      System.out.println(e.getMessage());
      assertTrue(false);
    }
    movedUID = phs.getPlanUID();

    assertTrue(movedUID.equalsIgnoreCase("1.2.34.56"));
    phs.stop();
    pas.stop();
  }