Author: szoerner Date: Tue Nov 4 13:08:30 2008 New Revision: 711406 URL: http://svn.apache.org/viewvc?rev=711406&view=rev Log: First working search Modified: directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/EnvironmentPartition.java Modified: directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/EnvironmentPartition.java URL: http://svn.apache.org/viewvc/directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/EnvironmentPartition.java?rev=711406&r1=711405&r2=711406&view=diff ============================================================================== --- directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/EnvironmentPartition.java (original) +++ directory/sandbox/szoerner/envpartition/src/main/java/org/apache/directory/samples/partition/env/EnvironmentPartition.java Tue Nov 4 13:08:30 2008 @@ -4,6 +4,7 @@ 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; @@ -23,6 +24,7 @@ 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; @@ -56,7 +58,7 @@ public void setSuffix(String suffix) { this.suffix = suffix; } - + public int getCacheSize() { return 0; } @@ -120,7 +122,6 @@ LOG.debug("destroy()"); } - public LdapDN getSuffixDn() throws Exception { return suffixDn; } @@ -165,7 +166,7 @@ this.suffixDn); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC); - entry.put(SchemaConstants.ORGANIZATIONAL_UNIT_NAME_AT, "env"); + entry.put(SchemaConstants.OU_AT, "env"); return new ClonedServerEntry(entry); } else { @@ -191,9 +192,22 @@ + ctx.getFilter() + ", scope=" + ctx.getScope() + ")"); } - return new BaseEntryFilteringCursor(new EmptyCursor(), ctx); - } + 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(entry), ctx); + } else { + return new BaseEntryFilteringCursor(new EmptyCursor(), + ctx); + } + } @Override public void sync() throws Exception {