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 2009/11/17 18:34:49 UTC
svn commit: r881393 [1/3] - in
/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema:
./ normalizers/ registries/
Author: elecharny
Date: Tue Nov 17 17:34:44 2009
New Revision: 881393
URL: http://svn.apache.org/viewvc?rev=881393&view=rev
Log:
o Create updateXXX() methods for SchemaObject to be used when we initialize the schema (there is no check down on the readOnly flag in this case)
o Renamed the clone() method for SchemaObjects to copy() and refactored all those copy() methods.
o The corresponding classes are not anymore Cloneable
o Fixed the toString() method for the DescriptionUtils class
o Renamed the SchemaWrapper class to SchemaObjectWrapper
o All the SchemaObject Registry classes have a copy() method instead of a clone() method, and are not anymore Cloneable
o The same Registry classes now have a local oidRegistry to store the oids of each of their SchemaObjects
o Added a toString() method to all those Registry
Added:
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectWrapper.java
- copied, changed from r833624, directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaWrapper.java
Removed:
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaWrapper.java
Modified:
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/OidNormalizer.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultComparatorRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITContentRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultLdapSyntaxRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleUseRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNameFormRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNormalizerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchema.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchemaObjectRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSyntaxCheckerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableComparatorRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableDITContentRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableDITStructureRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableLdapSyntaxRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleUseRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNameFormRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNormalizerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableObjectClassRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableSyntaxCheckerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/OidRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Schema.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java Tue Nov 17 17:34:44 2009
@@ -272,7 +272,6 @@
// Register this AttributeType into the Descendant map
atRegistry.registerDescendants( this, this.getSuperior() );
-
}
}
@@ -480,6 +479,18 @@
/**
+ * Update the associated Superior AttributeType, even if the SchemaObject is readOnly
+ *
+ * @param superior The superior for this AttributeType
+ */
+ public void updateSuperior( AttributeType superior )
+ {
+ this.superior = superior;
+ this.superiorOid = superior.getOid();
+ }
+
+
+ /**
* Gets the Syntax for this AttributeType's values.
*
* @return the value syntax
@@ -549,6 +560,18 @@
/**
+ * Update the associated Syntax, even if the SchemaObject is readOnly
+ *
+ * @param syntax The Syntax for this AttributeType
+ */
+ public void updateSyntax( LdapSyntax syntax )
+ {
+ this.syntax = syntax;
+ this.syntaxOid = syntax.getOid();
+ }
+
+
+ /**
* Gets the MatchingRule for this AttributeType used for equality matching.
*
* @return the equality matching rule
@@ -618,6 +641,18 @@
/**
+ * Update the associated Equality MatchingRule, even if the SchemaObject is readOnly
+ *
+ * @param equality The Equality MR for this AttributeType
+ */
+ public void updateEquality( MatchingRule equality )
+ {
+ this.equality = equality;
+ this.equalityOid = equality.getOid();
+ }
+
+
+ /**
* Gets the MatchingRule for this AttributeType used for Ordering matching.
*
* @return the Ordering matching rule
@@ -687,6 +722,18 @@
/**
+ * Update the associated Ordering MatchingRule, even if the SchemaObject is readOnly
+ *
+ * @param ordering The Ordering MR for this AttributeType
+ */
+ public void updateOrdering( MatchingRule ordering )
+ {
+ this.ordering = ordering;
+ this.orderingOid = ordering.getOid();
+ }
+
+
+ /**
* Gets the MatchingRule for this AttributeType used for Substr matching.
*
* @return the Substr matching rule
@@ -756,6 +803,18 @@
/**
+ * Update the associated Substring MatchingRule, even if the SchemaObject is readOnly
+ *
+ * @param substring The Substr MR for this AttributeType
+ */
+ public void updateSubstring( MatchingRule substring )
+ {
+ this.substring = substring;
+ this.substringOid = substring.getOid();
+ }
+
+
+ /**
* Checks to see if this AttributeType is the ancestor of another
* attributeType.
*
@@ -826,19 +885,50 @@
/**
- * Clone an AttributeType
+ * Copy an AttributeType
*/
- public AttributeType clone() throws CloneNotSupportedException
+ public AttributeType copy()
{
- AttributeType clone = (AttributeType)super.clone();
+ AttributeType copy = new AttributeType( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
+
+ // Copy the canUserModify flag
+ copy.canUserModify = canUserModify;
+
+ // Copy the isCollective flag
+ copy.isCollective = isCollective;
+
+ // Copy the isSingleValue flag
+ copy.isSingleValued = isSingleValued;
+
+ // Copy the USAGE type
+ copy.usage = usage;
+
+ // All the references to other Registries object are set to null,
+ // all the OIDs are copied
+ // The EQUALITY MR
+ copy.equality = null;
+ copy.equalityOid = equalityOid;
+
+ // The ORDERING MR
+ copy.ordering = null;
+ copy.orderingOid = orderingOid;
+
+ // The SUBSTR MR
+ copy.substring = null;
+ copy.substringOid = substringOid;
+
+ // The SUP AT
+ copy.superior = null;
+ copy.superiorOid = superiorOid;
- // All the references to other Registries object are set to null.
- clone.equality = null;
- clone.ordering = null;
- clone.substring = null;
- clone.superior = null;
- clone.syntax = null;
+ // The SYNTAX
+ copy.syntax = null;
+ copy.syntaxOid = syntaxOid;
+ copy.syntaxLength = syntaxLength;
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java Tue Nov 17 17:34:44 2009
@@ -566,53 +566,59 @@
/**
- * Clone a DITContentRule
+ * Copy a DITContentRule
*/
- public DITContentRule clone() throws CloneNotSupportedException
+ public DITContentRule copy()
{
- DITContentRule clone = (DITContentRule)super.clone();
+ DITContentRule copy = new DITContentRule( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
- // Clone the AUX ObjectClasses
- clone.auxObjectClassOids = new ArrayList<String>();
+ // copy the AUX ObjectClasses OIDs
+ copy.auxObjectClassOids = new ArrayList<String>();
for ( String oid : auxObjectClassOids )
{
- clone.auxObjectClassOids.add( oid );
+ copy.auxObjectClassOids.add( oid );
}
- clone.auxObjectClasses = new ArrayList<ObjectClass>();
+ // copy the AUX ObjectClasses ( will be empty )
+ copy.auxObjectClasses = new ArrayList<ObjectClass>();
- // Clone the MAY AttributeTypes
- clone.mayAttributeTypeOids = new ArrayList<String>();
+ // Clone the MAY AttributeTypes OIDs
+ copy.mayAttributeTypeOids = new ArrayList<String>();
for ( String oid : mayAttributeTypeOids )
{
- clone.mayAttributeTypeOids.add( oid );
+ copy.mayAttributeTypeOids.add( oid );
}
- clone.mayAttributeTypes = new ArrayList<AttributeType>();
+ // Clone the MAY AttributeTypes ( will be empty )
+ copy.mayAttributeTypes = new ArrayList<AttributeType>();
- // Clone the MUST AttributeTypes
- clone.mustAttributeTypeOids = new ArrayList<String>();
+ // Clone the MUST AttributeTypes OIDs
+ copy.mustAttributeTypeOids = new ArrayList<String>();
for ( String oid : mustAttributeTypeOids )
{
- clone.mustAttributeTypeOids.add( oid );
+ copy.mustAttributeTypeOids.add( oid );
}
- clone.mustAttributeTypes = new ArrayList<AttributeType>();
+ // Clone the MUST AttributeTypes ( will be empty )
+ copy.mustAttributeTypes = new ArrayList<AttributeType>();
- // Clone the NOT AttributeTypes
- clone.notAttributeTypeOids = new ArrayList<String>();
+ // Clone the NOT AttributeTypes OIDs
+ copy.notAttributeTypeOids = new ArrayList<String>();
for ( String oid : notAttributeTypeOids )
{
- clone.notAttributeTypeOids.add( oid );
+ copy.notAttributeTypeOids.add( oid );
}
- clone.notAttributeTypes = new ArrayList<AttributeType>();
-
+ // Clone the NOT AttributeTypes ( will be empty )
+ copy.notAttributeTypes = new ArrayList<AttributeType>();
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java Tue Nov 17 17:34:44 2009
@@ -205,20 +205,26 @@
/**
- * Clone a DITStructureRule
+ * Copy a DITStructureRule
*/
- public DITStructureRule clone() throws CloneNotSupportedException
+ public DITStructureRule copy()
{
- DITStructureRule clone = (DITStructureRule)super.clone();
+ DITStructureRule copy = new DITStructureRule( ruleId );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
+
+ // Copy the Superiors rules
+ copy.superRules = new ArrayList<Integer>();
- // Clone the Superiors rules
- clone.superRules = new ArrayList<Integer>();
+ // Copy the form
+ copy.form = form;
for ( int ruleId : superRules )
{
- clone.superRules.add( ruleId );
+ copy.superRules.add( ruleId );
}
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java Tue Nov 17 17:34:44 2009
@@ -103,7 +103,7 @@
if ( attributeType.getSuperior() != null )
{
- buf.append( " SUP " );
+ buf.append( " SUP " );
buf.append( attributeType.getSuperiorName() );
buf.append( '\n' );
}
@@ -684,7 +684,7 @@
if ( ( sups != null ) && ( sups.size() > 0 ) )
{
- buf.append( " SUP\n" );
+ buf.append( " SUP " );
getQDStrings( buf, sups );
}
@@ -699,7 +699,7 @@
if ( ( must != null ) && ( must.size() > 0 ) )
{
- buf.append( " MUST\n" );
+ buf.append( " MUST " );
getQDStrings( buf, must );
}
@@ -707,7 +707,7 @@
if ( ( may != null ) && ( may.size() > 0 ) )
{
- buf.append( " MAY\n" );
+ buf.append( " MAY " );
getQDStrings( buf, may );
}
@@ -717,6 +717,7 @@
}
buf.append( " )\n" );
+
return buf.toString();
}
@@ -860,7 +861,7 @@
}
}
- sb.append( '\n' );
+ sb.append( '\n' );
}
@@ -895,7 +896,7 @@
}
}
- sb.append( '\n' );
+ sb.append( '\n' );
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapComparator.java Tue Nov 17 17:34:44 2009
@@ -55,17 +55,6 @@
/**
- * Clone a LdapComparator
- */
- public LdapComparator<T> clone() throws CloneNotSupportedException
- {
- LdapComparator<T> clone = (LdapComparator<T>)super.clone();
-
- return clone;
- }
-
-
- /**
* @see Object#toString()
*/
public String toString()
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java Tue Nov 17 17:34:44 2009
@@ -165,6 +165,17 @@
this.syntaxChecker = syntaxChecker;
}
}
+
+
+ /**
+ * Update the associated SyntaxChecker, even if the SchemaObject is readOnly
+ *
+ * @param syntaxChecker The associated SyntaxChecker
+ */
+ public void updateSyntaxChecker( SyntaxChecker syntaxChecker )
+ {
+ this.syntaxChecker = syntaxChecker;
+ }
/**
@@ -201,15 +212,21 @@
/**
- * Clone a LdapSyntax
+ * Copy a LdapSyntax
*/
- public LdapSyntax clone() throws CloneNotSupportedException
+ public LdapSyntax copy()
{
- LdapSyntax clone = (LdapSyntax)super.clone();
+ LdapSyntax copy = new LdapSyntax( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
+
+ // Copy the HR flag
+ copy.isHumanReadable = isHumanReadable;
// All the references to other Registries object are set to null.
- clone.syntaxChecker = null;
+ copy.syntaxChecker = null;
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java Tue Nov 17 17:34:44 2009
@@ -111,15 +111,10 @@
this.fqcn = fqcn;
}
}
-
-
- /**
- * Clone a LoadableSchemaObject
- */
- public LoadableSchemaObject clone() throws CloneNotSupportedException
+
+
+ public LoadableSchemaObject copy()
{
- LoadableSchemaObject clone = (LoadableSchemaObject)super.clone();
-
- return clone;
+ return null;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java Tue Nov 17 17:34:44 2009
@@ -209,6 +209,18 @@
/**
+ * Update the associated Syntax, even if the SchemaObject is readOnly
+ *
+ * @param oid The Syntax
+ */
+ public void updateSyntax( LdapSyntax ldapSyntax )
+ {
+ this.ldapSyntax = ldapSyntax;
+ this.ldapSyntaxOid = ldapSyntax.getOid();
+ }
+
+
+ /**
* Gets the LdapComparator enabling the use of this MatchingRule for ORDERING
* and sorted indexing.
*
@@ -236,6 +248,17 @@
/**
+ * Update the associated Comparator, even if the SchemaObject is readOnly
+ *
+ * @param oid The LdapComparator
+ */
+ public void updateLdapComparator( LdapComparator<?> ldapComparator )
+ {
+ this.ldapComparator = (LdapComparator<? super Object>)ldapComparator;
+ }
+
+
+ /**
* Gets the Normalizer enabling the use of this MatchingRule for EQUALITY
* matching and indexing.
*
@@ -260,6 +283,19 @@
this.normalizer = normalizer;
}
}
+
+
+ /**
+ * Update the associated Normalizer, even if the SchemaObject is readOnly
+ *
+ * @param oid The Normalizer
+ */
+ public void updateNormalizer( Normalizer normalizer )
+ {
+ this.normalizer = normalizer;
+ }
+
+
/**
* @see Object#toString()
*/
@@ -270,17 +306,23 @@
/**
- * Clone an MatchingRule
+ * Copy an MatchingRule
*/
- public MatchingRule clone() throws CloneNotSupportedException
+ public MatchingRule copy()
{
- MatchingRule clone = (MatchingRule)super.clone();
-
+ MatchingRule copy = new MatchingRule( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
+
// All the references to other Registries object are set to null.
- clone.ldapComparator = null;
- clone.ldapSyntax = null;
- clone.normalizer = null;
+ copy.ldapComparator = null;
+ copy.ldapSyntax = null;
+ copy.normalizer = null;
+
+ // Copy the syntax OID
+ copy.ldapSyntaxOid = ldapSyntaxOid;
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java Tue Nov 17 17:34:44 2009
@@ -232,23 +232,27 @@
/**
- * Clone an MatchingRuleUse
+ * Copy an MatchingRuleUse
*/
- public MatchingRuleUse clone() throws CloneNotSupportedException
+ public MatchingRuleUse copy()
{
- MatchingRuleUse clone = (MatchingRuleUse)super.clone();
+ MatchingRuleUse copy = new MatchingRuleUse( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
// Clone the APPLY AttributeTypes
- clone.applicableAttributeOids = new ArrayList<String>();
+ copy.applicableAttributeOids = new ArrayList<String>();
+ // Copy the APPLIES oid list
for ( String oid : applicableAttributeOids )
{
- clone.applicableAttributeOids.add( oid );
+ copy.applicableAttributeOids.add( oid );
}
- clone.applicableAttributes = new ArrayList<AttributeType>();
+ // Copy the APPLIES list (will be empty)
+ copy.applicableAttributes = new ArrayList<AttributeType>();
-
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java Tue Nov 17 17:34:44 2009
@@ -428,35 +428,43 @@
/**
- * Clone a NameForm
+ * Copy a NameForm
*/
- public NameForm clone() throws CloneNotSupportedException
+ public NameForm copy()
{
- NameForm clone = (NameForm)super.clone();
+ NameForm copy = new NameForm( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
- // Clone the MAY AttributeTypes
- clone.mayAttributeTypeOids = new ArrayList<String>();
+ // Copy the MAY AttributeTypes OIDs
+ copy.mayAttributeTypeOids = new ArrayList<String>();
for ( String oid : mayAttributeTypeOids )
{
- clone.mayAttributeTypeOids.add( oid );
+ copy.mayAttributeTypeOids.add( oid );
}
- clone.mayAttributeTypes = new ArrayList<AttributeType>();
+ // Copy the MAY AttributeTypes (will be empty)
+ copy.mayAttributeTypes = new ArrayList<AttributeType>();
- // Clone the MUST AttributeTypes
- clone.mustAttributeTypeOids = new ArrayList<String>();
+ // Copy the MUST AttributeTypes OIDs
+ copy.mustAttributeTypeOids = new ArrayList<String>();
for ( String oid : mustAttributeTypeOids )
{
- clone.mustAttributeTypeOids.add( oid );
+ copy.mustAttributeTypeOids.add( oid );
}
- clone.mustAttributeTypes = new ArrayList<AttributeType>();
+ // Copy the MUST AttributeTypes ( will be empty )
+ copy.mustAttributeTypes = new ArrayList<AttributeType>();
+ // Copy the Structural ObjectClass OID
+ copy.structuralObjectClassOid = structuralObjectClassOid;
+
// All the references to other Registries object are set to null.
- clone.structuralObjectClass = null;
+ copy.structuralObjectClass = null;
- return clone;
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java Tue Nov 17 17:34:44 2009
@@ -90,17 +90,6 @@
/**
- * Clone a Normalizer
- */
- public Normalizer clone() throws CloneNotSupportedException
- {
- Normalizer clone = (Normalizer)super.clone();
-
- return clone;
- }
-
-
- /**
* @see Object#toString()
*/
public String toString()
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java Tue Nov 17 17:34:44 2009
@@ -140,11 +140,6 @@
for ( String superiorName : superiorOids )
{
- if ( superiorName.equals( "top" ) )
- {
- continue;
- }
-
superiors.add( ocRegistry.lookup( ocRegistry.getOidByName( superiorName ) ) );
}
}
@@ -254,6 +249,26 @@
}
}
}
+
+
+ /**
+ * Update the associated MAY AttributeType, even if the SchemaObject is readOnly
+ *
+ * @param mayAttributeTypes the list of allowed AttributeTypes
+ */
+ public void updateMayAttributeTypes( List<AttributeType> mayAttributeTypes )
+ {
+ this.mayAttributeTypes.clear();
+ this.mayAttributeTypes.addAll( mayAttributeTypes );
+
+ // update the OIDS now
+ mayAttributeTypeOids.clear();
+
+ for ( AttributeType may : mayAttributeTypes )
+ {
+ mayAttributeTypeOids.add( may.getOid() );
+ }
+ }
/**
@@ -341,6 +356,26 @@
/**
+ * Update the associated MUST AttributeType, even if the SchemaObject is readOnly
+ *
+ * @param mayAttributeTypes the list of allowed AttributeTypes
+ */
+ public void updateMustAttributeTypes( List<AttributeType> mustAttributeTypes )
+ {
+ this.mustAttributeTypes.clear();
+ this.mustAttributeTypes.addAll( mustAttributeTypes );
+
+ // update the OIDS now
+ mustAttributeTypeOids.clear();
+
+ for ( AttributeType must : mustAttributeTypes )
+ {
+ mustAttributeTypeOids.add( must.getOid() );
+ }
+ }
+
+
+ /**
* Gets the superclasses of this ObjectClass.
*
* @return the superclasses
@@ -427,6 +462,26 @@
/**
+ * Update the associated SUPERIORS ObjectClasses, even if the SchemaObject is readOnly
+ *
+ * @param superiors the object classes to set
+ */
+ public void updateSuperiors( List<ObjectClass> superiors )
+ {
+ this.superiors.clear();
+ this.superiors.addAll( superiors );
+
+ // update the OIDS now
+ superiorOids.clear();
+
+ for ( ObjectClass oc : superiors )
+ {
+ superiorOids.add( oc.getOid() );
+ }
+ }
+
+
+ /**
* Sets the superior object class OIDs
*
* @param superiorOids the object class OIDs to set
@@ -508,42 +563,51 @@
/**
- * Clone an ObjectClass
+ * Copy an ObjectClass
*/
- public ObjectClass clone() throws CloneNotSupportedException
+ public ObjectClass copy()
{
- ObjectClass clone = (ObjectClass)super.clone();
+ ObjectClass copy = new ObjectClass( oid );
+
+ // Copy the SchemaObject common data
+ copy.copy( this );
+
+ // Copy the ObjectClass type
+ copy.objectClassType = objectClassType;
- // Clone the Superiors ObjectClasses
- clone.superiorOids = new ArrayList<String>();
+ // Copy the Superiors ObjectClasses OIDs
+ copy.superiorOids = new ArrayList<String>();
for ( String oid : superiorOids )
{
- clone.superiorOids.add( oid );
+ copy.superiorOids.add( oid );
}
- clone.superiors = new ArrayList<ObjectClass>();
+ // Copy the Superiors ObjectClasses ( will be empty )
+ copy.superiors = new ArrayList<ObjectClass>();
- // Clone the MAY AttributeTypes
- clone.mayAttributeTypeOids = new ArrayList<String>();
+ // Copy the MAY AttributeTypes OIDs
+ copy.mayAttributeTypeOids = new ArrayList<String>();
for ( String oid : mayAttributeTypeOids )
{
- clone.mayAttributeTypeOids.add( oid );
+ copy.mayAttributeTypeOids.add( oid );
}
- clone.mayAttributeTypes = new ArrayList<AttributeType>();
+ // Copy the MAY AttributeTypes ( will be empty )
+ copy.mayAttributeTypes = new ArrayList<AttributeType>();
- // Clone the MUST AttributeTypes
- clone.mustAttributeTypeOids = new ArrayList<String>();
+ // Copy the MUST AttributeTypes OIDs
+ copy.mustAttributeTypeOids = new ArrayList<String>();
for ( String oid : mustAttributeTypeOids )
{
- clone.mustAttributeTypeOids.add( oid );
+ copy.mustAttributeTypeOids.add( oid );
}
- clone.mustAttributeTypes = new ArrayList<AttributeType>();
+ // Copy the MUST AttributeTypes ( will be empty )
+ copy.mustAttributeTypes = new ArrayList<AttributeType>();
- return clone;
+ return copy;
}
}
\ No newline at end of file
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java Tue Nov 17 17:34:44 2009
@@ -71,7 +71,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class SchemaObject implements Serializable, Cloneable
+public abstract class SchemaObject implements Serializable
{
/** The serialVersionUID */
public static final long serialVersionUID = 1L;
@@ -709,28 +709,39 @@
return false;
}
+
+ public abstract SchemaObject copy();
+
/**
- * Clone a SchemaObject
+ * Copy a SchemaObject.
+ *
+ * @return A copy of the current SchemaObject
*/
- public SchemaObject clone() throws CloneNotSupportedException
+ public SchemaObject copy( SchemaObject original )
{
- SchemaObject clone = (SchemaObject)super.clone();
+ // copy the description
+ description = original.description;
+
+ // copy the flags
+ isEnabled = original.isEnabled;
+ isObsolete = original.isObsolete;
+ isReadOnly = original.isReadOnly;
- //Clone the names
- clone.names = new ArrayList<String>();
+ // copy the names
+ names = new ArrayList<String>();
- for ( String name : names )
+ for ( String name : original.names )
{
- clone.names.add( name );
+ names.add( name );
}
- // Clone the extensions
- clone.extensions = new HashMap<String, List<String>>();
+ // copy the extensions
+ extensions = new HashMap<String, List<String>>();
- for ( String key : extensions.keySet() )
+ for ( String key : original.extensions.keySet() )
{
- List<String> extensionValues = extensions.get( key );
+ List<String> extensionValues = original.extensions.get( key );
List<String> cloneExtension = new ArrayList<String>();
@@ -739,10 +750,19 @@
cloneExtension.add( value );
}
- clone.extensions.put( key, cloneExtension );
+ extensions.put( key, cloneExtension );
}
- return clone;
+ // The SchemaName
+ schemaName = original.schemaName;
+
+ // The SchemaManager
+ schemaManager = original.schemaManager;
+
+ // The specification
+ specification = original.specification;
+
+ return this;
}
Copied: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectWrapper.java (from r833624, directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaWrapper.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectWrapper.java?p2=directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectWrapper.java&p1=directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaWrapper.java&r1=833624&r2=881393&rev=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaWrapper.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObjectWrapper.java Tue Nov 17 17:34:44 2009
@@ -28,18 +28,18 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class SchemaWrapper
+public class SchemaObjectWrapper
{
/** The internal schemaObject */
private SchemaObject schemaObject;
/**
- * Creates a new instance of SchemaWrapper.
+ * Creates a new instance of SchemaObjectWrapper.
*
* @param schemaObject The contained SchemaObject
*/
- public SchemaWrapper( SchemaObject schemaObject )
+ public SchemaObjectWrapper( SchemaObject schemaObject )
{
this.schemaObject = schemaObject;
}
@@ -68,12 +68,12 @@
return true;
}
- if ( !(o instanceof SchemaWrapper ) )
+ if ( !(o instanceof SchemaObjectWrapper ) )
{
return false;
}
- SchemaObject that = ((SchemaWrapper)o).get();
+ SchemaObject that = ((SchemaObjectWrapper)o).get();
SchemaObject current = get();
return ( that.getOid().equals( current.getOid() ) &&
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SyntaxChecker.java Tue Nov 17 17:34:44 2009
@@ -85,17 +85,6 @@
/**
- * Clone a SyntaxChecker
- */
- public SyntaxChecker clone() throws CloneNotSupportedException
- {
- SyntaxChecker clone = (SyntaxChecker)super.clone();
-
- return clone;
- }
-
-
- /**
* @see Object#toString()
*/
public String toString()
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/OidNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/OidNormalizer.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/OidNormalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/OidNormalizer.java Tue Nov 17 17:34:44 2009
@@ -83,6 +83,22 @@
{
return attributeTypeOid;
}
+
+
+ /**
+ * Copy an OidNormalizer(). The contained Normalizer will be cloned too.
+ *
+ * @return A deep clone of the current OidNormalizer
+ */
+ public OidNormalizer copy() throws CloneNotSupportedException
+ {
+ OidNormalizer copy = new OidNormalizer( attributeTypeOid, normalizer );
+
+ // Copy the SchemaObject common data
+ copy.copy();
+
+ return copy;
+ }
/**
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistry.java Tue Nov 17 17:34:44 2009
@@ -36,7 +36,7 @@
* @version $Rev$
*/
public interface AttributeTypeRegistry extends SchemaObjectRegistry<AttributeType>,
- Iterable<AttributeType>, Cloneable
+ Iterable<AttributeType>
{
/**
* Gets an oid/name to normalizer mapping used to normalize distinguished
@@ -79,7 +79,7 @@
* @param attributeType The attributeType to register
* @throws NamingException If something went wrong
*/
- public void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException;
+ void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException;
/**
@@ -96,5 +96,11 @@
/**
* Add a new Oid/Normalizer couple in the OidNormalizer map
*/
- public void addMappingFor( AttributeType attributeType ) throws NamingException;
+ void addMappingFor( AttributeType attributeType ) throws NamingException;
+
+
+ /**
+ * Copy the AttributeTypeRegistry
+ */
+ AttributeTypeRegistry copy();
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java Tue Nov 17 17:34:44 2009
@@ -32,7 +32,7 @@
* @version $Rev$
*/
public interface ComparatorRegistry extends SchemaObjectRegistry<LdapComparator<?>>,
- Iterable<LdapComparator<?>>, Cloneable
+ Iterable<LdapComparator<?>>
{
/**
* Registers a new LdapComparator with this registry.
@@ -64,13 +64,7 @@
/**
- * Clone the ComparatorRegistry
+ * Copy the ComparatorRegistry
*/
- ComparatorRegistry clone() throws CloneNotSupportedException;
-
-
- /**
- * @return The number of Comparators stored
- */
- int size();
+ ComparatorRegistry copy();
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java Tue Nov 17 17:34:44 2009
@@ -30,16 +30,10 @@
* @version $Rev$
*/
public interface DITContentRuleRegistry extends SchemaObjectRegistry<DITContentRule>,
- Iterable<DITContentRule>, Cloneable
+ Iterable<DITContentRule>
{
/**
- * Clone the DITContentRuleRegistry
+ * Copy the DITContentRuleRegistry
*/
- DITContentRuleRegistry clone() throws CloneNotSupportedException;
-
-
- /**
- * @return The number of DITContentRule stored
- */
- int size();
+ DITContentRuleRegistry copy();
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java Tue Nov 17 17:34:44 2009
@@ -34,7 +34,7 @@
* @version $Rev$
*/
public interface DITStructureRuleRegistry extends SchemaObjectRegistry<DITStructureRule>,
- Iterable<DITStructureRule>, Cloneable
+ Iterable<DITStructureRule>
{
/**
* Checks to see if an DITStructureRule exists in the registry, by its
@@ -124,13 +124,7 @@
/**
- * Clone the DITStructureRuleRegistry
+ * Copy the DITStructureRuleRegistry
*/
- DITStructureRuleRegistry clone() throws CloneNotSupportedException;
-
-
- /**
- * @return The number of DITStructureRule stored
- */
- int size();
+ DITStructureRuleRegistry copy();
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultAttributeTypeRegistry.java Tue Nov 17 17:34:44 2009
@@ -64,12 +64,10 @@
/**
* Creates a new default AttributeTypeRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultAttributeTypeRegistry( OidRegistry oidRegistry )
+ public DefaultAttributeTypeRegistry()
{
- super( SchemaObjectType.ATTRIBUTE_TYPE, oidRegistry );
+ super( SchemaObjectType.ATTRIBUTE_TYPE, new OidRegistry() );
oidNormalizerMap = new HashMap<String, OidNormalizer>();
oidToDescendantSet = new HashMap<String,Set<AttributeType>>();
}
@@ -256,18 +254,18 @@
*/
public void addMappingFor( AttributeType attributeType ) throws NamingException
{
- MatchingRule matchingRule = attributeType.getEquality();
+ MatchingRule equality = attributeType.getEquality();
OidNormalizer oidNormalizer;
String oid = attributeType.getOid();
- if ( matchingRule == null )
+ if ( equality == null )
{
LOG.debug( "Attribute {} does not have normalizer : using NoopNormalizer", attributeType.getName() );
oidNormalizer = new OidNormalizer( oid, new NoOpNormalizer( attributeType.getOid() ) );
}
else
{
- oidNormalizer = new OidNormalizer( oid, matchingRule.getNormalizer() );
+ oidNormalizer = new OidNormalizer( oid, equality.getNormalizer() );
}
oidNormalizerMap.put( oid, oidNormalizer );
@@ -319,25 +317,13 @@
/**
* {@inheritDoc}
*/
- public DefaultAttributeTypeRegistry clone() throws CloneNotSupportedException
+ public AttributeTypeRegistry copy()
{
- DefaultAttributeTypeRegistry clone = (DefaultAttributeTypeRegistry)super.clone();
+ DefaultAttributeTypeRegistry copy = new DefaultAttributeTypeRegistry();
- // Clone the oidNormalizerMap (will be empty)
- clone.oidNormalizerMap = new HashMap<String, OidNormalizer>();
+ // Copy the base data
+ copy.copy( this );
- // Clone the oidToDescendant map (will be empty)
- clone.oidToDescendantSet = new HashMap<String,Set<AttributeType>>();
-
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultComparatorRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultComparatorRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultComparatorRegistry.java Tue Nov 17 17:34:44 2009
@@ -48,12 +48,10 @@
/**
* Creates a new default ComparatorRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultComparatorRegistry( OidRegistry oidRegistry )
+ public DefaultComparatorRegistry()
{
- super( SchemaObjectType.COMPARATOR, oidRegistry );
+ super( SchemaObjectType.COMPARATOR, new OidRegistry() );
}
@@ -66,7 +64,7 @@
if ( byName.containsKey( oid ) )
{
- String msg = type.name() + " with OID " + oid + " already registered!";
+ String msg = schemaObjectType.name() + " with OID " + oid + " already registered!";
LOG.warn( msg );
throw new NamingException( msg );
}
@@ -82,6 +80,9 @@
byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), comparator );
}
+ // Update the ComparatorRegistry OidRegistry
+ oidRegistry.register( comparator );
+
if ( LOG.isDebugEnabled() )
{
LOG.debug( "registered " + comparator.getName() + " for OID {}", oid );
@@ -148,19 +149,58 @@
/**
* {@inheritDoc}
*/
- public DefaultComparatorRegistry clone() throws CloneNotSupportedException
+ public DefaultComparatorRegistry copy()
{
- DefaultComparatorRegistry clone = (DefaultComparatorRegistry)super.clone();
+ DefaultComparatorRegistry copy = new DefaultComparatorRegistry();
+
+ // Copy the base data
+ copy.copy( this );
- return clone;
+ return copy;
}
/**
- * {@inheritDoc}
+ * @see Object#toString()
*/
- public int size()
+ public String toString()
{
- return byName.values().size();
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( schemaObjectType ).append( ": " );
+ boolean isFirst = true;
+
+ for ( String name : byName.keySet() )
+ {
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ sb.append( ", " );
+ }
+
+ LdapComparator<?> comparator = byName.get( name );
+
+ String fqcn = comparator.getFqcn();
+ int lastDotPos = fqcn.lastIndexOf( '.' );
+
+ sb.append( '<' ).append( comparator.getOid() ).append( ", " );
+
+
+ if ( lastDotPos > 0 )
+ {
+ sb.append( fqcn.substring( lastDotPos + 1 ) );
+ }
+ else
+ {
+ sb.append( fqcn );
+ }
+
+ sb.append( '>' );
+ }
+
+ return sb.toString();
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITContentRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITContentRuleRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITContentRuleRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITContentRuleRegistry.java Tue Nov 17 17:34:44 2009
@@ -35,31 +35,23 @@
{
/**
* Creates a new default DITContentRuleRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultDITContentRuleRegistry( OidRegistry oidRegistry )
+ public DefaultDITContentRuleRegistry()
{
- super( SchemaObjectType.DIT_CONTENT_RULE, oidRegistry );
+ super( SchemaObjectType.DIT_CONTENT_RULE, new OidRegistry() );
}
/**
* {@inheritDoc}
*/
- public DefaultDITContentRuleRegistry clone() throws CloneNotSupportedException
+ public DefaultDITContentRuleRegistry copy()
{
- DefaultDITContentRuleRegistry clone = (DefaultDITContentRuleRegistry)super.clone();
+ DefaultDITContentRuleRegistry copy = new DefaultDITContentRuleRegistry();
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ // Copy the base data
+ copy.copy( this );
+
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultDITStructureRuleRegistry.java Tue Nov 17 17:34:44 2009
@@ -53,12 +53,10 @@
/**
* Creates a new default NormalizerRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultDITStructureRuleRegistry( OidRegistry oidRegistry )
+ public DefaultDITStructureRuleRegistry()
{
- super( SchemaObjectType.DIT_STRUCTURE_RULE, oidRegistry );
+ super( SchemaObjectType.DIT_STRUCTURE_RULE, new OidRegistry() );
byRuleId = new HashMap<Integer, DITStructureRule>();
}
@@ -221,22 +219,13 @@
/**
* {@inheritDoc}
*/
- public DefaultDITStructureRuleRegistry clone() throws CloneNotSupportedException
+ public DefaultDITStructureRuleRegistry copy()
{
- DefaultDITStructureRuleRegistry clone = (DefaultDITStructureRuleRegistry)super.clone();
+ DefaultDITStructureRuleRegistry copy = new DefaultDITStructureRuleRegistry();
- // Clone the RuleId map
- clone.byRuleId = new HashMap<Integer, DITStructureRule>();
+ // Copy the base data
+ copy.copy( this );
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return byRuleId.values().size();
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultLdapSyntaxRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultLdapSyntaxRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultLdapSyntaxRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultLdapSyntaxRegistry.java Tue Nov 17 17:34:44 2009
@@ -34,31 +34,23 @@
{
/**
* Creates a new default LdapSyntaxRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultLdapSyntaxRegistry( OidRegistry oidRegistry )
+ public DefaultLdapSyntaxRegistry()
{
- super( SchemaObjectType.LDAP_SYNTAX, oidRegistry );
+ super( SchemaObjectType.LDAP_SYNTAX, new OidRegistry() );
}
/**
* {@inheritDoc}
*/
- public DefaultLdapSyntaxRegistry clone() throws CloneNotSupportedException
+ public DefaultLdapSyntaxRegistry copy()
{
- DefaultLdapSyntaxRegistry clone = (DefaultLdapSyntaxRegistry)super.clone();
+ DefaultLdapSyntaxRegistry copy = new DefaultLdapSyntaxRegistry();
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ // Copy the base data
+ copy.copy( this );
+
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleRegistry.java Tue Nov 17 17:34:44 2009
@@ -35,31 +35,23 @@
{
/**
* Creates a new default MatchingRuleRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultMatchingRuleRegistry( OidRegistry oidRegistry )
+ public DefaultMatchingRuleRegistry()
{
- super( SchemaObjectType.MATCHING_RULE, oidRegistry );
+ super( SchemaObjectType.MATCHING_RULE, new OidRegistry() );
}
/**
* {@inheritDoc}
*/
- public DefaultMatchingRuleRegistry clone() throws CloneNotSupportedException
+ public DefaultMatchingRuleRegistry copy()
{
- DefaultMatchingRuleRegistry clone = (DefaultMatchingRuleRegistry)super.clone();
+ DefaultMatchingRuleRegistry copy = new DefaultMatchingRuleRegistry();
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ // Copy the base data
+ copy.copy( this );
+
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleUseRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleUseRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleUseRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultMatchingRuleUseRegistry.java Tue Nov 17 17:34:44 2009
@@ -38,31 +38,23 @@
{
/**
* Creates a new default MatchingRuleUseRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultMatchingRuleUseRegistry( OidRegistry oidRegistry )
+ public DefaultMatchingRuleUseRegistry()
{
- super( SchemaObjectType.MATCHING_RULE_USE, oidRegistry );
+ super( SchemaObjectType.MATCHING_RULE_USE, new OidRegistry() );
}
/**
* {@inheritDoc}
*/
- public DefaultMatchingRuleUseRegistry clone() throws CloneNotSupportedException
+ public DefaultMatchingRuleUseRegistry copy()
{
- DefaultMatchingRuleUseRegistry clone = (DefaultMatchingRuleUseRegistry)super.clone();
+ DefaultMatchingRuleUseRegistry copy = new DefaultMatchingRuleUseRegistry();
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ // Copy the base data
+ copy.copy( this );
+
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNameFormRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNameFormRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNameFormRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNameFormRegistry.java Tue Nov 17 17:34:44 2009
@@ -35,31 +35,23 @@
{
/**
* Creates a new default NameFormRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultNameFormRegistry( OidRegistry oidRegistry )
+ public DefaultNameFormRegistry()
{
- super( SchemaObjectType.NAME_FORM, oidRegistry );
+ super( SchemaObjectType.NAME_FORM, new OidRegistry() );
}
/**
* {@inheritDoc}
*/
- public DefaultNameFormRegistry clone() throws CloneNotSupportedException
+ public DefaultNameFormRegistry copy()
{
- DefaultNameFormRegistry clone = (DefaultNameFormRegistry)super.clone();
+ DefaultNameFormRegistry copy = new DefaultNameFormRegistry();
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ // Copy the base data
+ copy.copy( this );
+
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNormalizerRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNormalizerRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultNormalizerRegistry.java Tue Nov 17 17:34:44 2009
@@ -48,12 +48,10 @@
/**
* Creates a new default NormalizerRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultNormalizerRegistry( OidRegistry oidRegistry )
+ public DefaultNormalizerRegistry()
{
- super( SchemaObjectType.NORMALIZER, oidRegistry );
+ super( SchemaObjectType.NORMALIZER, new OidRegistry() );
}
@@ -66,7 +64,7 @@
if ( byName.containsKey( oid ) )
{
- String msg = type.name() + " with OID " + oid + " already registered!";
+ String msg = schemaObjectType.name() + " with OID " + oid + " already registered!";
LOG.warn( msg );
throw new NamingException( msg );
}
@@ -82,6 +80,9 @@
byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), normalizer );
}
+ // Update the NormalizerRegistry OidRegistry
+ oidRegistry.register( normalizer );
+
if ( LOG.isDebugEnabled() )
{
LOG.debug( "registered " + normalizer.getName() + " for OID {}", oid );
@@ -148,19 +149,58 @@
/**
* {@inheritDoc}
*/
- public DefaultNormalizerRegistry clone() throws CloneNotSupportedException
+ public DefaultNormalizerRegistry copy()
{
- DefaultNormalizerRegistry clone = (DefaultNormalizerRegistry)super.clone();
+ DefaultNormalizerRegistry copy = new DefaultNormalizerRegistry();
+
+ // Copy the base data
+ copy.copy( this );
- return clone;
+ return copy;
}
/**
- * {@inheritDoc}
+ * @see Object#toString()
*/
- public int size()
+ public String toString()
{
- return byName.values().size();
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( schemaObjectType ).append( ": " );
+ boolean isFirst = true;
+
+ for ( String name : byName.keySet() )
+ {
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ sb.append( ", " );
+ }
+
+ Normalizer normalizer = byName.get( name );
+
+ String fqcn = normalizer.getFqcn();
+ int lastDotPos = fqcn.lastIndexOf( '.' );
+
+ sb.append( '<' ).append( normalizer.getOid() ).append( ", " );
+
+
+ if ( lastDotPos > 0 )
+ {
+ sb.append( fqcn.substring( lastDotPos + 1 ) );
+ }
+ else
+ {
+ sb.append( fqcn );
+ }
+
+ sb.append( '>' );
+ }
+
+ return sb.toString();
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultObjectClassRegistry.java Tue Nov 17 17:34:44 2009
@@ -57,12 +57,10 @@
/**
* Creates a new default ObjectClassRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultObjectClassRegistry( OidRegistry oidRegistry )
+ public DefaultObjectClassRegistry()
{
- super( SchemaObjectType.OBJECT_CLASS, oidRegistry );
+ super( SchemaObjectType.OBJECT_CLASS, new OidRegistry() );
oidToDescendants = new HashMap<String,Set<ObjectClass>>();
}
@@ -199,9 +197,6 @@
{
super.register( objectClass );
- // Register this ObjectClass into the Descendant map
- registerDescendants( objectClass, objectClass.getSuperiors() );
-
// Internally associate the OID to the registered AttributeType
if ( IS_DEBUG )
{
@@ -244,22 +239,13 @@
/**
* {@inheritDoc}
*/
- public DefaultObjectClassRegistry clone() throws CloneNotSupportedException
+ public DefaultObjectClassRegistry copy()
{
- DefaultObjectClassRegistry clone = (DefaultObjectClassRegistry)super.clone();
+ DefaultObjectClassRegistry copy = new DefaultObjectClassRegistry();
- // Clone the oidToDescendantSet (will be empty)
- clone.oidToDescendants = new HashMap<String, Set<ObjectClass>>();
+ // Copy the base data
+ copy.copy( this );
- return clone;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int size()
- {
- return oidRegistry.size();
+ return copy;
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchema.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchema.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchema.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchema.java Tue Nov 17 17:34:44 2009
@@ -24,7 +24,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.directory.shared.ldap.schema.SchemaWrapper;
+import org.apache.directory.shared.ldap.schema.SchemaObjectWrapper;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -53,7 +53,7 @@
private String name;
/** The set of SchemaObjects declared in this schema */
- private Set<SchemaWrapper> content;
+ private Set<SchemaObjectWrapper> content;
/**
@@ -129,7 +129,7 @@
this.disabled = disabled;
- content = new HashSet<SchemaWrapper>();
+ content = new HashSet<SchemaObjectWrapper>();
}
@@ -201,7 +201,7 @@
/**
* {@inheritDoc}
*/
- public Set<SchemaWrapper> getContent()
+ public Set<SchemaObjectWrapper> getContent()
{
return content;
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchemaObjectRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchemaObjectRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSchemaObjectRegistry.java Tue Nov 17 17:34:44 2009
@@ -27,6 +27,7 @@
import javax.naming.NamingException;
import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.schema.LoadableSchemaObject;
import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.shared.ldap.schema.SchemaObjectType;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -40,7 +41,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class DefaultSchemaObjectRegistry<T extends SchemaObject> implements SchemaObjectRegistry<T>, Iterable<T>, Cloneable
+public abstract class DefaultSchemaObjectRegistry<T extends SchemaObject> implements SchemaObjectRegistry<T>, Iterable<T>
{
/** static class logger */
private static final Logger LOG = LoggerFactory.getLogger( DefaultSchemaObjectRegistry.class );
@@ -51,8 +52,8 @@
/** a map of SchemaObject looked up by name */
protected Map<String, T> byName;
- /** The SchemaObject type */
- protected SchemaObjectType type;
+ /** The SchemaObject type, used by the toString() method */
+ protected SchemaObjectType schemaObjectType;
/** the global OID Registry */
protected OidRegistry oidRegistry;
@@ -64,7 +65,7 @@
protected DefaultSchemaObjectRegistry( SchemaObjectType schemaObjectType, OidRegistry oidRegistry )
{
byName = new HashMap<String, T>();
- type = schemaObjectType;
+ this.schemaObjectType = schemaObjectType;
this.oidRegistry = oidRegistry;
}
@@ -168,7 +169,7 @@
if ( schemaObject == null )
{
- String msg = type.name() + " for OID " + oid + " does not exist!";
+ String msg = schemaObjectType.name() + " for OID " + oid + " does not exist!";
LOG.debug( msg );
throw new NamingException( msg );
}
@@ -193,7 +194,7 @@
{
if ( byName.containsKey( oid ) )
{
- String msg = type.name() + " with OID " + oid + " already registered!";
+ String msg = schemaObjectType.name() + " with OID " + oid + " already registered!";
LOG.warn( msg );
throw new NamingException( msg );
}
@@ -269,7 +270,6 @@
{
String oid = schemaObject.getOid();
SchemaObject removed = unregister( oid );
- oidRegistry.unregister( oid );
if ( DEBUG )
{
@@ -324,34 +324,63 @@
/**
* {@inheritDoc}
*/
- public DefaultSchemaObjectRegistry<T> clone() throws CloneNotSupportedException
+ public SchemaObjectRegistry<T> copy( SchemaObjectRegistry<T> original )
{
- // Clone the base object
- DefaultSchemaObjectRegistry<T> clone = (DefaultSchemaObjectRegistry<T>)super.clone();
-
- // Clone the byName Map
- clone.byName = new HashMap<String, T>();
-
- for ( String key : byName.keySet() )
+ // Fill the byName and OidRegistry maps, the type has already be copied
+ for ( String key : ((DefaultSchemaObjectRegistry<T>)original).byName.keySet() )
{
// Clone each SchemaObject
- SchemaObject value = byName.get( key );
- clone.byName.put( key, (T)value.clone() );
+ T value = ((DefaultSchemaObjectRegistry<T>)original).byName.get( key );
+
+ if ( value instanceof LoadableSchemaObject )
+ {
+ // Update the data structure.
+ // Comparators, Normalizers and SyntaxCheckers aren't copied,
+ // they are immutable
+ byName.put( key, value );
+
+ // Update the OidRegistry
+ oidRegistry.put( value );
+ }
+ else
+ {
+ // Copy the value
+ T copiedValue = (T)value.copy();
+
+ // Update the data structure.
+ byName.put( key, copiedValue );
+
+ // Update the OidRegistry
+ oidRegistry.put( copiedValue );
+ }
}
- // Clone the oidRegistry
- clone.oidRegistry = oidRegistry.clone();
-
- return clone;
+ return this;
}
/**
* {@inheritDoc}
*/
+ public SchemaObject get( String oid )
+ {
+ try
+ {
+ return oidRegistry.getSchemaObject( oid );
+ }
+ catch ( NamingException ne )
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public SchemaObjectType getType()
{
- return type;
+ return schemaObjectType;
}
@@ -360,7 +389,7 @@
*/
public int size()
{
- return 0;
+ return oidRegistry.size();
}
@@ -371,8 +400,25 @@
{
StringBuilder sb = new StringBuilder();
- sb.append( type ).append( ':' );
- sb.append( StringTools.setToString( byName.keySet() ) );
+ sb.append( schemaObjectType ).append( ": " );
+ boolean isFirst = true;
+
+ for ( String name : byName.keySet() )
+ {
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ sb.append( ", " );
+ }
+
+ T schemaObject = byName.get( name );
+
+ sb.append( '<' ).append( name ).append( ", " ).append( schemaObject.getOid() ).append( '>' );
+ }
+
return sb.toString();
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSyntaxCheckerRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSyntaxCheckerRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DefaultSyntaxCheckerRegistry.java Tue Nov 17 17:34:44 2009
@@ -48,12 +48,10 @@
/**
* Creates a new default SyntaxCheckerRegistry instance.
- *
- * @param oidRegistry The global OID registry
*/
- public DefaultSyntaxCheckerRegistry( OidRegistry oidRegistry )
+ public DefaultSyntaxCheckerRegistry()
{
- super( SchemaObjectType.SYNTAX_CHECKER, oidRegistry );
+ super( SchemaObjectType.SYNTAX_CHECKER, new OidRegistry() );
}
@@ -66,7 +64,7 @@
if ( byName.containsKey( oid ) )
{
- String msg = type.name() + " with OID " + oid + " already registered!";
+ String msg = schemaObjectType.name() + " with OID " + oid + " already registered!";
LOG.warn( msg );
//throw new NamingException( msg );
}
@@ -82,6 +80,9 @@
byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), syntaxChecker );
}
+ // Update the SyntaxCheckerRegistry OidRegistry
+ oidRegistry.register( syntaxChecker );
+
if ( LOG.isDebugEnabled() )
{
LOG.debug( "registered " + syntaxChecker.getName() + " for OID {}", oid );
@@ -148,19 +149,58 @@
/**
* {@inheritDoc}
*/
- public DefaultSyntaxCheckerRegistry clone() throws CloneNotSupportedException
+ public DefaultSyntaxCheckerRegistry copy()
{
- DefaultSyntaxCheckerRegistry clone = (DefaultSyntaxCheckerRegistry)super.clone();
+ DefaultSyntaxCheckerRegistry copy = new DefaultSyntaxCheckerRegistry();
+
+ // Copy the base data
+ copy.copy( this );
- return clone;
+ return copy;
}
-
+
/**
- * {@inheritDoc}
+ * @see Object#toString()
*/
- public int size()
+ public String toString()
{
- return byName.values().size();
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( schemaObjectType ).append( ": " );
+ boolean isFirst = true;
+
+ for ( String name : byName.keySet() )
+ {
+ if ( isFirst )
+ {
+ isFirst = false;
+ }
+ else
+ {
+ sb.append( ", " );
+ }
+
+ SyntaxChecker syntaxChecker = byName.get( name );
+
+ String fqcn = syntaxChecker.getFqcn();
+ int lastDotPos = fqcn.lastIndexOf( '.' );
+
+ sb.append( '<' ).append( syntaxChecker.getOid() ).append( ", " );
+
+
+ if ( lastDotPos > 0 )
+ {
+ sb.append( fqcn.substring( lastDotPos + 1 ) );
+ }
+ else
+ {
+ sb.append( fqcn );
+ }
+
+ sb.append( '>' );
+ }
+
+ return sb.toString();
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java?rev=881393&r1=881392&r2=881393&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java Tue Nov 17 17:34:44 2009
@@ -28,6 +28,7 @@
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.shared.ldap.schema.SchemaObjectType;
import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
@@ -148,9 +149,9 @@
/**
* {@inheritDoc}
*/
- public AttributeTypeRegistry clone() throws CloneNotSupportedException
+ public AttributeTypeRegistry copy()
{
- return (AttributeTypeRegistry)immutableAttributeTypeRegistry.clone();
+ return (AttributeTypeRegistry)immutableAttributeTypeRegistry.copy();
}
@@ -242,4 +243,13 @@
{
throw new LdapOperationNotSupportedException( "Cannot modify the AttributeTypeRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaObject get( String oid )
+ {
+ return immutableAttributeTypeRegistry.get( oid );
+ }
}