You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by "Louie, Kenneth W" <ke...@lmco.com> on 2014/02/11 20:16:55 UTC

[ApacheDS] trying to create a partition programmatically

Hey All,

I'm trying to create a partition programatically. I've tried following the example on the ApacheDS website (https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically) , but this example is definitely not correct.

Here is my code:

try {
      LdapConnection connection = new LdapNetworkConnection(host, port);
      connection.bind(admin, password);

      log.info("Loading Schema...");
      connection.loadSchema();
      SchemaManager schemaManager = connection.getSchemaManager();
      Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");

      log.info("Start to create partition...");
      JdbmPartition newPartition = new JdbmPartition(schemaManager);
      newPartition.setId("newParition");
      newPartition.setSuffixDn(suffixDn);
      newPartition.setCacheSize(1000);
      newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition")<file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition%22)>);

      newPartition.addIndex(new JdbmIndex("objectClass", false));
      newPartition.addIndex(new JdbmIndex("dc", false));

      Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
      contextEntry.put("objectClass", "domain", "top");
      contextEntry.put("dc", "newParition");

      log.info("Initializing Parition");
      newPartition.initialize();
      log.info("Adding Entry to Partition");
      newPartition.add(new AddOperationContext(null, contextEntry));
} catch (URISyntaxException ex) {
      log.error("Error with partition location: " + ex);
} catch (Exception ex) {
      log.error("Error creating partition: " + ex);
}

When I run this, I'm seeing:

Error creating partition: org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …

It doesn't even look like the partition is being added to my server (when I restart my apacheds server, I don't see any new namingContexts under the Root DSE). I think I'm missing some steps here, but not sure what they are. Can anyone help me? I'd greatly appreciate it.

Thanks