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 2010/07/07 18:41:14 UTC
svn commit: r961431 - in
/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree:
AdministrativeRole.java Subentry.java SubentryCache.java
SubentryInterceptor.java
Author: elecharny
Date: Wed Jul 7 16:41:13 2010
New Revision: 961431
URL: http://svn.apache.org/viewvc?rev=961431&view=rev
Log:
Created an Enum for the administartive roles, and used it in the subentry interceptor
Added:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/AdministrativeRole.java
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/Subentry.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/AdministrativeRole.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/AdministrativeRole.java?rev=961431&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/AdministrativeRole.java (added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/AdministrativeRole.java Wed Jul 7 16:41:13 2010
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.core.subtree;
+
+
+/**
+ * A list of all the Administrative Roles :
+ * <ul>
+ * <li>SubSchema administration role</li>
+ * <li>Access Control administration role</li>
+ * <li>Collective Attribute administration role</li>
+ * <li>Triggers administration role</li>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum AdministrativeRole
+{
+ /** For collective attributes administration */
+ COLLECTIVE_ADMIN_ROLE,
+
+ /** For the subschema administration */
+ SUB_SCHEMA_ADMIN_ROLE,
+
+ /** For the access control administration */
+ ACCESS_CONTROL_ADMIN_ROLE,
+
+ /** For triggers administration */
+ TRIGGERS_ADMIN_ROLE;
+}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/Subentry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/Subentry.java?rev=961431&r1=961430&r2=961431&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/Subentry.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/Subentry.java Wed Jul 7 16:41:13 2010
@@ -20,69 +20,97 @@
package org.apache.directory.server.core.subtree;
+import java.util.Set;
+
import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
/**
- * An operational view of a subentry within the system.
+ * An operational view of a subentry within the system. A Subentry can have
+ * many types (Collective, Schema, AccessControl or Trigger) but only one
+ * Subtree Specification.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class Subentry
{
- static final int COLLECTIVE_SUBENTRY = 1;
- static final int SCHEMA_SUBENTRY = 2;
- static final int ACCESS_CONTROL_SUBENTRY = 4;
- static final int TRIGGER_SUBENTRY = 8;
-
+ /** The Subtree Specification associated with this subentry */
private SubtreeSpecification ss;
- private int type;
+
+ /** The administratives roles */
+ private Set<AdministrativeRole> administrativeRoles;
+ /**
+ * Stores the subtree
+ *
+ * @param ss The subtree specification
+ */
final void setSubtreeSpecification( SubtreeSpecification ss )
{
this.ss = ss;
}
+ /**
+ * @return The subtree specification
+ */
final SubtreeSpecification getSubtreeSpecification()
{
return ss;
}
- final void setTypes( int type )
+ /**
+ *
+ * TODO setAdministrativeRoles.
+ *
+ * @param administrativeRoles
+ */
+ final void setAdministrativeRoles( Set<AdministrativeRole> administrativeRoles )
{
- this.type = type;
+ this.administrativeRoles = administrativeRoles;
}
- final int getTypes()
+ final Set<AdministrativeRole> getAdministrativeRoles()
{
- return type;
+ return administrativeRoles;
}
- final boolean isCollectiveSubentry()
+ /**
+ * Tells if the type contains the Collective attribute Administrative Role
+ */
+ final boolean isCollectiveAdminRole()
{
- return ( COLLECTIVE_SUBENTRY & type ) == COLLECTIVE_SUBENTRY;
+ return administrativeRoles.contains( AdministrativeRole.COLLECTIVE_ADMIN_ROLE );
}
- final boolean isSchemaSubentry()
+ /**
+ * Tells if the type contains the SubSchema Administrative Role
+ */
+ final boolean isSchemaAdminRole()
{
- return ( SCHEMA_SUBENTRY & type ) == SCHEMA_SUBENTRY;
+ return administrativeRoles.contains( AdministrativeRole.SUB_SCHEMA_ADMIN_ROLE );
}
- final boolean isAccessControlSubentry()
+ /**
+ * Tells if the type contains the Access Control Administrative Role
+ */
+ final boolean isAccessControlAdminRole()
{
- return ( ACCESS_CONTROL_SUBENTRY & type ) == ACCESS_CONTROL_SUBENTRY;
+ return administrativeRoles.contains( AdministrativeRole.ACCESS_CONTROL_ADMIN_ROLE );
}
- final boolean isTriggerSubentry()
+ /**
+ * Tells if the type contains the Triggers Administrative Role
+ */
+ final boolean isTriggersAdminRole()
{
- return ( TRIGGER_SUBENTRY & type ) == TRIGGER_SUBENTRY;
+ return administrativeRoles.contains( AdministrativeRole.TRIGGERS_ADMIN_ROLE );
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java?rev=961431&r1=961430&r2=961431&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryCache.java Wed Jul 7 16:41:13 2010
@@ -23,12 +23,13 @@ package org.apache.directory.server.core
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
/**
- * A cache for subtree specifications.
+ * A cache for subtree specifications. It associates a
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -49,12 +50,12 @@ public class SubentryCache
}
- final Subentry setSubentry( String normalizedName, SubtreeSpecification ss, int types )
+ final Subentry setSubentry( String normalizedName, SubtreeSpecification ss, Set<AdministrativeRole> adminRoles )
{
Subentry old = name2subentry.get( normalizedName );
Subentry subentry = new Subentry();
subentry.setSubtreeSpecification( ss );
- subentry.setTypes( types );
+ subentry.setAdministrativeRoles( adminRoles );
name2subentry.put( normalizedName, subentry );
return old;
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=961431&r1=961430&r2=961431&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Wed Jul 7 16:41:13 2010
@@ -21,6 +21,7 @@ package org.apache.directory.server.core
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -186,7 +187,7 @@ public class SubentryInterceptor extends
}
dnName.normalize( schemaManager.getNormalizerMapping() );
- subentryCache.setSubentry( dnName.getNormName(), ss, getSubentryTypes( subentry ) );
+ subentryCache.setSubentry( dnName.getNormName(), ss, getSubentryAdminRoles( subentry ) );
}
subentries.close();
@@ -199,9 +200,9 @@ public class SubentryInterceptor extends
}
- private int getSubentryTypes( Entry subentry ) throws LdapException
+ private Set<AdministrativeRole> getSubentryAdminRoles( Entry subentry ) throws LdapException
{
- int types = 0;
+ Set<AdministrativeRole> adminRoles = new HashSet<AdministrativeRole>();
EntryAttribute oc = subentry.get( SchemaConstants.OBJECT_CLASS_AT );
@@ -212,25 +213,25 @@ public class SubentryInterceptor extends
if ( oc.contains( SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC ) )
{
- types |= Subentry.ACCESS_CONTROL_SUBENTRY;
+ adminRoles.add( AdministrativeRole.ACCESS_CONTROL_ADMIN_ROLE );
}
if ( oc.contains( SchemaConstants.SUBSCHEMA_OC ) )
{
- types |= Subentry.SCHEMA_SUBENTRY;
+ adminRoles.add( AdministrativeRole.SUB_SCHEMA_ADMIN_ROLE );
}
if ( oc.contains( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC ) )
{
- types |= Subentry.COLLECTIVE_SUBENTRY;
+ adminRoles.add( AdministrativeRole.COLLECTIVE_ADMIN_ROLE );
}
if ( oc.contains( ApacheSchemaConstants.TRIGGER_EXECUTION_SUBENTRY_OC ) )
{
- types |= Subentry.TRIGGER_SUBENTRY;
+ adminRoles.add( AdministrativeRole.TRIGGERS_ADMIN_ROLE );
}
- return types;
+ return adminRoles;
}
@@ -334,7 +335,7 @@ public class SubentryInterceptor extends
{
EntryAttribute operational;
- if ( subentry.isAccessControlSubentry() )
+ if ( subentry.isAccessControlAdminRole() )
{
operational = subentryAttrs.get( SchemaConstants.ACCESS_CONTROL_SUBENTRIES_AT );
@@ -348,7 +349,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isSchemaSubentry() )
+ if ( subentry.isSchemaAdminRole() )
{
operational = subentryAttrs.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
@@ -362,7 +363,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isCollectiveSubentry() )
+ if ( subentry.isCollectiveAdminRole() )
{
operational = subentryAttrs.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
@@ -377,7 +378,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isTriggerSubentry() )
+ if ( subentry.isTriggersAdminRole() )
{
operational = subentryAttrs.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT );
@@ -428,7 +429,7 @@ public class SubentryInterceptor extends
* ----------------------------------------------------------------
*/
Subentry subentry = new Subentry();
- subentry.setTypes( getSubentryTypes( entry ) );
+ subentry.setAdministrativeRoles( getSubentryAdminRoles( entry ) );
Entry operational = getSubentryOperationalAttributes( name, subentry );
/* ----------------------------------------------------------------
@@ -452,7 +453,7 @@ public class SubentryInterceptor extends
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
}
- subentryCache.setSubentry( name.getNormName(), ss, getSubentryTypes( entry ) );
+ subentryCache.setSubentry( name.getNormName(), ss, getSubentryAdminRoles( entry ) );
next.add( addContext );
@@ -520,7 +521,7 @@ public class SubentryInterceptor extends
{
EntryAttribute operational;
- if ( subentry.isAccessControlSubentry() )
+ if ( subentry.isAccessControlAdminRole() )
{
operational = entry.get( SchemaConstants.ACCESS_CONTROL_SUBENTRIES_AT );
@@ -534,7 +535,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isSchemaSubentry() )
+ if ( subentry.isSchemaAdminRole() )
{
operational = entry.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
@@ -548,7 +549,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isCollectiveSubentry() )
+ if ( subentry.isCollectiveAdminRole() )
{
operational = entry.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT );
@@ -562,7 +563,7 @@ public class SubentryInterceptor extends
operational.add( subentryDn.getNormName() );
}
- if ( subentry.isTriggerSubentry() )
+ if ( subentry.isTriggersAdminRole() )
{
operational = entry.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT );
@@ -797,7 +798,7 @@ public class SubentryInterceptor extends
newName.add( renameContext.getNewRdn() );
String newNormName = newName.getNormName();
- subentryCache.setSubentry( newNormName, ss, subentry.getTypes() );
+ subentryCache.setSubentry( newNormName, ss, subentry.getAdministrativeRoles() );
next.rename( renameContext );
subentry = subentryCache.getSubentry( newNormName );
@@ -884,7 +885,7 @@ public class SubentryInterceptor extends
newName.add( moveAndRenameContext.getNewRdn() );
String newNormName = newName.getNormName();
- subentryCache.setSubentry( newNormName, ss, subentry.getTypes() );
+ subentryCache.setSubentry( newNormName, ss, subentry.getAdministrativeRoles() );
next.moveAndRename( moveAndRenameContext );
subentry = subentryCache.getSubentry( newNormName );
@@ -973,7 +974,7 @@ public class SubentryInterceptor extends
newName.add( newSuperiorDn.get( newSuperiorDn.size() - 1 ) );
String newNormName = newName.getNormName();
- subentryCache.setSubentry( newNormName, ss, subentry.getTypes() );
+ subentryCache.setSubentry( newNormName, ss, subentry.getAdministrativeRoles() );
next.move( moveContext );
subentry = subentryCache.getSubentry( newNormName );
@@ -1040,7 +1041,7 @@ public class SubentryInterceptor extends
// Methods dealing subentry modification
// -----------------------------------------------------------------------
- private int getSubentryTypes( Entry entry, List<Modification> mods ) throws LdapException
+ private Set<AdministrativeRole> getSubentryTypes( Entry entry, List<Modification> mods ) throws LdapException
{
EntryAttribute ocFinalState = entry.get( SchemaConstants.OBJECT_CLASS_AT ).clone();
@@ -1075,7 +1076,7 @@ public class SubentryInterceptor extends
Entry attrs = new DefaultEntry( schemaManager, DN.EMPTY_DN );
attrs.put( ocFinalState );
- return getSubentryTypes( attrs );
+ return getSubentryAdminRoles( attrs );
}
@@ -1222,7 +1223,7 @@ public class SubentryInterceptor extends
EntryAttribute operational;
- if ( subentry.isAccessControlSubentry() )
+ if ( subentry.isAccessControlAdminRole() )
{
operational = entry.get( SchemaConstants.ACCESS_CONTROL_SUBENTRIES_AT ).clone();
@@ -1241,7 +1242,7 @@ public class SubentryInterceptor extends
modList.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, operational ) );
}
- if ( subentry.isSchemaSubentry() )
+ if ( subentry.isSchemaAdminRole() )
{
operational = entry.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).clone();
@@ -1260,7 +1261,7 @@ public class SubentryInterceptor extends
modList.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, operational ) );
}
- if ( subentry.isCollectiveSubentry() )
+ if ( subentry.isCollectiveAdminRole() )
{
operational = entry.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ).clone();
@@ -1279,7 +1280,7 @@ public class SubentryInterceptor extends
modList.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, operational ) );
}
- if ( subentry.isTriggerSubentry() )
+ if ( subentry.isTriggersAdminRole() )
{
operational = entry.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT ).clone();
@@ -1314,7 +1315,7 @@ public class SubentryInterceptor extends
{
Entry operational = new DefaultEntry( schemaManager, name );
- if ( subentry.isAccessControlSubentry() )
+ if ( subentry.isAccessControlAdminRole() )
{
if ( operational.get( SchemaConstants.ACCESS_CONTROL_SUBENTRIES_AT ) == null )
{
@@ -1326,7 +1327,7 @@ public class SubentryInterceptor extends
}
}
- if ( subentry.isSchemaSubentry() )
+ if ( subentry.isSchemaAdminRole() )
{
if ( operational.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ) == null )
{
@@ -1338,7 +1339,7 @@ public class SubentryInterceptor extends
}
}
- if ( subentry.isCollectiveSubentry() )
+ if ( subentry.isCollectiveAdminRole() )
{
if ( operational.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ) == null )
{
@@ -1350,7 +1351,7 @@ public class SubentryInterceptor extends
}
}
- if ( subentry.isTriggerSubentry() )
+ if ( subentry.isTriggersAdminRole() )
{
if ( operational.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT ) == null )
{