From commits-return-26807-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Wed Aug 04 17:15:10 2010 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 12322 invoked from network); 4 Aug 2010 17:15:10 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Aug 2010 17:15:10 -0000 Received: (qmail 36022 invoked by uid 500); 4 Aug 2010 17:15:10 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 35970 invoked by uid 500); 4 Aug 2010 17:15:10 -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 35963 invoked by uid 99); 4 Aug 2010 17:15:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Aug 2010 17:15:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 04 Aug 2010 17:15:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 942BF2388A90; Wed, 4 Aug 2010 17:13:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r982332 [5/5] - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/ apacheds/trunk/core-api/src/main/java/... Date: Wed, 04 Aug 2010 17:13:47 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100804171348.942BF2388A90@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java?rev=982332&r1=982331&r2=982332&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java Wed Aug 4 17:13:46 2010 @@ -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.name; @@ -37,7 +37,6 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.entry.Value; import org.apache.directory.shared.ldap.exception.LdapException; import org.apache.directory.shared.ldap.exception.LdapInvalidDnException; -import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer; import org.apache.directory.shared.ldap.util.StringTools; @@ -151,7 +150,7 @@ public class RDN implements Cloneable, C /** * We also keep a set of types, in order to use manipulations. A type is * connected with the atav it represents. - * + * * Note : there is no Generic available classes in commons-collection... */ private MultiMap atavTypes = new MultiValueMap(); @@ -203,7 +202,7 @@ public class RDN implements Cloneable, C /** - * + * * Creates a new instance of RDN. * * @param schemaManager the schema manager @@ -266,7 +265,7 @@ public class RDN implements Cloneable, C /** * A constructor that parse a String representing a RDN. * - * @param rdn The String containing the RDN to parse + * @param rdn The String containing the RDN to parse * @throws LdapInvalidDnException */ public RDN( String rdn ) throws LdapInvalidDnException @@ -297,7 +296,7 @@ public class RDN implements Cloneable, C upName = upType + '=' + upValue; start = 0; length = upName.length(); - + // create the internal normalized form normalize(); @@ -312,7 +311,7 @@ public class RDN implements Cloneable, C } } - + /** * @see #RDN(String, String, String, String, SchemaManager) */ @@ -321,7 +320,7 @@ public class RDN implements Cloneable, C this( upType, normType, upValue, normValue, null ); } - + /** * A constructor that constructs a RDN from a type and a value. Constructs * an Rdn from the given attribute type and value. The string attribute @@ -340,7 +339,7 @@ public class RDN implements Cloneable, C upName = upType + '=' + upValue; start = 0; length = upName.length(); - + if( schemaManager != null ) { this.schemaManager = schemaManager; @@ -351,13 +350,13 @@ public class RDN implements Cloneable, C { // create the internal normalized form normalize(); - + // As strange as it seems, the RDN is *not* normalized against the schema at this point normalized = false; } } - + /** * @see #RDN(String, String, SchemaManager) */ @@ -365,7 +364,7 @@ public class RDN implements Cloneable, C { this( upType, upValue, null ); } - + /** * A constructor that constructs a RDN from a type, a position and a length. @@ -381,7 +380,7 @@ public class RDN implements Cloneable, C this.length = length; this.upName = upName; this.normName = normName; - normalized = true; + normalized = true; } @@ -428,8 +427,8 @@ public class RDN implements Cloneable, C /** * Transform the external representation of the current RDN to an internal - * normalized form where : - * - types are trimmed and lower cased + * normalized form where : + * - types are trimmed and lower cased * - values are trimmed and lower cased */ // WARNING : The protection level is left unspecified on purpose. @@ -488,6 +487,25 @@ public class RDN implements Cloneable, C * Transform a RDN by changing the value to its OID counterpart and * normalizing the value accordingly to its type. * + * @param schemaManager The SchemaManager + * @throws LdapException If the RDN is invalid. + */ + public RDN normalize( SchemaManager schemaManager ) throws LdapInvalidDnException + { + String upName = getName(); + DN.rdnOidToName( this, schemaManager.getNormalizerMapping() ); + normalize(); + this.upName = upName; + normalized = true; + + return this; + } + + + /** + * Transform a RDN by changing the value to its OID counterpart and + * normalizing the value accordingly to its type. + * * @param oidsMap The mapping between names and oids. * @throws LdapException If the RDN is invalid. */ @@ -522,7 +540,7 @@ public class RDN implements Cloneable, C // First, let's normalize the type Value normalizedValue = value; String normalizedType = StringTools.lowerCaseAscii( type ); - + if( schemaManager != null ) { OidNormalizer oidNormalizer = schemaManager.getNormalizerMapping().get( normalizedType ); @@ -649,7 +667,7 @@ public class RDN implements Cloneable, C * @param type * The type of the NameArgument * @return The Value to be returned, or null if none found. - * @throws LdapInvalidDnException + * @throws LdapInvalidDnException */ public Object getValue( String type ) throws LdapInvalidDnException { @@ -698,7 +716,7 @@ public class RDN implements Cloneable, C } - /** + /** * Get the start position * * @return The start position in the DN @@ -760,7 +778,7 @@ public class RDN implements Cloneable, C /** - * Retrieves the components of this RDN as an iterator of AttributeTypeAndValue. + * Retrieves the components of this RDN as an iterator of AttributeTypeAndValue. * The effect on the iterator of updates to this RDN is undefined. If the * RDN has zero components, an empty (non-null) iterator is returned. * @@ -804,7 +822,7 @@ public class RDN implements Cloneable, C /** * Clone the Rdn - * + * * @return A clone of the current RDN */ public Object clone() @@ -849,11 +867,11 @@ public class RDN implements Cloneable, C /** - * Compares two RDNs. They are equals if : - *
  • their have the same number of NC (AttributeTypeAndValue) - *
  • each ATAVs are equals - *
  • comparison of type are done case insensitive - *
  • each value is equal, case sensitive + * Compares two RDNs. They are equals if : + *
  • their have the same number of NC (AttributeTypeAndValue) + *
  • each ATAVs are equals + *
  • comparison of type are done case insensitive + *
  • each value is equal, case sensitive *
  • Order of ATAV is not important If the RDNs are not equals, a positive number is * returned if the first RDN is greater, negative otherwise * @@ -938,10 +956,10 @@ public class RDN implements Cloneable, C /** * Set the User Provided Name. - * + * * Package private because RDN is immutable, only used by the DN parser. - * - * @param upName the User Provided dame + * + * @param upName the User Provided dame */ void setUpName( String upName ) { @@ -1024,7 +1042,7 @@ public class RDN implements Cloneable, C /** * Return the User Provided value - * + * * @return The first User provided value of this RDN */ public Value getUpValue() @@ -1422,7 +1440,7 @@ public class RDN implements Cloneable, C * Gets the hashcode of this rdn. * * @see java.lang.Object#hashCode() - * @return the instance's hash code + * @return the instance's hash code */ public int hashCode() { @@ -1456,11 +1474,11 @@ public class RDN implements Cloneable, C /** * @see Externalizable#readExternal(ObjectInput)

    - * + * * A RDN is composed of on to many ATAVs (AttributeType And Value). - * We should write all those ATAVs sequencially, following the + * We should write all those ATAVs sequencially, following the * structure : - * + * *

  • parentId
  • The parent entry's Id *
  • nbAtavs
  • The number of ATAVs to write. Can't be 0. *
  • upName
  • The User provided RDN @@ -1472,7 +1490,7 @@ public class RDN implements Cloneable, C *
  • start
  • The position of this ATAV in the upName string *
  • length
  • The ATAV user provided length *
  • Call the ATAV write method
  • The ATAV itself - * + * * @param out The stream into which the serialized RDN will be put * @throws IOException If the stream can't be written */ @@ -1515,11 +1533,11 @@ public class RDN implements Cloneable, C /** * @see Externalizable#readExternal(ObjectInput) - * - * We read back the data to create a new RDB. The structure - * read is exposed in the {@link RDN#writeExternal(ObjectOutput)} + * + * We read back the data to create a new RDB. The structure + * read is exposed in the {@link RDN#writeExternal(ObjectOutput)} * method

    - * + * * @param in The input stream from which the RDN will be read * @throws IOException If we can't read from the input stream * @throws ClassNotFoundException If we can't create a new RDN