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 2012/02/15 17:21:32 UTC
svn commit: r1244564 - in
/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema:
DITContentRule.java registries/Registries.java
registries/helper/DitContentRuleHelper.java
Author: elecharny
Date: Wed Feb 15 16:21:31 2012
New Revision: 1244564
URL: http://svn.apache.org/viewvc?rev=1244564&view=rev
Log:
Added the DitContentRuleHelper class containing the methods that were in DITContentRule
Added:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java
Modified:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/DITContentRule.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/DITContentRule.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/DITContentRule.java?rev=1244564&r1=1244563&r2=1244564&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/DITContentRule.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/DITContentRule.java Wed Feb 15 16:21:31 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.ldap.model.schema;
@@ -24,10 +24,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.ObjectClassRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.Registries;
/**
@@ -41,37 +37,37 @@ import org.apache.directory.shared.ldap.
*
* <pre>
* 4.1.6. DIT Content Rules
- *
+ *
* A DIT content rule is a "rule governing the content of entries of a
* particular structural object class" [X.501].
- *
+ *
* For DIT entries of a particular structural object class, a DIT content
* rule specifies which auxiliary object classes the entries are allowed
* to belong to and which additional attributes (by type) are required,
* allowed or not allowed to appear in the entries.
- *
+ *
* The list of precluded attributes cannot include any attribute listed
* as mandatory in rule, the structural object class, or any of the
* allowed auxiliary object classes.
- *
+ *
* Each content rule is identified by the object identifier, as well as
* any short names (descriptors), of the structural object class it
* applies to.
- *
+ *
* An entry may only belong to auxiliary object classes listed in the
* governing content rule.
- *
+ *
* An entry must contain all attributes required by the object classes
* the entry belongs to as well as all attributed required by the
* governing content rule.
- *
+ *
* An entry may contain any non-precluded attributes allowed by the
* object classes the entry belongs to as well as all attributes allowed
* by the governing content rule.
- *
+ *
* An entry cannot include any attribute precluded by the governing
* content rule.
- *
+ *
* An entry is governed by (if present and active in the subschema) the
* DIT content rule which applies to the structural object class of the
* entry (see Section 2.4.2). If no active rule is present for the
@@ -568,63 +564,6 @@ public class DITContentRule extends Abst
/**
- * Inject the DITContentRule into the registries, updating the references to
- * other SchemaObject
- *
- * @param registries The Registries
- * @exception If the addition failed
- */
- public void addToRegistries( Registries registries ) throws LdapException
- {
- if ( registries != null )
- {
- AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
- ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
-
- if ( mayAttributeTypeOids != null )
- {
- mayAttributeTypes = new ArrayList<AttributeType>( mayAttributeTypeOids.size() );
-
- for ( String oid : mayAttributeTypeOids )
- {
- mayAttributeTypes.add( atRegistry.lookup( oid ) );
- }
- }
-
- if ( mustAttributeTypeOids != null )
- {
- mustAttributeTypes = new ArrayList<AttributeType>( mustAttributeTypeOids.size() );
-
- for ( String oid : mustAttributeTypeOids )
- {
- mustAttributeTypes.add( atRegistry.lookup( oid ) );
- }
- }
-
- if ( notAttributeTypeOids != null )
- {
- notAttributeTypes = new ArrayList<AttributeType>( notAttributeTypeOids.size() );
-
- for ( String oid : notAttributeTypeOids )
- {
- notAttributeTypes.add( atRegistry.lookup( oid ) );
- }
- }
-
- if ( auxObjectClassOids != null )
- {
- auxObjectClasses = new ArrayList<ObjectClass>( auxObjectClassOids.size() );
-
- for ( String oid : auxObjectClassOids )
- {
- auxObjectClasses.add( ocRegistry.lookup( oid ) );
- }
- }
- }
- }
-
-
- /**
* @see Object#toString()
*/
public String toString()
@@ -696,7 +635,7 @@ public class DITContentRule extends Abst
*/
@Override
@SuppressWarnings("PMD.UnusedLocalVariable")
- // Remove me when the TODO is fixed
+ // Remove me when the TODO is fixed
public boolean equals( Object o )
{
if ( !super.equals( o ) )
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java?rev=1244564&r1=1244563&r2=1244564&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java Wed Feb 15 16:21:31 2012
@@ -53,6 +53,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.schema.SchemaObjectWrapper;
import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
import org.apache.directory.shared.ldap.model.schema.registries.helper.AttributeTypeHelper;
+import org.apache.directory.shared.ldap.model.schema.registries.helper.DitContentRuleHelper;
import org.apache.directory.shared.ldap.model.schema.registries.helper.ObjectClassHelper;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
@@ -668,6 +669,10 @@ public class Registries implements Schem
AttributeTypeHelper.addToRegistries( (AttributeType)schemaObject, errors, this );
break;
+ case DIT_CONTENT_RULE :
+ DitContentRuleHelper.addToRegistries( (DITContentRule)schemaObject, errors, this );
+ break;
+
case OBJECT_CLASS :
ObjectClassHelper.addToRegistries( (ObjectClass)schemaObject, errors, this );
break;
Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java?rev=1244564&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java (added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/helper/DitContentRuleHelper.java Wed Feb 15 16:21:31 2012
@@ -0,0 +1,106 @@
+/*
+ * 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.shared.ldap.model.schema.registries.helper;
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.DITContentRule;
+import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.model.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An helper class used to store all the methods associated with an DitContentRule
+ * in relation with the Registries and SchemaManager.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DitContentRuleHelper
+{
+ /** A logger for this class */
+ private static final Logger LOG = LoggerFactory.getLogger( DitContentRuleHelper.class );
+
+ /**
+ * Inject the DITContentRule into the registries, updating the references to
+ * other SchemaObject
+ *
+ * @param registries The Registries
+ * @exception If the addition failed
+ */
+ public static void addToRegistries( DITContentRule ditContentRule, List<Throwable> errors, Registries registries ) throws LdapException
+ {
+ if ( registries != null )
+ {
+ try
+ {
+ ditContentRule.unlock();
+ AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
+ ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
+
+ if ( ditContentRule.getMayAttributeTypeOids() != null )
+ {
+ ditContentRule.getMayAttributeTypes().clear();
+
+ for ( String oid : ditContentRule.getMayAttributeTypeOids() )
+ {
+ ditContentRule.getMayAttributeTypes().add( atRegistry.lookup( oid ) );
+ }
+ }
+
+ if ( ditContentRule.getMustAttributeTypeOids() != null )
+ {
+ ditContentRule.getMustAttributeTypes().clear();
+
+ for ( String oid : ditContentRule.getMustAttributeTypeOids() )
+ {
+ ditContentRule.getMustAttributeTypes().add( atRegistry.lookup( oid ) );
+ }
+ }
+
+ if ( ditContentRule.getNotAttributeTypeOids() != null )
+ {
+ ditContentRule.getNotAttributeTypes().clear();
+
+ for ( String oid : ditContentRule.getNotAttributeTypeOids() )
+ {
+ ditContentRule.getNotAttributeTypes().add( atRegistry.lookup( oid ) );
+ }
+ }
+
+ if ( ditContentRule.getAuxObjectClassOids() != null )
+ {
+ ditContentRule.getAuxObjectClasses().clear();
+
+ for ( String oid : ditContentRule.getAuxObjectClassOids() )
+ {
+ ditContentRule.getAuxObjectClasses().add( ocRegistry.lookup( oid ) );
+ }
+ }
+ }
+ finally
+ {
+ ditContentRule.lock();
+ }
+ }
+ }
+}