directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szoer...@apache.org
Subject svn commit: r711685 - in /directory/sandbox/szoerner/envpartition/src: main/java/org/apache/directory/samples/partition/env/ main/java/org/apache/directory/samples/partition/sysprops/ test/java/org/apache/directory/samples/partition/env/ test/java/org/...
Date Wed, 05 Nov 2008 20:28:28 GMT
Author: szoerner
Date: Wed Nov  5 12:28:27 2008
New Revision: 711685

URL: http://svn.apache.org/viewvc?rev=711685&view=rev
Log:
Modified names

Added:
    directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/
    directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartition.java
    directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/
    directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartitionTest.java
Removed:
    directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/
    directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/env/

Added: directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartition.java?rev=711685&view=auto
==============================================================================
--- directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartition.java
(added)
+++ directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartition.java
Wed Nov  5 12:28:27 2008
@@ -0,0 +1,222 @@
+package org.apache.directory.samples.partition.sysprops;
+
+import javax.naming.OperationNotSupportedException;
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.cursor.EmptyCursor;
+import org.apache.directory.server.core.cursor.SingletonCursor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
+import org.apache.directory.server.core.interceptor.context.AddOperationContext;
+import org.apache.directory.server.core.interceptor.context.BindOperationContext;
+import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
+import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
+import org.apache.directory.server.core.interceptor.context.ListOperationContext;
+import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
+import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.interceptor.context.UnbindOperationContext;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SystemPropertyPartition implements Partition {
+
+    /** The logger */
+    private static final Logger LOG = LoggerFactory
+            .getLogger(SystemPropertyPartition.class);
+
+    private String id;
+
+    private String suffix;
+
+    private DirectoryService service;
+
+    private LdapDN suffixDn;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getSuffix() {
+        return suffix;
+    }
+
+    public void setSuffix(String suffix) {
+        this.suffix = suffix;
+    }
+
+    public int getCacheSize() {
+        return 0;
+    }
+
+    public void setCacheSize(int cacheSize) {
+    }
+
+    public void bind(BindOperationContext ctx) throws Exception {
+
+        LOG.debug("bind()");
+
+        // TODO Auto-generated method stub
+    }
+
+    public void delete(DeleteOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void add(AddOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void modify(ModifyOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void move(MoveOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void moveAndRename(MoveAndRenameOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void rename(RenameOperationContext ctx)
+            throws OperationNotSupportedException {
+        throw new OperationNotSupportedException();
+    }
+
+    public void init(DirectoryService service) throws Exception {
+        LOG.debug("init()");
+
+        this.service = service;
+
+        suffixDn = new LdapDN(suffix);
+        suffixDn.normalize(service.getRegistries().getAttributeTypeRegistry()
+                .getNormalizerMapping());
+    }
+
+    public boolean isInitialized() {
+        LOG.debug("isInitialized()");
+        return true;
+    }
+
+    public void destroy() throws Exception {
+        LOG.debug("destroy()");
+    }
+
+    public LdapDN getSuffixDn() throws Exception {
+        return suffixDn;
+    }
+
+    @Override
+    public LdapDN getUpSuffixDn() throws Exception {
+
+        LOG.debug("getUpSuffixDn()");
+
+        return new LdapDN(suffix);
+    }
+
+    @Override
+    public boolean hasEntry(EntryOperationContext ctx) throws Exception {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("hasEntry(dn=" + ctx.getDn() + ")");
+        }
+
+        return this.getSuffixDn().equals(ctx.getDn());
+    }
+
+    @Override
+    public EntryFilteringCursor list(ListOperationContext ctx) throws Exception {
+
+        LOG.debug("list()");
+
+        return null;
+    }
+
+    @Override
+    public ClonedServerEntry lookup(LookupOperationContext ctx)
+            throws Exception {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("lookup(dn=" + ctx.getDn() + ")");
+        }
+
+        if (this.suffixDn.equals(ctx.getDn())) {
+
+            ServerEntry entry = new DefaultServerEntry(service.getRegistries(),
+                    this.suffixDn);
+            entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
+                    SchemaConstants.ORGANIZATIONAL_UNIT_OC);
+            entry.put(SchemaConstants.OU_AT, "env");
+
+            return new ClonedServerEntry(entry);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public ClonedServerEntry lookup(Long arg0) throws Exception {
+        // TODO Auto-generated method stub
+
+        LOG.debug("lookup()");
+
+        return null;
+    }
+
+    @Override
+    public EntryFilteringCursor search(SearchOperationContext ctx)
+            throws Exception {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("search((dn=" + ctx.getDn() + ", filter="
+                    + ctx.getFilter() + ", scope=" + ctx.getScope() + ")");
+        }
+
+        if (this.suffixDn.equals(ctx.getDn()) && !ctx.getFilter().toString().contains("objectClass=subentry")
&& ctx.getScope().equals(SearchScope.OBJECT)) {
+
+            ServerEntry entry = new DefaultServerEntry(service.getRegistries(),
+                    this.suffixDn);
+            entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
+                    SchemaConstants.ORGANIZATIONAL_UNIT_OC);
+            entry.put(SchemaConstants.OU_AT, "env");
+
+            return new BaseEntryFilteringCursor(
+                    new SingletonCursor<ServerEntry>(entry), ctx);
+
+        } else {
+            return new BaseEntryFilteringCursor(new EmptyCursor<ServerEntry>(),
+                    ctx);
+        }
+    }
+
+    @Override
+    public void sync() throws Exception {
+        LOG.debug("sync()");
+    }
+
+    @Override
+    public void unbind(UnbindOperationContext ctx) throws Exception {
+        LOG.debug("unbind()");
+    }
+
+}

Added: directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartitionTest.java?rev=711685&view=auto
==============================================================================
--- directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartitionTest.java
(added)
+++ directory/sandbox/szoerner/envpartition/src/test/java/org/apache/directory/samples/partition/sysprops/SystemPropertyPartitionTest.java
Wed Nov  5 12:28:27 2008
@@ -0,0 +1,34 @@
+package org.apache.directory.samples.partition.sysprops;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+
+public class SystemPropertyPartitionTest extends TestCase {
+
+    public void testAddPartition() throws Exception {
+        DirectoryService directoryService;
+
+        directoryService = new DefaultDirectoryService();
+        directoryService.setShutdownHookEnabled(true);
+
+        // Determine an appropriate working directory
+        File workingDir = new File("work");
+        directoryService.setWorkingDirectory(workingDir);
+
+        // Create a new partition
+        SystemPropertyPartition envPartition = new SystemPropertyPartition();
+        envPartition.setId("env");
+        envPartition.setSuffix("ou=env");
+        envPartition.init(directoryService);
+
+        directoryService.addPartition(envPartition);
+        directoryService.startup();
+        
+        directoryService.shutdown();
+    }
+
+}



Mime
View raw message