directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r503355 - in /directory/apacheds/trunk: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ core/src/main/java/org/apache/directory/server/core/authz/ core/src/main/java/org/apache/directory/server/core/authz/s...
Date Sun, 04 Feb 2007 04:22:20 GMT
Author: akarasulu
Date: Sat Feb  3 20:22:19 2007
New Revision: 503355

URL: http://svn.apache.org/viewvc?view=rev&rev=503355
Log:
removed ServerUtils which has redundant functionality found in AttributeUtils

Added:
    directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/
    directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java
Removed:
    directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java
    directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/core/
Modified:
    directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java
    directory/apacheds/trunk/jdbm-store/pom.xml
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/utils/pom.xml

Modified: directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/apacheds/trunk/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Sat Feb  3 20:22:19 2007
@@ -60,6 +60,7 @@
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
 import org.apache.directory.server.schema.registries.SyntaxRegistry;
+import org.apache.directory.server.utils.AttributesFactory;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java Sat Feb  3 20:22:19 2007
@@ -21,7 +21,6 @@
 
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.authz.support.ACDFEngine;
 import org.apache.directory.server.core.configuration.InterceptorConfiguration;
@@ -225,7 +224,7 @@
     private void addPerscriptiveAciTuples( PartitionNexusProxy proxy, Collection<ACITuple> tuples, LdapDN dn,
         Attributes entry ) throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassType );
         
         /*
          * If the protected entry is a subentry, then the entry being evaluated
@@ -243,7 +242,7 @@
             entry = proxy.lookup( parentDn, PartitionNexusProxy.LOOKUP_BYPASS );
         }
 
-        Attribute subentries = ServerUtils.getAttribute( acSubentryType, entry );
+        Attribute subentries = AttributeUtils.getAttribute( entry, acSubentryType );
         if ( subentries == null )
         {
             return;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java Sat Feb  3 20:22:19 2007
@@ -27,7 +27,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.event.Evaluator;
 import org.apache.directory.server.core.partition.PartitionNexusProxy;
 import org.apache.directory.server.core.subtree.RefinementEvaluator;
@@ -249,7 +248,7 @@
                     if ( oid.equals( oidRegistry.getOid( svItem ) ) )
                     {
                         AttributeType attrType = attrRegistry.lookup( oid );
-                        Attribute attr = ServerUtils.getAttribute( attrType, entry );
+                        Attribute attr = AttributeUtils.getAttribute( entry, attrType );
                         if ( attr != null && ( ( attr.contains( userName.toNormName() ) || attr.contains( userName.getUpName() ) ) ) )
                         {
                             return true;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java Sat Feb  3 20:22:19 2007
@@ -27,7 +27,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.NotImplementedException;
@@ -39,6 +38,7 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 
 /**
@@ -150,7 +150,7 @@
 
         // get the attribute associated with the node
         AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( attrId ) );
-        Attribute attr = ServerUtils.getAttribute( type, entry );
+        Attribute attr = AttributeUtils.getAttribute( entry, type );
 
         // If we do not have the attribute just return false
         if ( null == attr )
@@ -219,7 +219,7 @@
         }
 
         AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( attrId ) );
-        return null != ServerUtils.getAttribute( type, entry );
+        return null != AttributeUtils.getAttribute( entry, type );
     }
 
 
@@ -239,7 +239,7 @@
 
         // get the attribute associated with the node
         AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( node.getAttribute() ) );
-        Attribute attr = ServerUtils.getAttribute( type, entry );
+        Attribute attr = AttributeUtils.getAttribute( entry, type );
 
         // If we do not have the attribute just return false
         if ( null == attr )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java Sat Feb  3 20:22:19 2007
@@ -28,7 +28,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.shared.ldap.NotImplementedException;
@@ -264,7 +263,7 @@
         }
 
         AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( attrId ) );
-        return null != ServerUtils.getAttribute( type, attrs );
+        return null != AttributeUtils.getAttribute( attrs, type );
     }
 
    
@@ -305,7 +304,7 @@
         // get the attribute associated with the node 
         Attributes attrs = rec.getAttributes();
         AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( node.getAttribute() ) );
-        Attribute attr = ServerUtils.getAttribute( type, attrs );
+        Attribute attr = AttributeUtils.getAttribute( attrs, type );
 
         // If we do not have the attribute just return false
         if ( null == attr )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java Sat Feb  3 20:22:19 2007
@@ -39,7 +39,6 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.configuration.PartitionConfiguration;
 import org.apache.directory.server.core.configuration.InterceptorConfiguration;
 import org.apache.directory.server.core.enumeration.ReferralHandlingEnumeration;
@@ -68,6 +67,7 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -286,7 +286,7 @@
 
             Attributes referral = invocation.getProxy().lookup( farthest, PartitionNexusProxy.LOOKUP_BYPASS );
             AttributeType refsType = attrRegistry.lookup( oidRegistry.getOid( REF_ATTR ) );
-            Attribute refs = ServerUtils.getAttribute( refsType, referral );
+            Attribute refs = AttributeUtils.getAttribute( referral, refsType );
             doReferralException( farthest, new LdapDN( normName.getUpName() ), refs );
         }
         else if ( refval.equals( FOLLOW ) )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/AbstractSchemaChangeHandler.java Sat Feb  3 20:22:19 2007
@@ -29,13 +29,13 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 
 
 /**
@@ -97,7 +97,7 @@
     
     protected String getOid( Attributes entry ) throws NamingException
     {
-        Attribute oid = ServerUtils.getAttribute( m_oidAT, entry );
+        Attribute oid = AttributeUtils.getAttribute( entry, m_oidAT );
         if ( oid == null )
         {
             return null;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaComparatorHandler.java Sat Feb  3 20:22:19 2007
@@ -27,7 +27,6 @@
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.ComparatorRegistry;
 import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
@@ -39,6 +38,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -58,7 +58,7 @@
     private final Registries targetRegistries;
     private final ComparatorRegistry comparatorRegistry;
     private final MatchingRuleRegistry matchingRuleRegistry;
-    private final AttributeType m_oidAT;
+    private final AttributeType oidAT;
 
     
 
@@ -69,13 +69,13 @@
         this.comparatorRegistry = targetRegistries.getComparatorRegistry();
         this.matchingRuleRegistry = targetRegistries.getMatchingRuleRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
-        this.m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
     }
 
 
     private String getOid( Attributes entry ) throws NamingException
     {
-        Attribute oid = ServerUtils.getAttribute( m_oidAT, entry );
+        Attribute oid = AttributeUtils.getAttribute( entry, oidAT );
         if ( oid == null )
         {
             return null;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaNormalizerHandler.java Sat Feb  3 20:22:19 2007
@@ -25,7 +25,6 @@
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
 import org.apache.directory.server.schema.registries.NormalizerRegistry;
@@ -38,6 +37,7 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -57,7 +57,7 @@
     private final Registries targetRegistries;
     private final NormalizerRegistry normalizerRegistry;
     private final MatchingRuleRegistry matchingRuleRegistry;
-    private final AttributeType m_oidAT;
+    private final AttributeType oidAT;
 
     
 
@@ -68,13 +68,13 @@
         this.normalizerRegistry = targetRegistries.getNormalizerRegistry();
         this.matchingRuleRegistry = targetRegistries.getMatchingRuleRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
-        this.m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
     }
 
 
     private String getOid( Attributes entry ) throws NamingException
     {
-        Attribute oid = ServerUtils.getAttribute( m_oidAT, entry );
+        Attribute oid = AttributeUtils.getAttribute( entry, oidAT );
         if ( oid == null )
         {
             return null;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java Sat Feb  3 20:22:19 2007
@@ -32,7 +32,6 @@
 import org.apache.directory.server.constants.CoreSchemaConstants;
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.schema.registries.SchemaObjectRegistry;
@@ -93,7 +92,7 @@
         Attribute disabledInMods = AttributeUtils.getAttribute( mods, disabledAT );
         if ( disabledInMods != null )
         {
-            disable( name, modOp, disabledInMods, ServerUtils.getAttribute( disabledAT, entry ) );
+            disable( name, modOp, disabledInMods, AttributeUtils.getAttribute( entry, disabledAT ) );
         }
         
         // check if the new schema is enabled or disabled

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java Sat Feb  3 20:22:19 2007
@@ -25,7 +25,6 @@
 import javax.naming.directory.Attributes;
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
@@ -39,6 +38,7 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 
@@ -58,7 +58,7 @@
     private final Registries targetRegistries;
     private final SyntaxCheckerRegistry syntaxCheckerRegistry;
     private final SyntaxRegistry syntaxRegistry;
-    private final AttributeType m_oidAT;
+    private final AttributeType oidAT;
 
     
 
@@ -69,13 +69,13 @@
         this.syntaxCheckerRegistry = targetRegistries.getSyntaxCheckerRegistry();
         this.syntaxRegistry = targetRegistries.getSyntaxRegistry();
         this.factory = new SchemaEntityFactory( targetRegistries );
-        this.m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
     }
 
 
     private String getOid( Attributes entry ) throws NamingException
     {
-        Attribute oid = ServerUtils.getAttribute( m_oidAT, entry );
+        Attribute oid = AttributeUtils.getAttribute( entry, oidAT );
         if ( oid == null )
         {
             return null;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java Sat Feb  3 20:22:19 2007
@@ -33,7 +33,6 @@
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -150,7 +149,7 @@
         SyntaxChecker syntaxChecker = null;
         Class clazz = null;
 
-        Attribute byteCodeAttr = ServerUtils.getAttribute( byteCodeAT, entry );
+        Attribute byteCodeAttr = AttributeUtils.getAttribute( entry, byteCodeAT );
         if ( byteCodeAttr == null )
         {
             try
@@ -214,7 +213,7 @@
 
         // try now before returning to check if we can inject a Registries object
         injectRegistries( syntaxChecker, targetRegistries );
-        String syntaxOid = ( String ) ServerUtils.getAttribute( oidAT, entry ).get();
+        String syntaxOid = ( String ) AttributeUtils.getAttribute( entry, oidAT ).get();
         injectOid( syntaxOid, syntaxChecker );
         return syntaxChecker;
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java Sat Feb  3 20:22:19 2007
@@ -33,7 +33,6 @@
 import org.apache.directory.server.constants.CoreSchemaConstants;
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.ObjectClassRegistry;
 import org.apache.directory.server.schema.registries.Registries;
@@ -175,7 +174,7 @@
 
     public void add( LdapDN name, Attributes entry ) throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -220,7 +219,7 @@
 
     public void delete( LdapDN name, Attributes entry ) throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -266,7 +265,7 @@
     public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry, Attributes targetEntry ) 
         throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -292,7 +291,7 @@
     public void modify( LdapDN name, ModificationItemImpl[] mods, Attributes entry, Attributes targetEntry ) 
         throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -317,7 +316,7 @@
 
     public void modifyRn( LdapDN name, String newRdn, boolean deleteOldRn, Attributes entry ) throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -342,7 +341,7 @@
 
     public void move( LdapDN oriChildName, LdapDN newParentName, Attributes entry ) throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {
@@ -368,7 +367,7 @@
     public void move( LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn, Attributes entry )
         throws NamingException
     {
-        Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
+        Attribute oc = AttributeUtils.getAttribute( entry, objectClassAT );
         
         for ( int ii = 0; ii < oc.size(); ii++ )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java Sat Feb  3 20:22:19 2007
@@ -36,7 +36,6 @@
 
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.bootstrap.Schema;
@@ -374,7 +373,7 @@
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
         Attributes entry = partition.lookup( dn );
-        Attribute disabledAttr = ServerUtils.getAttribute( disabledAttributeType, entry );
+        Attribute disabledAttr = AttributeUtils.getAttribute( entry, disabledAttributeType );
         ModificationItemImpl[] mods = new ModificationItemImpl[3];
         
         if ( disabledAttr == null )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java Sat Feb  3 20:22:19 2007
@@ -26,7 +26,6 @@
 import java.util.Map;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.configuration.InterceptorConfiguration;
 import org.apache.directory.server.core.enumeration.SearchResultFilter;
 import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration;
@@ -527,7 +526,7 @@
     public void delete( NextInterceptor next, LdapDN name ) throws NamingException
     {
         Attributes entry = nexus.lookup( name );
-        Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
 
         if ( AttributeUtils.containsValueCaseIgnore( objectClasses, "subentry" ) )
         {
@@ -606,7 +605,7 @@
     private ModificationItemImpl[] getModsOnEntryRdnChange( Name oldName, Name newName, Attributes entry )
         throws NamingException
     {
-        List modList = new ArrayList();
+        List<ModificationItemImpl> modList = new ArrayList<ModificationItemImpl>();
 
         /*
          * There are two different situations warranting action.  Firt if
@@ -671,7 +670,7 @@
         }
 
         ModificationItemImpl[] mods = new ModificationItemImpl[modList.size()];
-        mods = ( ModificationItemImpl[] ) modList.toArray( mods );
+        mods = modList.toArray( mods );
         return mods;
     }
 
@@ -679,7 +678,7 @@
     public void modifyRn( NextInterceptor next, LdapDN name, String newRn, boolean deleteOldRn ) throws NamingException
     {
         Attributes entry = nexus.lookup( name );
-        Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
 
         if ( AttributeUtils.containsValueCaseIgnore( objectClasses, "subentry" ) )
         {
@@ -750,7 +749,7 @@
         throws NamingException
     {
         Attributes entry = nexus.lookup( oriChildName );
-        Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
 
         if ( AttributeUtils.containsValueCaseIgnore( objectClasses, "subentry" ) )
         {
@@ -964,7 +963,7 @@
     public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException
     {
         Attributes entry = nexus.lookup( name );
-        Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
 
         if ( AttributeUtils.containsValueCaseIgnore( objectClasses, "subentry" )  && mods.get( "subtreeSpecification" ) != null )
         {
@@ -1038,7 +1037,7 @@
     public void modify( NextInterceptor next, LdapDN name, ModificationItemImpl[] mods ) throws NamingException
     {
         Attributes entry = nexus.lookup( name );
-        Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry );
+        Attribute objectClasses = AttributeUtils.getAttribute( entry, objectClassType );
         boolean isSubtreeSpecificationModification = false;
         ModificationItemImpl subtreeMod = null;
 
@@ -1127,7 +1126,7 @@
     private ModificationItemImpl[] getOperationalModsForReplace( Name oldName, Name newName, Subentry subentry,
         Attributes entry ) throws NamingException
     {
-        List modList = new ArrayList();
+        List<ModificationItemImpl> modList = new ArrayList<ModificationItemImpl>();
         
         Attribute operational;
 
@@ -1193,7 +1192,7 @@
         } 
 
         ModificationItemImpl[] mods = new ModificationItemImpl[modList.size()];
-        return ( ModificationItemImpl[] ) modList.toArray( mods );
+        return modList.toArray( mods );
     }
 
 
@@ -1275,7 +1274,7 @@
      */
     private ModificationItemImpl[] getOperationalModsForRemove( LdapDN subentryDn, Attributes candidate )
     {
-        List modList = new ArrayList();
+        List<ModificationItemImpl> modList = new ArrayList<ModificationItemImpl>();
         String dn = subentryDn.toNormName();
 
         for ( int ii = 0; ii < SUBENTRY_OPATTRS.length; ii++ )
@@ -1292,7 +1291,7 @@
         }
 
         ModificationItemImpl[] mods = new ModificationItemImpl[modList.size()];
