Ejemplo n.º 1
0
 /**
  * removes the listener from the list of Persistent Search listeners of the asynchronous seach for
  * the given search ID.
  *
  * @param request The request returned by the addListener
  * @supported.api
  */
 protected void removeListener(Request request) {
   LDAPConnection connection = request.getLDAPConnection();
   if (connection != null) {
     if (debugger.messageEnabled()) {
       debugger.message(
           "EventService.removeListener(): Removing "
               + "listener requestID: "
               + request.getRequestID()
               + " Listener: "
               + request.getListener());
     }
     try {
       if ((connection != null) && (connection.isConnected())) {
         connection.abandon(request.getId());
         connection.disconnect();
       }
     } catch (LDAPException le) {
       // Might have to check the reset codes and try to reset
       if (debugger.warningEnabled()) {
         debugger.warning(
             "EventService.removeListener(): " + "LDAPException, when trying to remove listener",
             le);
       }
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Response message carries a LDAP error. Response with the code 0 (SUCCESS), should never be
  * received as persistent search never completes, it has to be abandon. Referral messages are
  * ignored
  */
 protected boolean processResponseMessage(LDAPResponse rsp, Request request) {
   _retryErrorCodes = getPropertyRetryErrorCodes(EVENT_CONNECTION_ERROR_CODES);
   int resultCode = rsp.getResultCode();
   if (_retryErrorCodes.contains("" + resultCode)) {
     if (debugger.messageEnabled()) {
       debugger.message(
           "EventService.processResponseMessage() - "
               + "received LDAP Response for requestID: "
               + request.getRequestID()
               + " Listener: "
               + request.getListener()
               + "Need restarting");
     }
     resetErrorSearches(false);
   } else if (resultCode != 0 || resultCode != LDAPException.REFERRAL) {
     // If not neither of the cases then
     if (resultCode == LDAPException.BUSY) {
       debugger.error(
           "EventService.processResponseMessage() - received error BUSY, call retryManager");
       return retryManager(false);
     }
     LDAPException ex =
         new LDAPException(
             "Error result", rsp.getResultCode(), rsp.getErrorMessage(), rsp.getMatchedDN());
     dispatchException(ex, request);
   }
   return true;
 }
Ejemplo n.º 3
0
  /** Create naming event from a change control */
  private DSEvent createDSEvent(LDAPEntry entry, LDAPEntryChangeControl changeCtrl, Request req)
      throws Exception {
    DSEvent dsEvent = new DSEvent();

    if (debugger.messageEnabled()) {
      debugger.message(
          "EventService.createDSEvent() - Notifying event " + "to: " + req.getListener());
    }

    // Get the dn from the entry
    String dn = entry.getDN();
    dsEvent.setID(dn);

    // Get information on the type of change made
    int changeType = changeCtrl.getChangeType();
    dsEvent.setEventType(changeType);

    // Pass the search ID as the event's change info
    dsEvent.setSearchID(req.getRequestID());

    // set the object class name
    String className = entry.getAttribute("objectclass").toString();
    dsEvent.setClassName(className);

    return dsEvent;
  }
Ejemplo n.º 4
0
 private void dispatchException(Exception e, Request request) {
   IDSEventListener el = request.getListener();
   debugger.error(
       "EventService.dispatchException() - dispatching "
           + "exception to the listener: "
           + request.getRequestID()
           + " Listener: "
           + request.getListener(),
       e);
   el.eventError(e.toString());
 }
Ejemplo n.º 5
0
  /**
   * Reset error searches. Clear cache only if true is passed to argument
   *
   * @param clearCaches
   */
  protected void resetErrorSearches(boolean clearCaches) {

    Hashtable tmpReqList = new Hashtable();
    tmpReqList.putAll(_requestList);

    int[] ids = _msgQueue.getMessageIDs();
    if (ids != null) {
      for (int i = 0; i < ids.length; i++) {
        String reqID = Integer.toString(ids[i]);
        tmpReqList.remove(reqID);
      }
    }
    Collection reqList = tmpReqList.values();
    for (Iterator iter = reqList.iterator(); iter.hasNext(); ) {
      Request req = (Request) iter.next();
      _requestList.remove(req.getRequestID());
    }
    _retryInterval = getPropertyIntValue(EVENT_CONNECTION_RETRY_INTERVAL, _retryInterval);
    RetryTask task = new RetryTask(tmpReqList);
    task.clearCache(clearCaches);
    SystemTimer.getTimer()
        .schedule(task, new Date(((System.currentTimeMillis() + _retryInterval) / 1000) * 1000));
  }