directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
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 GMT
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<ServerValue<?>> put( ServerAttribute<ServerValue<?>>
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<ServerAttribute<ServerValue<?>>> put( ServerAttribute<ServerValue<?>>...
serverAttributes ) throws NamingException
     {
         List<ServerAttribute<ServerValue<?>>> duplicatedAttributes = new
ArrayList<ServerAttribute<ServerValue<?>>>();
@@ -234,20 +211,57 @@
     }
 
 
-    public ServerAttribute<ServerValue<?>> 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<ServerValue<?>> put( String upId, String... values
) throws NamingException
     {
-        throw new NotImplementedException();
+        AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId
);
+        ServerAttribute<ServerValue<?>> existing = serverAttributeMap.get( attributeType
);
+
+        for ( String value:values )
+        {
+            put( attributeType, value );
+        }
+        
+        return existing;
     }
 
 
-    public ServerAttribute<ServerValue<?>> remove( ServerAttribute<ServerValue<?>>
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<ServerValue<?>> put( String upId, byte[]... values
) throws NamingException
     {
-        if ( serverAttribute.getType().equals( objectClassAT ) )
+        AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId
);
+        ServerAttribute<ServerValue<?>> 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<ServerValue<?>> 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 <code>null</code>.
-     *
-     * @param attribute the attribute to be put into this ServerEntry
-     * @return the existing attribute of the same type if it exists; otherwise
-     * <code>null</code>
-     */
-    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 <code>null</code>.
-     *
-     * @param attribute the attribute to be put into this ServerEntry
-     * @return the existing attribute of the same type if it exists; otherwise
-     * <code>null</code>
-     */
-    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<Value<?>> attr )
+    public static Attribute toAttributeImpl( ServerAttribute<ServerValue<?>>
attr )
     {
         Attribute attribute = new AttributeImpl( attr.getUpId(), false );
 
-        for ( Iterator<Value<?>> iter = attr.getAll(); iter.hasNext();)
+        for ( Iterator<ServerValue<?>> 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 <code>null</code>.
-     *
-     * @param attribute the attribute to be put
-     * @return the old attribute with the same OID, if exists; otherwise
-     *         <code>null</code>
-     */
-    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 <code>null</code>.
@@ -110,17 +97,6 @@
     List<T> 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 <code>null</code>.
-     *
-     * @param attribute the attribute to be removed
-     * @return the removed attribute, if exists; otherwise <code>null</code>
-     */
-    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<T extends Value<?>>
 {
     /**
-     * Adds a value to this attribute. If the new value is already present in
-     * the attribute values, the method has no effect.
-     * <p>
-     * The new value is added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns true or false to indicate whether a value was added.
-     * </p>
-     *
-     * @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.
      * <p>
@@ -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.
-     * <p>
-     * The new value is added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns true or false to indicate whether a value was added.
-     * </p>
-     *
-     * @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.
      * <p>
@@ -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.
-     * <p>
-     * Returns true if a value is removed. If there is no value equal to <code>
-     * val</code> this method simply returns false.
-     * </p>
-     *
-     * @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.
      * <p>
      * Returns true if a value is removed. If there is no value equal to <code>
@@ -177,19 +112,6 @@
 
 
     /**
-     * Removes a value that is equal to the given value.
-     * <p>
-     * Returns true if a value is removed. If there is no value equal to <code>
-     * val</code> this method simply returns false.
-     * </p>
-     *
-     * @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.
      * <p>
      * Returns true if a value is removed. If there is no value equal to <code>
@@ -245,19 +167,6 @@
 
 
     /**
-     * Removes a value that is equal to the given value.
-     * <p>
-     * Returns true if a value is removed. If there is no value equal to <code>
-     * val</code> this method simply returns false.
-     * </p>
-     *
-     * @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.
      * <p>
      * Returns true if a value is removed. If there is no value equal to <code>
@@ -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.
-     * <p>
-     * The new value is added at the end of list of values.
-     * </p>
-     * <p>
-     * This method returns true or false to indicate whether a value was added.
-     * </p>
-     *
-     * @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 );
     }
 



Mime
View raw message