-        return ( ModificationItemImpl[] ) modList.toArray( mods );
+        return modList.toArray( mods );
     }
 
 
@@ -1313,7 +1312,7 @@
     public ModificationItemImpl[] getOperationalModsForAdd( Attributes entry, Attributes operational )
         throws NamingException
     {
-        List modList = new ArrayList();
+        List<ModificationItemImpl> modList = new ArrayList<ModificationItemImpl>();
 
         NamingEnumeration opAttrIds = operational.getIDs();
         while ( opAttrIds.hasMore() )
@@ -1345,7 +1344,7 @@
         }
 
         ModificationItemImpl[] mods = new ModificationItemImpl[modList.size()];
-        mods = ( ModificationItemImpl[] ) modList.toArray( mods );
+        mods = modList.toArray( mods );
         return mods;
     }
 

Modified: directory/apacheds/trunk/jdbm-store/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/pom.xml?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/jdbm-store/pom.xml (original)
+++ directory/apacheds/trunk/jdbm-store/pom.xml Sat Feb  3 20:22:19 2007
@@ -40,11 +40,6 @@
     </dependency>
     <dependency>
       <groupId>${pom.groupId}</groupId>
-      <artifactId>apacheds-utils</artifactId>
-      <version>${pom.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>${pom.groupId}</groupId>
       <artifactId>apacheds-btree-base</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Sat Feb  3 20:22:19 2007
@@ -35,13 +35,13 @@
 import jdbm.recman.BaseRecordManager;
 import jdbm.recman.CacheRecordManager;
 
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.partition.impl.btree.Index;
 import org.apache.directory.server.core.partition.impl.btree.IndexComparator;
 import org.apache.directory.server.core.partition.impl.btree.IndexConfiguration;
 import org.apache.directory.server.core.partition.impl.btree.IndexEnumeration;
 import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
 
 
@@ -253,7 +253,7 @@
      */
     public synchronized void add( Attributes attrs, BigInteger id ) throws NamingException
     {
-        add( ServerUtils.getAttribute( attribute, attrs ), id );
+        add( AttributeUtils.getAttribute( attrs, attribute ), id );
     }
 
 
@@ -317,7 +317,7 @@
      */
     public void drop( Attributes attrs, BigInteger id ) throws NamingException
     {
-        drop( ServerUtils.getAttribute( attribute, attrs ), id );
+        drop( AttributeUtils.getAttribute( attrs, attribute ), id );
     }
 
 

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sat Feb  3 20:22:19 2007
@@ -41,7 +41,6 @@
 import jdbm.recman.BaseRecordManager;
 import jdbm.recman.CacheRecordManager;
 
-import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.partition.Oid;
 import org.apache.directory.server.core.partition.impl.btree.Index;
 import org.apache.directory.server.core.partition.impl.btree.IndexAssertion;
@@ -60,6 +59,7 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -1036,7 +1036,7 @@
             throw new LdapNameNotFoundException( "Id for parent '" + parentDn + "' not found!" );
         }
 
