/**
  * Update the CommInfo to the database.
  *
  * @param commInfo The CommInfo to update.
  */
 static void updateCommInfo(CommInfo commInfo) throws Throwable {
   try {
     ServiceLookupHelper.getChannelManager().updateCommInfo(commInfo);
   } catch (Throwable t) {
     Logger.warn("[DelegateHelper.updateCommInfo] Error ", t);
     throw new Exception("Unable to update CommInfo");
   }
 }
  /**
   * Update the ConnectionStatus to the database.
   *
   * @param connStatus The ConnectionStatus to update.
   */
  static ConnectionStatus updateConnectionStatus(ConnectionStatus connStatus) throws Throwable {
    try {
      ServiceLookupHelper.getGridNodeManager().updateConnectionStatus(connStatus);

      return getConnectionStatus(connStatus.getGridNodeID());
    } catch (Throwable t) {
      Logger.warn("[DelegateHelper.updateConnectionStatus] Error ", t);
      throw new Exception("Unable to update Connection Status");
    }
  }
  /**
   * Retrieve the ConnectionStatus for a particular GridNode.
   *
   * @param nodeID The GridNodeID of the GridNode.
   * @return The ConnectionStatus retrieved.
   * @throws Exception No such GridNode.
   */
  static ConnectionStatus getConnectionStatus(String nodeID) throws Throwable {
    ConnectionStatus connStatus = null;

    try {
      connStatus = ServiceLookupHelper.getGridNodeManager().findConnectionStatusByNodeID(nodeID);
    } catch (Throwable t) {
      Logger.warn("[DelegateHelper.getConnectionStatus] Error ", t);
      throw new Exception("Unable to retrieve Connection Status");
    }
    return connStatus;
  }
 /** Update the ChannelInfo and its related profiles to the database. */
 static void updateChannel(ChannelInfo channel) throws Throwable {
   try {
     IChannelManagerObj mgr = ServiceLookupHelper.getChannelManager();
     mgr.updateChannelInfo(channel);
     mgr.updateCommInfo(channel.getTptCommInfo());
     mgr.updatePackagingInfo(channel.getPackagingProfile());
     mgr.updateSecurityInfo(channel.getSecurityProfile());
   } catch (Throwable t) {
     Logger.warn("[DelegateHelper.updateChannel] Error ", t);
     throw new Exception("Unable to update Channel related information");
   }
 }
 /**
  * Disconnect from the specified Jms router.
  *
  * @param commInfo the CommInfo indicating the Jms router to disconnect from.
  */
 static void disconnect(CommInfo commInfo) {
   try {
     if (getProperties().getIsTest()) {
       Logger.log("[DelegateHelper.disconnect] Testing only. No real disconnect initiated");
     } else {
       // disconnect, should not throw exception
       ServiceLookupHelper.getChannelManager().disconnect(commInfo);
     }
   } catch (Throwable t) {
     Logger.warn("[DelegateHelper.disconnect] Error disconnecting.. ", t);
   }
 }
  /**
   * Retrieve the master channel with a particular reference id.
   *
   * @param refID The referenceID.
   * @return The channel retrieved, or <b>null</b> if no such channel found.
   */
  static ChannelInfo retrieveMasterChannel(String refID) throws Throwable {
    Collection results = null;
    try {
      DataFilterImpl filter = new DataFilterImpl();
      filter.addSingleFilter(
          null, ChannelInfo.IS_MASTER, filter.getEqualOperator(), Boolean.TRUE, false);
      filter.addSingleFilter(
          filter.getAndConnector(), ChannelInfo.REF_ID, filter.getEqualOperator(), refID, false);

      results = ServiceLookupHelper.getChannelManager().getChannelInfo(filter);
    } catch (Throwable t) {
      Logger.warn("[ConnectDelegate.retrieveMasterChannel] Error ", t);
      throw new Exception("Error retrieving Master Channel for RefID: " + refID);
    }

    return (results.isEmpty() ? null : (ChannelInfo) results.toArray()[0]);
  }