Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 30083 invoked from network); 25 Dec 2007 21:27:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Dec 2007 21:27:15 -0000 Received: (qmail 33281 invoked by uid 500); 25 Dec 2007 21:27:04 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 33242 invoked by uid 500); 25 Dec 2007 21:27:04 -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 33231 invoked by uid 99); 25 Dec 2007 21:27:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Dec 2007 13:27:04 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Dec 2007 21:26:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4A5901A983A; Tue, 25 Dec 2007 13:26:50 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r606814 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/ shared/branches/bigbang/ldap/src/... Date: Tue, 25 Dec 2007 21:26:49 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071225212650.4A5901A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Tue Dec 25 13:26:48 2007 New Revision: 606814 URL: http://svn.apache.org/viewvc?rev=606814&view=rev Log: Remove some useless methods in ServerEntry. As we now have varargs, no need to have the same method with a single argument Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java (original) +++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java Tue Dec 25 13:26:48 2007 @@ -166,29 +166,6 @@ } - public ServerAttribute> put( ServerAttribute> serverAttribute ) throws NamingException - { - if ( serverAttribute.getType().equals( objectClassAT ) && serverAttribute instanceof ObjectClassAttribute ) - { - return setObjectClassAttribute( ( ObjectClassAttribute ) serverAttribute ); - } - - if ( serverAttribute.getType().equals( objectClassAT ) ) - { - ObjectClassAttribute objectClassAttribute = new ObjectClassAttribute( registries ); - - for ( ServerValue val : serverAttribute ) - { - objectClassAttribute.add( val ); - } - - return setObjectClassAttribute( objectClassAttribute ); - } - - return serverAttributeMap.put( serverAttribute.getType(), serverAttribute ); - } - - public List>> put( ServerAttribute>... serverAttributes ) throws NamingException { List>> duplicatedAttributes = new ArrayList>>(); @@ -234,20 +211,57 @@ } - public ServerAttribute> put( AttributeType attributeType ) throws NamingException + /** + * Put an attribute (represented by its ID and values) into an entry. + * If the attribute already exists, the previous attribute will be + * replaced and returned. + * + * @param upId The attribute ID + * @param values The list of values to inject. It can be empty + * @return The replaced attribute + * @throws NamingException If the attribute does not exist + */ + public ServerAttribute> put( String upId, String... values ) throws NamingException { - throw new NotImplementedException(); + AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId ); + ServerAttribute> existing = serverAttributeMap.get( attributeType ); + + for ( String value:values ) + { + put( attributeType, value ); + } + + return existing; } - public ServerAttribute> remove( ServerAttribute> serverAttribute ) throws NamingException + /** + * Put an attribute (represented by its ID and values) into an entry. + * If the attribute already exists, the previous attribute will be + * replaced and returned. + * + * @param upId The attribute ID + * @param values The list of values to inject. It can be empty + * @return The replaced attribute + * @throws NamingException If the attribute does not exist + */ + public ServerAttribute> put( String upId, byte[]... values ) throws NamingException { - if ( serverAttribute.getType().equals( objectClassAT ) ) + AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId ); + ServerAttribute> existing = serverAttributeMap.get( attributeType ); + + for ( byte[] value:values ) { - return setObjectClassAttribute( new ObjectClassAttribute( registries ) ); + put( attributeType, value ); } + + return existing; + } + - return serverAttributeMap.remove( serverAttribute.getType() ); + public ServerAttribute> put( AttributeType attributeType ) throws NamingException + { + throw new NotImplementedException(); } Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java (original) +++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java Tue Dec 25 13:26:48 2007 @@ -196,19 +196,6 @@ /** - * Places a non-null attribute into this ServerEntry. If there an attribute - * of the same exists, the existing one is removed from the set and is - * returned by this method. If there was no attribute of the same type the - * return value is null. - * - * @param attribute the attribute to be put into this ServerEntry - * @return the existing attribute of the same type if it exists; otherwise - * null - */ - T put( T attribute ) throws NamingException; - - - /** * Places non-null attributes in the attribute collection. If there is * already an attribute with the same OID as any of the new attributes, * the old ones are removed from the collection and are returned by this @@ -325,17 +312,6 @@ */ T remove( AttributeType attributeType ) throws NamingException; - /** - * Places a non-null attribute into this ServerEntry. If there an attribute - * of the same exists, the existing one is removed from the set and is - * returned by this method. If there was no attribute of the same type the - * return value is null. - * - * @param attribute the attribute to be put into this ServerEntry - * @return the existing attribute of the same type if it exists; otherwise - * null - */ - T remove( T attribute ) throws NamingException; /** * Removes the specified attributes. The removed attributes are Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java (original) +++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java Tue Dec 25 13:26:48 2007 @@ -219,11 +219,11 @@ * * @return An instance of a BasicAttribute() object */ - public Attribute toAttributeImpl( EntryAttribute> attr ) + public static Attribute toAttributeImpl( ServerAttribute> attr ) { Attribute attribute = new AttributeImpl( attr.getUpId(), false ); - for ( Iterator> iter = attr.getAll(); iter.hasNext();) + for ( Iterator> iter = attr.getAll(); iter.hasNext();) { Value value = iter.next(); Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Tue Dec 25 13:26:48 2007 @@ -27,7 +27,6 @@ import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.core.DirectoryService; -import org.apache.directory.server.core.entry.DefaultServerAttribute; import org.apache.directory.server.core.entry.DefaultServerEntry; import org.apache.directory.server.core.entry.ServerEntryUtils; import org.apache.directory.server.core.enumeration.SearchResultFilter; @@ -151,13 +150,8 @@ DefaultServerEntry entry = ServerEntryUtils.toServerEntry( opContext.getEntry(), opContext.getDn(), registries ); - DefaultServerAttribute attribute = new DefaultServerAttribute( registry.lookup( SchemaConstants.CREATORS_NAME_AT ) ); - attribute.add( principal ); - entry.put( attribute ); - - attribute = new DefaultServerAttribute( registry.lookup( SchemaConstants.CREATE_TIMESTAMP_AT ) ); - attribute.add( DateUtils.getGeneralizedTime() ); - entry.put( attribute ); + entry.put( SchemaConstants.CREATORS_NAME_AT, principal ); + entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); opContext.setEntry( ServerEntryUtils.toAttributesImpl( entry ) ); nextInterceptor.add( opContext ); Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java (original) +++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java Tue Dec 25 13:26:48 2007 @@ -87,19 +87,6 @@ /** - * Places a non-null attribute in the attribute collection. If there is - * already an attribute with the same OID as the new attribute, the old one - * is removed from the collection and is returned by this method. If there - * was no attribute with the same OID the return value is null. - * - * @param attribute the attribute to be put - * @return the old attribute with the same OID, if exists; otherwise - * null - */ - T put( T attribute ) throws NamingException; - - - /** * Removes the specified attributes. The removed attributes are * returned by this method. If there were no attribute the return value * is null. @@ -110,17 +97,6 @@ List remove( T... attributes ) throws NamingException; - /** - * Removes the specified attribute. The removed attribute is - * returned by this method. If there were no attribute the return value - * is null. - * - * @param attribute the attribute to be removed - * @return the removed attribute, if exists; otherwise null - */ - T remove( T attribute ) throws NamingException; - - /** * Returns the number of attributes. * Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java (original) +++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java Tue Dec 25 13:26:48 2007 @@ -34,24 +34,6 @@ public interface EntryAttribute> { /** - * Adds a value to this attribute. If the new value is already present in - * the attribute values, the method has no effect. - *

