mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
22.12.2014 ef384e41122d87682404ecbc1e0ff95d1a3a4402
OPENDJ-1548 (CR-4579) In changelog backend, persistent searches should perform the same validations as normal searches

Added validation for changes only persistent searches inside ChangelogBackend.registerPersistentSearches().
For cookie based searches, cookie is now stored on the CookieEntrySender object rather than as a search operation attachment. This makes code easier to read and understand.


Backend.java
In registerPersistentSearch(), now throws DirectoryException.

LocalBackendSearchOperation.java:
Consequence of the change to Backend.registerPersistentSearch().

ChangelogBackend.java:
Added validatePersistentSearch() + called it from registerPersistentSearch().
Added cookie field and setCookie() to CookieEntrySender + removed COOKIE_ATTACHMENT constant + changed code that was using it + no longer pass cookie down method calls
Renamed initializeAttachements() to initializeEntrySender() + fixed a bug with the starting phase.
2 files modified
51 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/api/Backend.java 4 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java 47 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -912,8 +912,10 @@
   *
   * @param persistentSearch
   *          The persistent search operation to register with this backend
   * @throws DirectoryException
   *           If a problem occurs while registering the persistent search
   */
  public void registerPersistentSearch(PersistentSearch persistentSearch)
  public void registerPersistentSearch(PersistentSearch persistentSearch) throws DirectoryException
  {
    persistentSearches.add(persistentSearch);
opendj3-server-dev/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
@@ -219,34 +219,33 @@
    // will be overwritten.
    setResultCode(ResultCode.SUCCESS);
    // If there's a persistent search, then register it with the server.
    boolean processSearchNow = true;
    if (persistentSearch != null)
    {
      // If we're only interested in changes, then we do not actually want
      // to process the search now.
      processSearchNow = !persistentSearch.isChangesOnly();
      // The Core server maintains the count of concurrent persistent searches
      // so that all the backends (Remote and Local) are aware of it. Verify
      // with the core if we have already reached the threshold.
      if (!DirectoryServer.allowNewPersistentSearch())
      {
        setResultCode(ResultCode.ADMIN_LIMIT_EXCEEDED);
        appendErrorMessage(ERR_MAX_PSEARCH_LIMIT_EXCEEDED.get());
        return;
      }
      backend.registerPersistentSearch(persistentSearch);
      persistentSearch.enable();
    }
    // Process the search in the backend and all its subordinates.
    try
    {
      // If there's a persistent search, then register it with the server.
      boolean processSearchNow = true;
      if (persistentSearch != null)
      {
        // If we're only interested in changes, then we do not actually want
        // to process the search now.
        processSearchNow = !persistentSearch.isChangesOnly();
        // The Core server maintains the count of concurrent persistent searches
        // so that all the backends (Remote and Local) are aware of it. Verify
        // with the core if we have already reached the threshold.
        if (!DirectoryServer.allowNewPersistentSearch())
        {
          setResultCode(ResultCode.ADMIN_LIMIT_EXCEEDED);
          appendErrorMessage(ERR_MAX_PSEARCH_LIMIT_EXCEEDED.get());
          return;
        }
        backend.registerPersistentSearch(persistentSearch);
        persistentSearch.enable();
      }
      if (processSearchNow)
      {
        // Process the search in the backend and all its subordinates.
        backend.search(this);
      }
    }