-        Attribute objectClass = ServerUtils.getAttribute( OBJECT_CLASS_AT, entry );
+        Attribute objectClass = AttributeUtils.getAttribute( entry, OBJECT_CLASS_AT );
 
         if ( objectClass == null )
         {
@@ -1049,7 +1049,7 @@
 
         if ( objectClass.contains( ALIAS_OBJECT ) )
         {
-            Attribute aliasAttr = ServerUtils.getAttribute( ALIAS_AT, entry );
+            Attribute aliasAttr = AttributeUtils.getAttribute( entry, ALIAS_AT );
             addAliasIndices( id, normName, ( String ) aliasAttr.get() );
         }
 
@@ -1103,7 +1103,7 @@
         BigInteger parentId = getParentId( id );
         NamingEnumeration attrs = entry.getIDs();
 
-        Attribute objectClass = ServerUtils.getAttribute( OBJECT_CLASS_AT, entry );
+        Attribute objectClass = AttributeUtils.getAttribute( entry, OBJECT_CLASS_AT );
         if ( objectClass.contains( ALIAS_OBJECT ) )
         {
             dropAliasIndices( id );
@@ -1294,7 +1294,7 @@
 
         // add all the values in mods to the same attribute in the entry
         AttributeType type = attributeTypeRegistry.lookup( modsOid );
-        Attribute entryAttrToAddTo = ServerUtils.getAttribute( type, entry );
+        Attribute entryAttrToAddTo = AttributeUtils.getAttribute( entry, type );
 
         if ( entryAttrToAddTo == null )
         {
@@ -1357,11 +1357,11 @@
          */
         if ( mods.size() == 0 )
         {
-            ServerUtils.removeAttribute( attrType, entry );
+            AttributeUtils.removeAttribute( attrType, entry );
         }
         else
         {
-            Attribute entryAttr = ServerUtils.getAttribute( attrType, entry );
+            Attribute entryAttr = AttributeUtils.getAttribute( entry, attrType );
             NamingEnumeration values = mods.getAll();
             while ( values.hasMore() )
             {
@@ -1565,7 +1565,7 @@
 
         String newRdnAttrOid = oidRegistry.getOid( newRdnAttr );
         AttributeType newRdnAttrType = attributeTypeRegistry.lookup( newRdnAttrOid );
-        Attribute rdnAttr = ServerUtils.getAttribute( newRdnAttrType, entry );
+        Attribute rdnAttr = AttributeUtils.getAttribute( entry, newRdnAttrType );
         if ( rdnAttr == null )
         {
             rdnAttr = new AttributeImpl( newRdnAttr );
@@ -1613,7 +1613,7 @@
             String oldRdnValue = NamespaceTools.getRdnValue( oldRdn );
             AttributeType oldRdnAttrType = attributeTypeRegistry.lookup( oldRdnAttrOid );
             
-            ServerUtils.getAttribute( oldRdnAttrType, entry ).remove( oldRdnValue );
+            AttributeUtils.getAttribute( entry, oldRdnAttrType ).remove( oldRdnValue );
 
             if ( hasUserIndexOn( oldRdnAttrOid ) )
             {

Modified: directory/apacheds/trunk/utils/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/utils/pom.xml?view=diff&rev=503355&r1=503354&r2=503355
==============================================================================
--- directory/apacheds/trunk/utils/pom.xml (original)
+++ directory/apacheds/trunk/utils/pom.xml Sat Feb  3 20:22:19 2007
@@ -12,5 +12,17 @@
   <description>
     Contains utility classes for ApacheDS.
   </description>
+  <dependencies>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>apacheds-constants</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>apacheds-core-shared</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+  </dependencies>
 </project>
 

Added: directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java?view=auto&rev=503355
==============================================================================
--- directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java (added)
+++ directory/apacheds/trunk/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java Sat Feb  3 20:22:19 2007
@@ -0,0 +1,396 @@
+/*
+ *  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.utils; 
+
+
+import java.util.Comparator; 
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.constants.SystemSchemaConstants;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.DITContentRule;
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.DateUtils;
+
+
+/**
+ * A factory that generates an entry using the meta schema for schema 
+ * elements.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AttributesFactory
+{
+    public Attributes getAttributes( Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SCHEMA_OC );
+        entry.put( SystemSchemaConstants.CN_AT, schema.getSchemaName() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        
+        if ( schema.isDisabled() )
+        {
+            entry.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
+        }
+        
+        String[] dependencies = schema.getDependencies();
+        if ( dependencies != null && dependencies.length > 0 )
+        {
+            Attribute attr = new AttributeImpl( MetaSchemaConstants.M_DEPENDENCIES_AT );
+            for ( int ii = 0; ii < dependencies.length; ii++ )
+            {
+                attr.add( dependencies[ii] );
+            }
+            entry.put( attr );
+        }
+        
+        return entry;
+    }
+    
+    
+    public Attributes getAttributes( SyntaxChecker syntaxChecker, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
+        entry.put( MetaSchemaConstants.M_OID_AT, syntaxChecker.getSyntaxOid() );
+        entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( Syntax syntax, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SYNTAX_OC );
+        entry.put( MetaSchemaConstants.X_HUMAN_READIBLE_AT, getBoolean( syntax.isHumanReadible() ) );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        injectCommon( syntax, entry );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( String oid, Normalizer normalizer, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_NORMALIZER_OC );
+        entry.put( MetaSchemaConstants.M_OID_AT, oid );
+        entry.put( MetaSchemaConstants.M_FQCN_AT, normalizer.getClass().getName() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( String oid, Comparator comparator, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_COMPARATOR_OC );
+        entry.put( MetaSchemaConstants.M_OID_AT, oid );
+        entry.put( MetaSchemaConstants.M_FQCN_AT, comparator.getClass().getName() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+
+    /**
+     * 
+     * @param matchingRule
+     * @return
+     * @throws NamingException
+     */
+    public Attributes getAttributes( MatchingRule matchingRule, Schema schema ) throws NamingException
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_MATCHING_RULE_OC );
+        entry.put( MetaSchemaConstants.M_SYNTAX_AT, matchingRule.getSyntax().getOid() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        injectCommon( matchingRule, entry );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( MatchingRuleUse matchingRuleUse, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( "" );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( DITStructureRule dITStructureRule, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( "" );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( DITContentRule dITContentRule, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( "" );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+    
+    public Attributes getAttributes( NameForm nameForm, Schema schema )
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( "" );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        return entry;
+    }
+
+
+    /**
+     * <pre>
+     *    objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.3
+     *       NAME 'metaAttributeType'
+     *       DESC 'meta definition of the AttributeType object'
+     *       SUP metaTop
+     *       STRUCTURAL
+     *       MUST ( m-name $ m-syntax )
+     *       MAY ( m-supAttributeType $ m-obsolete $ m-equality $ m-ordering $ 
+     *             m-substr $ m-singleValue $ m-collective $ m-noUserModification $ 
+     *             m-usage $ m-extensionAttributeType )
+     *    )
+     * </pre>
+     * 
+     * @param attributeType
+     * @return
+     * @throws NamingException
+     */
+    public Attributes getAttributes( AttributeType attributeType, Schema schema ) throws NamingException
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
+        entry.put( MetaSchemaConstants.M_SYNTAX_AT, attributeType.getSyntax().getOid() );
+        entry.put( MetaSchemaConstants.M_COLLECTIVE_AT, getBoolean( attributeType.isCollective() ) );
+        entry.put( MetaSchemaConstants.M_NO_USER_MODIFICATION_AT, getBoolean( ! attributeType.isCanUserModify() ) );
+        entry.put( MetaSchemaConstants.M_SINGLE_VALUE_AT, getBoolean( attributeType.isSingleValue() ) );
+        entry.put( MetaSchemaConstants.M_USAGE_AT, attributeType.getUsage().toString() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+
+        injectCommon( attributeType, entry );
+        
+        AttributeType superior = attributeType.getSuperior();
+        if ( superior != null )
+        {
+            // use name if we can for clarity
+            String sup = superior.getName();
+            if ( sup == null )
+            {
+                sup = superior.getOid();
+            }
+            entry.put( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT, sup );
+        }
+        
+        if ( attributeType.getEquality() != null )
+        {
+            String equality = attributeType.getEquality().getName();
+            
+            if ( equality == null )
+            {
+                equality = attributeType.getEquality().getOid();
+            }
+            
+            entry.put( MetaSchemaConstants.M_EQUALITY_AT, equality );
+        }
+
+        if ( attributeType.getSubstr() != null )
+        {
+            String substr = attributeType.getSubstr().getName();
+            
+            if ( substr == null )
+            {
+                substr = attributeType.getSubstr().getOid();
+            }
+            
+            entry.put( MetaSchemaConstants.M_SUBSTR_AT, substr );
+        }
+
+        if ( attributeType.getOrdering() != null )
+        {
+            String ordering = attributeType.getOrdering().getName();
+            
+            if ( ordering == null )
+            {
+                ordering = attributeType.getOrdering().getOid();
+            }
+            
+            entry.put( MetaSchemaConstants.M_ORDERING_AT, ordering );
+        }
+
+        return entry;
+    }
+
+    
+    /**
+     * Creates the attributes of an entry representing an objectClass.
+     * 
+     * <pre>
+     *  objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.2
+     *      NAME 'metaObjectclass'
+     *      DESC 'meta definition of the objectclass object'
+     *      SUP metaTop
+     *      STRUCTURAL
+     *      MUST m-oid
+     *      MAY ( m-name $ m-obsolete $ m-supObjectClass $ m-typeObjectClass $ m-must $ 
+     *            m-may $ m-extensionObjectClass )
+     *  )
+     * </pre>
+     * 
+     * @param objectClass the objectClass to produce a meta schema entry for
+     * @return the attributes of the metaSchema entry representing the objectClass
+     * @throws NamingException if there are any problems
+     */
+    public Attributes getAttributes( ObjectClass objectClass, Schema schema ) throws NamingException
+    {
+        Attributes entry = new AttributesImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top", true );
+        entry.get( SystemSchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        entry.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, objectClass.getType().toString() );
+        entry.put( SystemSchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
+        entry.put( SystemSchemaConstants.CREAT_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+        
+        injectCommon( objectClass, entry );
+
+        // handle the superior objectClasses 
+        if ( objectClass.getSuperClasses() != null && objectClass.getSuperClasses().length != 0 )
+        {
+            Attribute attr = new AttributeImpl( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
+            ObjectClass[] superclasses = objectClass.getSuperClasses();
+            for ( int ii = 0; ii < superclasses.length; ii++ )
+            {
+                attr.add( getNameOrNumericoid( superclasses[ii] ) ); 
+            }
+            entry.put( attr );
+        }
+
+        // add the must list
+        if ( objectClass.getMustList() != null && objectClass.getMustList().length != 0 )
+        {
+            Attribute attr = new AttributeImpl( MetaSchemaConstants.M_MUST_AT );
+            AttributeType[] mustList = objectClass.getMustList();
+            for ( int ii = 0; ii < mustList.length; ii++ )
+            {
+                attr.add( getNameOrNumericoid( mustList[ii] ) );
+            }
+            entry.put( attr );
+        }
+        
+        // add the may list
+        if ( objectClass.getMayList() != null && objectClass.getMayList().length != 0 )
+        {
+            Attribute attr = new AttributeImpl( MetaSchemaConstants.M_MAY_AT );
+            AttributeType[] mayList = objectClass.getMayList();
+            for ( int ii = 0; ii < mayList.length; ii++ )
+            {
+                attr.add( getNameOrNumericoid( mayList[ii] ) );
+            }
+            entry.put( attr );
+        }
+        
+        return entry;
+    }
+
+    
+    private final String getNameOrNumericoid( SchemaObject object )
+    {
+        // first try to use userfriendly name if we can
+        if ( object.getName() != null )
+        {
+            return object.getName();
+        }
+        
+        return object.getOid();
+    }
+    
+    
+    private final void injectCommon( SchemaObject object, Attributes entry )
+    {
+        injectNames( object.getNames(), entry );
+        entry.put( MetaSchemaConstants.M_OBSOLETE_AT, getBoolean( object.isObsolete() ) );
+        entry.put( MetaSchemaConstants.M_OID_AT, object.getOid() );
+        
+        if ( object.getDescription() != null )
+        {
+            entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, object.getDescription() );
+        }
+    }
+    
+    
+    private final void injectNames( String[] names, Attributes entry )
+    {
+        if ( names == null || names.length == 0 )
+        {
+            return;
+        }
+        
+        Attribute attr = new AttributeImpl( MetaSchemaConstants.M_NAME_AT );
+        for ( int ii = 0; ii < names.length; ii++ )
+        {
+            attr.add( names[ii] );
+        }
+        entry.put( attr );
+    }
+
+    
+    private final String getBoolean( boolean value )
+    {
+        if ( value ) 
+        {
+            return "TRUE";
+        }
+        else
+        {
+            return "FALSE";
+        }
+    }
+}



Mime
View raw message