Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.Backend


            }
            else
            {
              ref.clear();

              Backend backend = freedEntry.getBackend();
              ConcurrentHashMap<Long,SoftReference<CacheEntry>> map =
                   idMap.get(backend);
              if (map != null)
              {
                ref = map.remove(freedEntry.getEntryID());
View Full Code Here


    LinkedHashMap<LocalDBBackendCfg, BackendImpl> jeBackends =
        new LinkedHashMap<LocalDBBackendCfg, BackendImpl>();
    for(int i = 0; i < backendList.size(); i++)
    {
      Backend backend = backendList.get(i);
      if(backend instanceof BackendImpl)
      {
        jeBackends.put((LocalDBBackendCfg)entryList.get(i),
                       (BackendImpl)backend);
      }
View Full Code Here

      if (entry == null)
      {
        return;
      }

      Backend backend = entry.getBackend();

      // Try to remove the entry from the ID list as well.
      Map<Long,CacheEntry> map = idMap.get(backend);
      if (map == null)
      {
View Full Code Here

   */
  public void clearSubtree(DN baseDN)
  {
    // Determine which backend should be used for the provided base DN.  If
    // there is none, then we don't need to do anything.
    Backend backend = DirectoryServer.getBackend(baseDN);
    if (backend == null)
    {
      return;
    }

View Full Code Here

  {

    List<Message> errors = new LinkedList<Message>();

    // Check to see if the base DN is already registered with the server.
    Backend existingBackend = baseDNs.get(baseDN);
    if (existingBackend != null)
    {
      Message message = ERR_REGISTER_BASEDN_ALREADY_EXISTS.
          get(String.valueOf(baseDN), backend.getBackendID(),
              existingBackend.getBackendID());
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }


    // Check to see if the backend is already registered with the server for
    // any other base DN(s).  The new base DN must not have any hierarchical
    // relationship with any other base Dns for the same backend.
    LinkedList<DN> otherBaseDNs = new LinkedList<DN>();
    for (DN dn : baseDNs.keySet())
    {
      Backend b = baseDNs.get(dn);
      if (b.equals(backend))
      {
        otherBaseDNs.add(dn);

        if (baseDN.isAncestorOf(dn) || baseDN.isDescendantOf(dn))
        {
          Message message = ERR_REGISTER_BASEDN_HIERARCHY_CONFLICT.
              get(String.valueOf(baseDN), backend.getBackendID(),
                  String.valueOf(dn));
          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                       message);
        }
      }
    }


    // Check to see if the new base DN is subordinate to any other base DN
    // already defined.  If it is, then any other base DN(s) for the same
    // backend must also be subordinate to the same base DN.
    Backend superiorBackend = null;
    DN      superiorBaseDN        ;
    DN      parentDN        = baseDN.getParent();
    while (parentDN != null)
    {
      if (baseDNs.containsKey(parentDN))
      {
        superiorBaseDN  = parentDN;
        superiorBackend = baseDNs.get(parentDN);

        for (DN dn : otherBaseDNs)
        {
          if (! dn.isDescendantOf(superiorBaseDN))
          {
            Message message = ERR_REGISTER_BASEDN_DIFFERENT_PARENT_BASES.
                get(String.valueOf(baseDN), backend.getBackendID(),
                    String.valueOf(dn));
            throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                         message);
          }
        }

        break;
      }

      parentDN = parentDN.getParent();
    }

    if (superiorBackend == null)
    {
      if (backend.getParentBackend() != null)
      {
        Message message = ERR_REGISTER_BASEDN_NEW_BASE_NOT_SUBORDINATE.
            get(String.valueOf(baseDN), backend.getBackendID(),
                backend.getParentBackend().getBackendID());
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                     message);
      }
    }


    // Check to see if the new base DN should be the superior base DN for any
    // other base DN(s) already defined.
    LinkedList<Backend> subordinateBackends = new LinkedList<Backend>();
    LinkedList<DN>      subordinateBaseDNs  = new LinkedList<DN>();
    for (DN dn : baseDNs.keySet())
    {
      Backend b = baseDNs.get(dn);
      parentDN = dn.getParent();
      while (parentDN != null)
      {
        if (parentDN.equals(baseDN))
        {
          subordinateBaseDNs.add(dn);
          subordinateBackends.add(b);
          break;
        }
        else if (baseDNs.containsKey(parentDN))
        {
          break;
        }

        parentDN = parentDN.getParent();
      }
    }


    // If we've gotten here, then the new base DN is acceptable.  If we should
    // actually apply the changes then do so now.

    // Check to see if any of the registered backends already contain an
    // entry with the DN specified as the base DN.  This could happen if
    // we're creating a new subordinate backend in an existing directory
    // (e.g., moving the "ou=People,dc=example,dc=com" branch to its own
    // backend when that data already exists under the "dc=example,dc=com"
    // backend).  This condition shouldn't prevent the new base DN from
    // being registered, but it's definitely important enough that we let
    // the administrator know about it and remind them that the existing
    // backend will need to be reinitialized.
    if (superiorBackend != null)
    {
      if (superiorBackend.entryExists(baseDN))
      {
        Message message = WARN_REGISTER_BASEDN_ENTRIES_IN_MULTIPLE_BACKENDS.
            get(superiorBackend.getBackendID(), String.valueOf(baseDN),
                backend.getBackendID());
        errors.add(message);
      }
    }


    baseDNs.put(baseDN, backend);

    if (superiorBackend == null)
    {
      if (isPrivate)
      {
        if (!testOnly)
        {
          backend.setPrivateBackend(true);
        }
        privateNamingContexts.put(baseDN, backend);
      }
      else
      {
        if (!testOnly)
        {
          backend.setPrivateBackend(false);
        }
        publicNamingContexts.put(baseDN, backend);
      }
    }
    else if (otherBaseDNs.isEmpty())
    {
      if (!testOnly)
      {
        backend.setParentBackend(superiorBackend);
        superiorBackend.addSubordinateBackend(backend);
      }
    }

    if (!testOnly)
    {
      for (Backend b : subordinateBackends)
      {
        Backend oldParentBackend = b.getParentBackend();
        if (oldParentBackend != null)
        {
          oldParentBackend.removeSubordinateBackend(b);
        }

        b.setParentBackend(backend);
        backend.addSubordinateBackend(b);
      }
View Full Code Here

    ensureNotNull(baseDN);

    // Make sure that the Directory Server actually contains a backend with
    // the specified base DN.
    Backend backend = baseDNs.get(baseDN);
    if (backend == null)
    {
      Message message =
          ERR_DEREGISTER_BASEDN_NOT_REGISTERED.get(String.valueOf(baseDN));
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }


    // Check to see if the backend has a parent backend, and whether it has
    // any subordinates with base DNs that are below the base DN to remove.
    Backend             superiorBackend     = backend.getParentBackend();
    LinkedList<Backend> subordinateBackends = new LinkedList<Backend>();
    if (backend.getSubordinateBackends() != null)
    {
      for (Backend b : backend.getSubordinateBackends())
      {
        for (DN dn : b.getBaseDNs())
        {
          if (dn.isDescendantOf(baseDN))
          {
            subordinateBackends.add(b);
            break;
          }
        }
      }
    }


    // See if there are any other base DNs registered within the same backend.
    LinkedList<DN> otherBaseDNs = new LinkedList<DN>();
    for (DN dn : baseDNs.keySet())
    {
      if (dn.equals(baseDN))
      {
        continue;
      }

      Backend b = baseDNs.get(dn);
      if (backend.equals(b))
      {
        otherBaseDNs.add(dn);
      }
    }


    // If we've gotten here, then it's OK to make the changes.

    // Get rid of the references to this base DN in the mapping tree
    // information.
    baseDNs.remove(baseDN);
    publicNamingContexts.remove(baseDN);
    privateNamingContexts.remove(baseDN);

    if (superiorBackend == null)
    {
      // If there were any subordinate backends, then all of their base DNs
      // will now be promoted to naming contexts.
      for (Backend b : subordinateBackends)
      {
        if (!testOnly)
        {
          b.setParentBackend(null);
          backend.removeSubordinateBackend(b);
        }

        for (DN dn : b.getBaseDNs())
        {
          if (b.isPrivateBackend())
          {
            privateNamingContexts.put(dn, b);
          }
          else
          {
            publicNamingContexts.put(dn, b);
          }
        }
      }
    }
    else
    {
      // If there are no other base DNs for the associated backend, then
      // remove this backend as a subordinate of the parent backend.
      if (otherBaseDNs.isEmpty())
      {
        if (!testOnly)
        {
          superiorBackend.removeSubordinateBackend(backend);
        }
      }


      // If there are any subordinate backends, then they need to be made
      // subordinate to the parent backend.  Also, we should log a warning
      // message indicating that there may be inconsistent search results
      // because some of the structural entries will be missing.
      if (! subordinateBackends.isEmpty())
      {
        // Suppress this warning message on server shutdown.
        if (!DirectoryServer.getInstance().isShuttingDown()) {
          Message message = WARN_DEREGISTER_BASEDN_MISSING_HIERARCHY.get(
            String.valueOf(baseDN), backend.getBackendID());
          errors.add(message);
        }

        if (!testOnly)
        {
          for (Backend b : subordinateBackends)
          {
            backend.removeSubordinateBackend(b);
            superiorBackend.addSubordinateBackend(b);
            b.setParentBackend(superiorBackend);
          }
        }
      }
    }
    return errors;
View Full Code Here

   */
  @Override()
  public Set<AttributeValue> getValues(Entry entry,
                                       VirtualAttributeRule rule)
  {
    Backend backend = DirectoryServer.getBackend(entry.getDN());

    try
    {
      long count = backend.numSubordinates(entry.getDN(), false);
      if(count >= 0)
      {
        AttributeValue value =
            AttributeValues.create(ByteString.valueOf(String.valueOf(count)),
                ByteString.valueOf(String.valueOf(count)));
View Full Code Here

   * {@inheritDoc}
   */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule)
  {
    Backend backend = DirectoryServer.getBackend(entry.getDN());

    try
    {
       return backend.numSubordinates(entry.getDN(), false) >= 0;
    }
    catch(DirectoryException de)
    {
      if (debugEnabled())
      {
View Full Code Here

   */
  @Override()
  public boolean hasValue(Entry entry, VirtualAttributeRule rule,
                          AttributeValue value)
  {
     Backend backend = DirectoryServer.getBackend(entry.getDN());

    try
    {
      long count = backend.numSubordinates(entry.getDN(), false);
      if(count >= 0)
      {
        return Long.parseLong(value.getNormalizedValue().toString())
            == count;
      }
View Full Code Here

                getExceptionMessage(e));
        logError(message);
        return 1;
      }

      Backend backend;
      BackendCfg cfg;
      try
      {
        backend = (Backend) backendClass.newInstance();
        backend.setBackendID(backendID);
        cfg = root.getBackend(backendID);
        backend.configureBackend(cfg);
      }
      catch (Exception e)
      {
        Message message = ERR_CANNOT_INSTANTIATE_BACKEND_CLASS.
            get(backendClassName, String.valueOf(configEntry.getDN()),
View Full Code Here

TOP

Related Classes of org.nasutekds.server.api.Backend

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.