Пример #1
0
  public void updateEntry(String name, EntryConfig entryConfig) throws Exception {

    log.debug(TextUtil.repeat("-", 70));

    Directory directory = getDirectory();
    List<Entry> children = null;

    if (directory != null) {
      try {
        Entry oldEntry = directory.removeEntry(entryConfig.getName());
        if (oldEntry != null) {
          children = oldEntry.getChildren();
          oldEntry.destroy();
        }
      } catch (Exception e) {
        log.error(e.getMessage(), e);
      }
    }

    removeEntryService(entryConfig.getName());

    DirectoryConfig directoryConfig = getDirectoryConfig();
    directoryConfig.updateEntryConfig(name, entryConfig);

    if (directory != null) {
      try {
        Entry newEntry = directory.createEntry(entryConfig);
        if (children != null) newEntry.addChildren(children);
      } catch (Exception e) {
        log.error(e.getMessage(), e);
      }
    }

    createEntryService(entryConfig.getName());
  }
Пример #2
0
  public void init() throws Exception {
    jmxService.register(getObjectName(), this);

    DirectoryConfig directoryConfig = getDirectoryConfig();

    for (String entryName : directoryConfig.getEntryNames()) {
      createEntryService(entryName);
    }
  }
Пример #3
0
  public void destroy() throws Exception {

    DirectoryConfig directoryConfig = getDirectoryConfig();

    for (String entryName : directoryConfig.getEntryNames()) {
      removeEntryService(entryName);
    }

    jmxService.unregister(getObjectName());
  }
  /**
   * Ensures that the Directory Server is running.
   *
   * @throws Exception If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer() throws Exception {
    TestCaseUtils.startServer();

    entryDNType = DirectoryConfig.getAttributeType("entrydn", false);
    assertNotNull(entryDNType);
  }
 /**
  * Tests the {@code appliesToEntry} method.
  *
  * @param rule The rule for which to perform the test.
  * @param appliesToEntry Indicates whether the provided rule applies to a minimal "o=test" entry.
  * @throws Exception If an unexpected problem occurs.
  */
 @Test(dataProvider = "testRules")
 public void testAppliesToEntry(VirtualAttributeRule rule, boolean appliesToEntry)
     throws Exception {
   TestCaseUtils.initializeTestBackend(true);
   addGroups();
   assertEquals(
       rule.appliesToEntry(DirectoryConfig.getEntry(DN.decode("o=test"))), appliesToEntry);
   removeGroups();
 }
Пример #6
0
  public void removeEntry(String entryName) throws Exception {

    log.debug(TextUtil.repeat("-", 70));

    Directory directory = getDirectory();
    if (directory != null) {
      try {
        directory.destroy(entryName);
      } catch (Exception e) {
        log.error(e.getMessage(), e);
      }
    }

    DirectoryConfig directoryConfig = getDirectoryConfig();
    directoryConfig.removeEntryConfig(entryName);

    removeEntryService(entryName);
  }
Пример #7
0
  public String createEntry(EntryConfig entryConfig) throws Exception {

    log.debug(TextUtil.repeat("-", 70));

    DirectoryConfig directoryConfig = getDirectoryConfig();
    directoryConfig.addEntryConfig(entryConfig);

    Directory directory = getDirectory();
    if (directory != null) {
      try {
        directory.createEntry(entryConfig);
      } catch (Exception e) {
        log.error(e.getMessage(), e);
      }
    }

    createEntryService(entryConfig.getName());

    return entryConfig.getName();
  }
Пример #8
0
 public void setChildNames(String entryName, List<String> childNames) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   directoryConfig.setChildNames(entryName, childNames);
 }
Пример #9
0
 public List<String> getChildNames(String entryName) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   return directoryConfig.getChildNames(entryName);
 }
Пример #10
0
 public String getParentName(String entryName) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   return directoryConfig.getParentName(entryName);
 }
Пример #11
0
 public Collection<String> getEntryNames() throws Exception {
   Collection<String> list = new ArrayList<String>();
   DirectoryConfig directoryConfig = getDirectoryConfig();
   list.addAll(directoryConfig.getEntryNames());
   return list;
 }
Пример #12
0
 public Collection<DN> getSuffixes() throws Exception {
   Collection<DN> list = new ArrayList<DN>();
   DirectoryConfig directoryConfig = getDirectoryConfig();
   list.addAll(directoryConfig.getSuffixes());
   return list;
 }
Пример #13
0
 public DN getSuffix() throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   return directoryConfig.getSuffix();
 }
Пример #14
0
 public EntryConfig getEntryConfig(String entryName) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   return directoryConfig.getEntryConfig(entryName);
 }
Пример #15
0
 public DN getEntryDn(String entryName) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   EntryConfig entryConfig = directoryConfig.getEntryConfig(entryName);
   if (entryConfig == null) return null;
   return entryConfig.getDn();
 }
Пример #16
0
 public String getEntryName(DN dn) throws Exception {
   DirectoryConfig directoryConfig = getDirectoryConfig();
   return directoryConfig.getEntryNameByDn(dn);
 }