Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4392E971C for ; Wed, 15 Feb 2012 16:21:54 +0000 (UTC) Received: (qmail 60492 invoked by uid 500); 15 Feb 2012 16:21:54 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 60429 invoked by uid 500); 15 Feb 2012 16:21:54 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 60421 invoked by uid 99); 15 Feb 2012 16:21:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2012 16:21:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2012 16:21:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8FEDD238890D for ; Wed, 15 Feb 2012 16:21:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Wed, 15 Feb 2012 16:21:32 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120215162132.8FEDD238890D@eris.apache.org> 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. * *
  *  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( mayAttributeTypeOids.size() );
-
-                for ( String oid : mayAttributeTypeOids )
-                {
-                    mayAttributeTypes.add( atRegistry.lookup( oid ) );
-                }
-            }
-
-            if ( mustAttributeTypeOids != null )
-            {
-                mustAttributeTypes = new ArrayList( mustAttributeTypeOids.size() );
-
-                for ( String oid : mustAttributeTypeOids )
-                {
-                    mustAttributeTypes.add( atRegistry.lookup( oid ) );
-                }
-            }
-
-            if ( notAttributeTypeOids != null )
-            {
-                notAttributeTypes = new ArrayList( notAttributeTypeOids.size() );
-
-                for ( String oid : notAttributeTypeOids )
-                {
-                    notAttributeTypes.add( atRegistry.lookup( oid ) );
-                }
-            }
-
-            if ( auxObjectClassOids != null )
-            {
-                auxObjectClasses = new ArrayList( 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 Apache Directory Project
+ */
+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 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();
+            }
+        }
+    }
+}