You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/01/07 17:19:17 UTC
svn commit: r1056373 -
/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
Author: elecharny
Date: Fri Jan 7 16:19:17 2011
New Revision: 1056373
URL: http://svn.apache.org/viewvc?rev=1056373&view=rev
Log:
Make the interceptor inject the CollectoveAttribute in entries using the UUID ref instead of the Subentry DN ref
Modified:
directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=1056373&r1=1056372&r2=1056373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java Fri Jan 7 16:19:17 2011
@@ -24,7 +24,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.administrative.AdministrativeRoleEnum;
+import org.apache.directory.server.core.administrative.CollectiveAttributeSubentry;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.filtering.EntryFilter;
import org.apache.directory.server.core.filtering.EntryFilteringCursor;
@@ -37,7 +40,6 @@ import org.apache.directory.server.core.
import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
-import org.apache.directory.server.core.partition.ByPassConstants;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
@@ -79,7 +81,7 @@ public class CollectiveAttributeIntercep
private static AttributeType OBJECT_CLASS_AT;
/** The CollectiveAttributeSubentries AttributeType */
- private static AttributeType COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT;
+ private static AttributeType COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT;
/** The CollectiveExclusions AttributeType */
private static AttributeType COLLECTIVE_EXCLUSIONS_AT;
@@ -109,7 +111,7 @@ public class CollectiveAttributeIntercep
schemaManager = directoryService.getSchemaManager();
// Load some AttributeType
- COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT = schemaManager.getAttributeType( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
+ COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT = schemaManager.getAttributeType( ApacheSchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT );
COLLECTIVE_EXCLUSIONS_AT = schemaManager.getAttributeType( SchemaConstants.COLLECTIVE_EXCLUSIONS_AT );
OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
@@ -338,7 +340,7 @@ public class CollectiveAttributeIntercep
private void addCollectiveAttributes( OperationContext opContext, Entry entry, String[] retAttrs ) throws LdapException
{
EntryAttribute collectiveAttributeSubentries = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get(
- COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
+ COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT );
/*
* If there are no collective attribute subentries referenced then we
@@ -415,23 +417,15 @@ public class CollectiveAttributeIntercep
*/
for ( Value<?> value : collectiveAttributeSubentries )
{
- String subentryDnStr = value.getString();
- DN subentryDn = opContext.getSession().getDirectoryService().getDNFactory().create( subentryDnStr );
-
- /*
- * TODO - Instead of hitting disk here can't we leverage the
- * SubentryService to get us cached sub-entries so we're not
- * wasting time with a lookup here? It is ridiculous to waste
- * time looking up this sub-entry.
- */
-
- Entry subentry = opContext.lookup( subentryDn, ByPassConstants.LOOKUP_COLLECTIVE_BYPASS );
+ String subentryUuid = value.getString();
+
+ CollectiveAttributeSubentry subentry = (CollectiveAttributeSubentry)directoryService.getSubentryCache().getSubentry( subentryUuid, AdministrativeRoleEnum.CollectiveAttribute );
- for ( AttributeType attributeType : subentry.getAttributeTypes() )
+ for ( EntryAttribute attribute : subentry.getCollectiveAttributes() )
{
- String attrId = attributeType.getName();
+ String attrId = attribute.getId();
- if ( !attributeType.isCollective() )
+ if ( !attribute.getAttributeType().isCollective() )
{
continue;
}
@@ -440,12 +434,12 @@ public class CollectiveAttributeIntercep
* Skip the addition of this collective attribute if it is excluded
* in the 'collectiveAttributes' attribute.
*/
- if ( exclusions.contains( attributeType.getOid() ) )
+ if ( exclusions.contains( attribute.getAttributeType().getOid() ) )
{
continue;
}
- Set<AttributeType> allSuperTypes = getAllSuperTypes( attributeType );
+ Set<AttributeType> allSuperTypes = getAllSuperTypes( attribute.getAttributeType() );
for ( String retId : retIdsSet )
{
@@ -474,7 +468,7 @@ public class CollectiveAttributeIntercep
continue;
}
- EntryAttribute subentryColAttr = subentry.get( attrId );
+ List<EntryAttribute> subentryColAttr = subentry.getCollectiveAttributes();
EntryAttribute entryColAttr = entry.get( attrId );
/*
@@ -491,9 +485,15 @@ public class CollectiveAttributeIntercep
* Add all the collective attribute values in the subentry
* to the currently processed collective attribute in the entry.
*/
- for ( Value<?> subentryColVal : subentryColAttr )
+ for ( EntryAttribute subentryAT : subentry.getCollectiveAttributes() )
{
- entryColAttr.add( subentryColVal.getString() );
+ if ( subentryAT.getId().equals( attrId) )
+ {
+ for ( Value<?> subentryColVal : subentryAT )
+ {
+ entryColAttr.add( subentryColVal.getString() );
+ }
+ }
}
}
}