Ejemplo n.º 1
0
 public Connection findCompatibelConnection(Connection remoteConn)
     throws IncompatibleConnectionException {
   for (Connection conn : connections)
     if (conn.isInstalled() && conn.isCompatible(remoteConn)) return conn;
   throw new IncompatibleConnectionException(
       "No compatible connection to " + remoteConn + " available on " + this);
 }
Ejemplo n.º 2
0
  public void addConnection(Connection conn) {
    if (conn.getProtocol() != Connection.Protocol.DICOM)
      throw new IllegalArgumentException("protocol != DICOM - " + conn.getProtocol());

    if (device != null && device != conn.getDevice())
      throw new IllegalStateException(conn + " not contained by Device: " + device.getDeviceName());
    connections.add(conn);
  }
Ejemplo n.º 3
0
 /**
  * Set the device that is identified by this application entity.
  *
  * @param device The owning <code>Device</code>.
  */
 public void setDevice(Device device) {
   if (device != null) {
     if (this.device != null && this.device != device)
       throw new IllegalStateException("already owned by " + this.device.getDeviceName());
     for (Connection conn : connections)
       if (conn.getDevice() != device)
         throw new IllegalStateException(conn + " not owned by " + device.getDeviceName());
   }
   this.device = device;
 }
Ejemplo n.º 4
0
 public StringBuilder promptTo(StringBuilder sb, String indent) {
   String indent2 = indent + "  ";
   StringUtils.appendLine(sb, indent, "ApplicationEntity[title: ", AETitle);
   StringUtils.appendLine(sb, indent2, "alias titles: ", AETitleAliases);
   StringUtils.appendLine(sb, indent2, "desc: ", description);
   StringUtils.appendLine(sb, indent2, "acceptor: ", associationAcceptor);
   StringUtils.appendLine(sb, indent2, "initiator: ", associationInitiator);
   StringUtils.appendLine(sb, indent2, "installed: ", getAeInstalled());
   for (Connection conn : connections)
     conn.promptTo(sb, indent2).append(StringUtils.LINE_SEPARATOR);
   for (TransferCapability tc : getTransferCapabilities())
     tc.promptTo(sb, indent2).append(StringUtils.LINE_SEPARATOR);
   return sb.append(indent).append(']');
 }
Ejemplo n.º 5
0
 public CompatibleConnection findCompatibelConnection(ApplicationEntity remote)
     throws IncompatibleConnectionException {
   CompatibleConnection cc = null;
   for (Connection remoteConn : remote.connections)
     if (remoteConn.isInstalled() && remoteConn.isServer())
       for (Connection conn : connections)
         if (conn.isInstalled() && conn.isCompatible(remoteConn)) {
           if (cc == null || conn.isTls() || conn.getProtocol() == Connection.Protocol.SYSLOG_TLS)
             cc = new CompatibleConnection(conn, remoteConn);
         }
   if (cc == null)
     throw new IncompatibleConnectionException(
         "No compatible connection to " + remote + " available on " + this);
   return cc;
 }
Ejemplo n.º 6
0
  public Association connect(Connection local, Connection remote, AAssociateRQ rq)
      throws IOException, InterruptedException, IncompatibleConnectionException,
          GeneralSecurityException {
    checkDevice();
    checkInstalled();
    if (rq.getCallingAET() == null) rq.setCallingAET(AETitle);
    rq.setMaxOpsInvoked(local.getMaxOpsInvoked());
    rq.setMaxOpsPerformed(local.getMaxOpsPerformed());
    rq.setMaxPDULength(local.getReceivePDULength());

    final Socket sock =
        local.connect(remote); // automatically closes the socket in case an exception is thrown

    Association as;
    try {
      as = new Association(this, local, sock);
    } catch (final IOException e) {
      LOG.warn("Failed to open new association, will close underlying socket");
      local.close(sock);
      throw e;
    }
    try {
      as.write(rq);
      as.waitForLeaving(State.Sta5);
    } catch (final IOException e) {
      LOG.warn("{}: Failed to write A-ASSOCIATE-RQ, will abort association", as.toString());
      as.abort();
      throw e;
    } catch (final InterruptedException e) {
      LOG.warn(
          "{}: Interrupted while waiting to leave state Sta 5, will abort association",
          as.toString());
      as.abort();
      throw e;
    }
    return as;
  }