directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r900983 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Date Tue, 19 Jan 2010 22:27:21 GMT
Author: elecharny
Date: Tue Jan 19 22:27:20 2010
New Revision: 900983

URL: http://svn.apache.org/viewvc?rev=900983&view=rev
Log:
Added a removeAttributes() method plus a test

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=900983&r1=900982&r2=900983&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
Tue Jan 19 22:27:20 2010
@@ -274,6 +274,25 @@
             entry.add( id, (byte[])value );
         }
     }
+    
+    
+    /**
+     * Remove a list of Attributes from the LdifEntry
+     *
+     * @param ids The Attributes to remove
+     * @return The list of removed EntryAttributes
+     */
+    public List<EntryAttribute> removeAttribute( String... ids )
+    {
+        if ( entry.containsAttribute( ids ) )
+        {
+            return entry.removeAttributes( ids );
+        }
+        else
+        {
+            return null;
+        }
+    }
 
     /**
      * Add an attribute value to an existing attribute

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=900983&r1=900982&r2=900983&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Tue Jan 19 22:27:20 2010
@@ -1698,4 +1698,32 @@
         attr = entry.get( "prescriptiveACI" );
         assertTrue( attr.contains( "{ identificationTag \"browseRoot\", precedence 100, authenticationLevel
none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems
{entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }" ) );
     }
+    
+    
+    @Test
+    public void testRemoveAttribute() throws Exception
+    {
+        String ldif = 
+            "version: 1\n" + 
+            "dn: cn=Horatio Jensen, ou=Product Testing, dc=airius, dc=com\n" + 
+            "objectclass: top\n" + 
+            "objectclass: person\n" + 
+            "objectclass: organizationalPerson\n" + 
+            "cn: Horatio Jensen\n" + 
+            "cn: Horatio N Jensen\n" + 
+            "sn: Jensen\n" + 
+            "uid: hjensen\n" + 
+            "telephonenumber: +1 408 555 1212\n" + 
+            "jpegphoto:< file:" + HJENSEN_JPEG_FILE.getAbsolutePath() + "\n";
+
+        LdifReader reader = new LdifReader();
+        List<LdifEntry> entries = reader.parseLdif( ldif );
+        reader.close();
+        
+        LdifEntry entry = entries.get( 0 );
+        
+        assertNotNull( entry.get( "uid" ) );
+        assertNotNull( entry.removeAttribute( "uid" ) );
+        assertNull( entry.get( "uid" ) );
+    }
 }



Mime
View raw message