- * The new value is added at the end of list of values. - *

- *

- * This method returns true or false to indicate whether a value was added. - *

- * - * @param val a new value to be added which may be null - * @return true if a value was added, otherwise false - * - * @exception InvalidAttributeValueException if the added value is not valid - */ - boolean add( String val ) throws InvalidAttributeValueException, NamingException; - - - /** * Adds some values to this attribute. If the new values are already present in * the attribute values, the method has no effect. *

@@ -68,22 +50,6 @@ /** - * Adds a value to this attribute. If the new value is already present in - * the attribute values, the method has no effect. - *

- * The new value is added at the end of list of values. - *

- *

- * This method returns true or false to indicate whether a value was added. - *

- * - * @param val a new value to be added which may be null - * @return true if a value was added, otherwise false - */ - boolean add( byte[] val ) throws InvalidAttributeValueException, NamingException; - - - /** * Adds some values to this attribute. If the new values are already present in * the attribute values, the method has no effect. *

@@ -106,15 +72,6 @@ /** - * Indicates whether the specified value is one of the attribute's values. - * - * @param val the value which may be null - * @return true if this attribute contains the value, otherwise false - */ - boolean contains( String val ); - - - /** * Indicates whether the specified values are some of the attribute's values. * * @param vals the values @@ -124,15 +81,6 @@ /** - * Indicates whether the specified value is one of the attribute's values. - * - * @param val the value which may be null - * @return true if this attribute contains the value, otherwise false - */ - boolean contains( byte[] val ); - - - /** * Indicates whether the specified values are some of the attribute's values. * * @param vals the values @@ -151,19 +99,6 @@ /** - * Removes a value that is equal to the given value. - *

- * Returns true if a value is removed. If there is no value equal to - * val this method simply returns false. - *

- * - * @param val the value to be removed - * @return true if the value is removed, otherwise false - */ - boolean remove( byte[] val ); - - - /** * Removes all the values that are equal to the given values. *

* Returns true if a value is removed. If there is no value equal to @@ -177,19 +112,6 @@ /** - * Removes a value that is equal to the given value. - *

- * Returns true if a value is removed. If there is no value equal to - * val this method simply returns false. - *

- * - * @param val the value to be removed - * @return true if the value is removed, otherwise false - */ - boolean remove( String val ); - - - /** * Removes all the values that are equal to the given values. *

* Returns true if a value is removed. If there is no value equal to @@ -245,19 +167,6 @@ /** - * Removes a value that is equal to the given value. - *

- * Returns true if a value is removed. If there is no value equal to - * val this method simply returns false. - *

- * - * @param val the value to be removed - * @return true if the value is removed, otherwise false - */ - boolean remove( T val ); - - - /** * Removes all the values that are equal to the given values. *

* Returns true if a value is removed. If there is no value equal to @@ -271,15 +180,6 @@ /** - * Indicates whether the specified value is one of the attribute's values. - * - * @param val the value which may be null - * @return true if this attribute contains the value, otherwise false - */ - boolean contains( T val ); - - - /** * Indicates whether the specified values are some of the attribute's values. * * @param vals the values @@ -287,22 +187,6 @@ */ boolean contains( T... vals ); - - /** - * Adds a value to this attribute. If the new value is already present in - * the attribute values, the method has no effect. - *

- * The new value is added at the end of list of values. - *

- *

- * This method returns true or false to indicate whether a value was added. - *

- * - * @param val a new value to be added which may be null - * @return true if a value was added, otherwise false - */ - boolean add( T val ) throws InvalidAttributeValueException, NamingException; - /** * Adds some values to this attribute. If the new values are already present in Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java?rev=606814&r1=606813&r2=606814&view=diff ============================================================================== --- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java (original) +++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java Tue Dec 25 13:26:48 2007 @@ -144,19 +144,23 @@ } StringValue stringValue = ( StringValue ) obj; - if ( this.wrapped == null && stringValue.wrapped == null ) + + if ( this.wrapped == null ) { - return true; + if ( stringValue.wrapped == null ) + { + return true; + } + else + { + return false; + } } - - //noinspection SimplifiableIfStatement - if ( this.wrapped == null && stringValue.wrapped != null || - this.wrapped != null && stringValue.wrapped == null ) + else if ( stringValue.wrapped == null ) { return false; } - //noinspection ConstantConditions return this.wrapped.equals( stringValue.wrapped ); }