Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.Backend


    ArrayList<Message> messages            = new ArrayList<Message>();


    // See if this backend config manager has a backend registered with the
    // provided DN.  If not, then we don't care if the entry is deleted.
    Backend backend = registeredBackends.get(backendDN);
    if (backend == null)
    {
      return new ConfigChangeResult(resultCode, adminActionRequired,
                                    messages);
    }


    // See if the backend has any subordinate backends.  If so, then it is not
    // acceptable to remove it.  Otherwise, it should be fine.
    Backend[] subBackends = backend.getSubordinateBackends();
    if ((subBackends == null) || (subBackends.length == 0))
    {
      registeredBackends.remove(backendDN);

      try
      {
        backend.finalizeBackend();
      }
      catch (Exception e)
      {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }

      for (BackendInitializationListener listener :
           DirectoryServer.getBackendInitializationListeners())
      {
        listener.performBackendFinalizationProcessing(backend);
      }

      DirectoryServer.deregisterBackend(backend);
      configEntry.removeChangeListener(this);

      // Remove the shared lock for this backend.
      try
      {
        String lockFile = LockFileManager.getBackendLockFileName(backend);
        StringBuilder failureReason = new StringBuilder();
        if (! LockFileManager.releaseLock(lockFile, failureReason))
        {
          Message message = WARN_CONFIG_BACKEND_CANNOT_RELEASE_SHARED_LOCK.get(
              backend.getBackendID(), String.valueOf(failureReason));
          logError(message);
          // FIXME -- Do we need to send an admin alert?
        }
      }
      catch (Exception e2)
      {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e2);
        }

        Message message = WARN_CONFIG_BACKEND_CANNOT_RELEASE_SHARED_LOCK.get(
            backend.getBackendID(), stackTraceToSingleLineString(e2));
        logError(message);
        // FIXME -- Do we need to send an admin alert?
      }

      return new ConfigChangeResult(resultCode, adminActionRequired,
View Full Code Here


         "userPassword: password");

    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();

    Backend b = DirectoryServer.getBackend(DN.decode("o=test"));
    b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);

    AddOperation addOperation =
         conn.processAdd(entry.getDN(), entry.getObjectClasses(),
                         entry.getUserAttributes(),
                         entry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    retrieveCompletedOperationElements(addOperation);

    b.setWritabilityMode(WritabilityMode.ENABLED);
  }
View Full Code Here

    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("People"));
    attrs.add(new LDAPAttribute("ou", values));

    Backend b = DirectoryServer.getBackend(DN.decode("o=test"));
    b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY);

    long addRequests  = ldapStatistics.getAddRequests();
    long addResponses = ldapStatistics.getAddResponses();

    AddRequestProtocolOp addRequest =
         new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"),
                                  attrs);
    message = new LDAPMessage(2, addRequest);
    w.writeMessage(message);

    message = r.readMessage();
    AddResponseProtocolOp addResponse =
         message.getAddResponseProtocolOp();
    assertFalse(addResponse.getResultCode() == 0);

    assertEquals(ldapStatistics.getAddRequests(), addRequests+1);
    waitForAddResponsesStat(addResponses+1);

    try
    {
      s.close();
    } catch (Exception e) {}

    b.setWritabilityMode(WritabilityMode.ENABLED);
  }
View Full Code Here

   */
  @Test()
  public void testHasSubordinates()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);

    assertEquals(b.hasSubordinates(DN.decode("o=ldif")), ConditionResult.TRUE);
    assertEquals(b.hasSubordinates(DN.decode("uid=user.1,ou=People,o=ldif")),
                 ConditionResult.FALSE);

    try
    {
      b.hasSubordinates(DN.decode("ou=nonexistent,o=ldif"));
      fail("Expected an exception when calling hasSubordinates on a " +
           "non-existent entry");
    }
    catch (DirectoryException de)
    {
View Full Code Here

   */
  @Test()
  public void testNumSubordinates()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);

    assertEquals(b.numSubordinates(DN.decode("o=ldif"), false), 1);
    assertEquals(b.numSubordinates(DN.decode("o=ldif"), true), 26);
    assertEquals(b.numSubordinates(
        DN.decode("uid=user.1,ou=People,o=ldif"), false), 0);
    assertEquals(b.numSubordinates(
        DN.decode("uid=user.1,ou=People,o=ldif"), true), 0);

    try
    {
      b.numSubordinates(DN.decode("ou=nonexistent,o=ldif"), false);
      fail("Expected an exception when calling numSubordinates on a " +
           "non-existent entry");
    }
    catch (DirectoryException de)
    {
View Full Code Here

   */
  @Test()
  public void testLDIFExport()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);
    assertTrue(b.supportsLDIFExport());

    String tempFilePath = TestCaseUtils.createTempFile();

    String taskDN = "ds-task-id=" + UUID.randomUUID() +
                    ",cn=Scheduled Tasks,cn=Tasks";
View Full Code Here

   */
  @Test()
  public void testMiscellaneousBackendMethods()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);

    assertTrue(b.getEntryCount() > 0);

    assertTrue(b.isLocal());

    assertFalse(b.supportsBackup());
    assertFalse(b.supportsBackup(null, null));

    try
    {
      b.createBackup(null);
      fail("Expected an exception when calling createBackup");
    } catch (DirectoryException de) {}

    try
    {
      b.removeBackup(null, null);
      fail("Expected an exception when calling removeBackup");
    } catch (DirectoryException de) {}

    assertFalse(b.supportsRestore());

    try
    {
      b.restoreBackup(null);
      fail("Expected an exception when calling restoreBackup");
    } catch (DirectoryException de) {}

    LDIFBackend ldifBackend = (LDIFBackend) b;
    assertNotNull(ldifBackend.getClassName());
View Full Code Here

{

  // Some of the tests disable the backends, so we reenable them here.
  @AfterMethod(alwaysRun=true)
  public void reenableBackend() throws DirectoryException {
    Backend b = DirectoryServer.getBackend(DN.decode("o=test"));
    b.setWritabilityMode(WritabilityMode.ENABLED);
  }
View Full Code Here

         "userPassword: password");

    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();

    Backend b = DirectoryServer.getBackend(DN.decode("o=test"));
    b.setWritabilityMode(WritabilityMode.DISABLED);

    AddOperation addOperation =
         conn.processAdd(entry.getDN(), entry.getObjectClasses(),
                         entry.getUserAttributes(),
                         entry.getOperationalAttributes());
    assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS);

    b.setWritabilityMode(WritabilityMode.ENABLED);
  }
View Full Code Here

    assertNull(toVerboseString(),
      "Expected empty cache.  " + "Cache contents:" + ServerConstants.EOL +
      toVerboseString());

    TestCaseUtils.initializeTestBackend(false);
    Backend b = DirectoryServer.getBackend(DN.decode("o=test"));

    // Spread test entries among all cache levels via default cache.
    for (int i = 0; i < NUMTESTENTRIES; i++) {
      super.cache.putEntry(testSoftRefEntriesList.get(i), b, i);
      super.cache.putEntry(testFIFOEntriesList.get(i), b, i);
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.