directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r690295 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/ apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/ apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/serv...
Date Fri, 29 Aug 2008 15:24:23 GMT
Author: elecharny
Date: Fri Aug 29 08:24:22 2008
New Revision: 690295

URL: http://svn.apache.org/viewvc?rev=690295&view=rev
Log:
Removed some more JNDI elements

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
    directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java?rev=690295&r1=690294&r2=690295&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
Fri Aug 29 08:24:22 2008
@@ -40,10 +40,7 @@
 import org.slf4j.LoggerFactory;
 
 import javax.naming.NamingException;
-import javax.naming.Name;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.Attribute;
+//import javax.naming.directory.DirContext;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -135,19 +132,20 @@
      * @param name the name of the entry being modified
      * @param mod the type of modification operation being performed (should be
      * REMOVE_ATTRIBUTE)
-     * @param attributes the attributes being modified
+     * @param entry the entry being modified
      * @throws NamingException if modify operations leave the entry inconsistent
      * without a STRUCTURAL objectClass
      */
-    public static void preventStructuralClassRemovalOnModifyReplace( ObjectClassRegistry
registry, Name name, int mod,
-        Attributes attributes ) throws NamingException
+    public static void preventStructuralClassRemovalOnModifyReplace( 
+        ObjectClassRegistry registry, LdapDN name, ModificationOperation mod, ServerEntry
entry ) throws NamingException
     {
-        if ( mod != DirContext.REPLACE_ATTRIBUTE )
+        if ( mod != ModificationOperation.REPLACE_ATTRIBUTE )
         {
             return;
         }
 
-        Attribute objectClass = attributes.get( SchemaConstants.OBJECT_CLASS_AT );
+        EntryAttribute objectClass = entry.get( SchemaConstants.OBJECT_CLASS_AT );
+        
         if ( objectClass == null )
         {
             return;
@@ -166,9 +164,10 @@
         }
 
         // check that there is at least one structural objectClass in the replacement set
-        for ( int ii = 0; ii < objectClass.size(); ii++ )
+        for ( Value<?> value:objectClass )
         {
-            ObjectClass ocType = registry.lookup( ( String ) objectClass.get( ii ) );
+            ObjectClass ocType = registry.lookup( ( String ) value.get() );
+            
             if ( ocType.getType() == ObjectClassTypeEnum.STRUCTURAL )
             {
                 return;
@@ -457,10 +456,11 @@
      * @param oidRegistry
      * @throws NamingException if the modify operation is removing an Rdn attribute
      */
-    public static void preventRdnChangeOnModifyReplace( LdapDN name, int mod, ServerEntry
entry, OidRegistry oidRegistry )
+    public static void preventRdnChangeOnModifyReplace( 
+        LdapDN name, ModificationOperation mod, ServerEntry entry, OidRegistry oidRegistry
)
         throws NamingException
     {
-        if ( mod != DirContext.REPLACE_ATTRIBUTE )
+        if ( mod != ModificationOperation.REPLACE_ATTRIBUTE )
         {
             return;
         }
@@ -609,10 +609,10 @@
      * @param oidRegistry
      * @throws NamingException if the modify operation is removing an Rdn attribute
      */
-    public static void preventRdnChangeOnModifyRemove( LdapDN name, int mod, ServerEntry
entry, OidRegistry oidRegistry )
+    public static void preventRdnChangeOnModifyRemove( LdapDN name, ModificationOperation
mod, ServerEntry entry, OidRegistry oidRegistry )
         throws NamingException
     {
-        if ( mod != DirContext.REMOVE_ATTRIBUTE )
+        if ( mod != ModificationOperation.REMOVE_ATTRIBUTE )
         {
             return;
         }
@@ -676,7 +676,7 @@
      * attribute is not an rdn attribute
      * @throws NamingException if the name is malformed in any way
      */
-    private static String getRdnValue( String id, Name name, OidRegistry oidRegistry ) throws
NamingException
+    private static String getRdnValue( String id, LdapDN name, OidRegistry oidRegistry )
throws NamingException
     {
         // Transform the rdnAttrId to it's OID counterPart
         String idOid = oidRegistry.getOid( id );

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java?rev=690295&r1=690294&r2=690295&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
Fri Aug 29 08:24:22 2008
@@ -23,9 +23,6 @@
 import junit.framework.TestCase;
 
 import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
 
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -43,14 +40,15 @@
 import org.apache.directory.server.schema.registries.ObjectClassRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 import java.util.Collections;
 import java.util.Iterator;
@@ -68,19 +66,12 @@
  */
 public class SchemaCheckerTest extends TestCase
 {
-    Registries registries = null;
+    static Registries registries;
 
 
-    public SchemaCheckerTest() throws Exception
+    @BeforeClass
+    protected void setUp() throws Exception
     {
-        this( "SchemaCheckerTest" );
-    }
-
-
-    public SchemaCheckerTest(String name) throws Exception
-    {
-        super( name );
-
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         registries = new DefaultRegistries( "bootstrap", loader, new DefaultOidRegistry()
);
 
@@ -105,12 +96,14 @@
      * Test case to check the schema checker operates correctly when modify
      * operations replace objectClasses.
      */
+    @Test
     public void testPreventStructuralClassRemovalOnModifyReplace() throws Exception
     {
         LdapDN name = new LdapDN( "uid=akarasulu,ou=users,dc=example,dc=com" );
-        int mod = DirContext.REPLACE_ATTRIBUTE;
-        Attributes modifyAttributes = new AttributesImpl( true );
-        modifyAttributes.put( new AttributeImpl( "cn" ) );
+        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
+        ServerEntry modifyAttributes = new DefaultServerEntry( registries );
+        AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
+        modifyAttributes.put( new DefaultServerAttribute( atCN ) );
 
         ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
 
@@ -118,15 +111,16 @@
         SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod,
modifyAttributes );
 
         // this should succeed since person is still in replaced set and is structural
-        modifyAttributes.remove( "cn" );
-        Attribute objectClassesReplaced = new AttributeImpl( "objectClass" );
+        modifyAttributes.removeAttributes( atCN );
+        AttributeType atOC = registries.getAttributeTypeRegistry().lookup( "objectClass"
);
+        EntryAttribute objectClassesReplaced = new DefaultServerAttribute( atOC );
         objectClassesReplaced.add( "top" );
         objectClassesReplaced.add( "person" );
         modifyAttributes.put( objectClassesReplaced );
         SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod,
modifyAttributes );
 
         // this should fail since only top is left
-        objectClassesReplaced = new AttributeImpl( "objectClass" );
+        objectClassesReplaced = new DefaultServerAttribute( atOC );
         objectClassesReplaced.add( "top" );
         modifyAttributes.put( objectClassesReplaced );
         try
@@ -141,8 +135,8 @@
 
         // this should fail since the modify operation tries to delete all
         // objectClass attribute values
-        modifyAttributes.remove( "cn" );
-        objectClassesReplaced = new AttributeImpl( "objectClass" );
+        modifyAttributes.removeAttributes( "cn" );
+        objectClassesReplaced = new DefaultServerAttribute( atOC );
         modifyAttributes.put( objectClassesReplaced );
         try
         {
@@ -224,9 +218,10 @@
      * Test case to check the schema checker operates correctly when modify
      * operations remove RDN attributes.
      */
+    @Test
     public void testPreventRdnChangeOnModifyRemove() throws Exception
     {
-        int mod = DirContext.REMOVE_ATTRIBUTE;
+        ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
         ServerEntry attributes = new DefaultServerEntry( registries, name );
         attributes.put( "cn", "does not matter" );
@@ -293,9 +288,10 @@
      * Test case to check the schema checker operates correctly when modify
      * operations replace RDN attributes.
      */
+    @Test
     public void testPreventRdnChangeOnModifyReplace() throws Exception
     {
-        int mod = DirContext.REPLACE_ATTRIBUTE;
+        ModificationOperation mod = ModificationOperation.REPLACE_ATTRIBUTE;
         LdapDN name = new LdapDN( "ou=user,dc=example,dc=com" );
         ServerEntry attributes = new DefaultServerEntry( registries, name );
         attributes.put( "cn", "does not matter" );
@@ -365,6 +361,7 @@
      * Test case to check the schema checker operates correctly when modify
      * operations replace objectClasses.
      */
+    @Test
     public void testPreventStructuralClassRemovalOnModifyReplaceAttribute() throws Exception
     {
         ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
@@ -414,6 +411,7 @@
      * Test case to check the schema checker operates correctly when modify
      * operations remove objectClasses.
      */
+    @Test
     public void testPreventStructuralClassRemovalOnModifyRemoveAttribute() throws Exception
     {
         AttributeTypeRegistry atReg = registries.getAttributeTypeRegistry();
@@ -477,6 +475,7 @@
      * Test case to check the schema checker operates correctly when modify
      * operations remove RDN attributes.
      */
+    @Test
     public void testPreventRdnChangeOnModifyRemoveAttribute() throws Exception
     {
         OidRegistry registry = new MockOidRegistry();

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java?rev=690295&r1=690294&r2=690295&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
Fri Aug 29 08:24:22 2008
@@ -22,9 +22,6 @@
 
 import java.util.Set;
 
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -34,8 +31,10 @@
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
 
@@ -199,14 +198,14 @@
      * @throws Exception if there are failures accessing the underlying store
      */
     @SuppressWarnings("unchecked")
-    public Attributes getAttributes( Store store, Long id ) throws Exception
+    public Entry getAttributes( Store store, Long id ) throws Exception
     {
-        Attributes attributes = new AttributesImpl();
+        Entry entry = new DefaultClientEntry();
 
         // Get the distinguishedName to id mapping
-        attributes.put( "_nDn", store.getEntryDn( id ) );
-        attributes.put( "_upDn", store.getEntryUpdn( id ) );
-        attributes.put( "_parent", store.getParentId( id ) );
+        entry.put( "_nDn", store.getEntryDn( id ) );
+        entry.put( "_upDn", store.getEntryUpdn( id ) );
+        entry.put( "_parent", Long.toString( store.getParentId( id ) ) );
 
         // Get all standard index attribute to value mappings
         for ( Index index : ( Set<Index> )store.getUserIndices() )
@@ -221,20 +220,20 @@
                 IndexEntry rec = list.get();
                 String val = rec.getValue().toString();
                 String attrId = index.getAttribute().getName();
-                Attribute attr = attributes.get( attrId );
+                EntryAttribute attr = entry.get( attrId );
 
                 if ( attr == null )
                 {
-                    attr = new AttributeImpl( attrId );
+                    attr = new DefaultClientAttribute( attrId );
                 }
                 
                 attr.add( val );
-                attributes.put( attr );
+                entry.put( attr );
             }
         }
 
-        // Get all existance mappings for this id creating a special key
-        // that looks like so 'existance[attribute]' and the value is set to id
+        // Get all existence mappings for this id creating a special key
+        // that looks like so 'existence[attribute]' and the value is set to id
         Cursor<IndexEntry> list = store.getPresenceIndex().reverseCursor();
         ForwardIndexEntry recordForward = new ForwardIndexEntry();
         recordForward.setId( id );
@@ -249,15 +248,15 @@
             val.append( "]" );
 
             String valStr = val.toString();
-            Attribute attr = attributes.get( valStr );
+            EntryAttribute attr = entry.get( valStr );
             
             if ( attr == null )
             {
-                attr = new AttributeImpl( valStr );
+                attr = new DefaultClientAttribute( valStr );
             }
             
             attr.add( rec.getId().toString() );
-            attributes.put( attr );
+            entry.put( attr );
             val.setLength( 0 );
         }
 
@@ -268,8 +267,8 @@
         recordForward.setId( id );
         children.before( longRecordForward );
 
-        Attribute childAttr = new AttributeImpl( "_child" );
-        attributes.put( childAttr );
+        EntryAttribute childAttr = new DefaultClientAttribute( "_child" );
+        entry.put( childAttr );
         
         while ( children.next() )
         {
@@ -277,7 +276,7 @@
             childAttr.add( rec.getId().toString() );
         }
 
-        return attributes;
+        return entry;
     }
 
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java?rev=690295&r1=690294&r2=690295&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/search/SearchRequestMatchingRuleAssertionTest.java
Fri Aug 29 08:24:22 2008
@@ -40,6 +40,8 @@
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 import junit.framework.TestCase;
 
@@ -53,6 +55,7 @@
 {
     static Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
 
+    @BeforeClass
     protected void setUp() throws Exception
     {
         super.setUp();
@@ -71,6 +74,7 @@
     /**
      * Tests an search request decode with a simple equality match filter.
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatch()
     {
         Asn1Decoder ldapDecoder = new LdapDecoder();
@@ -173,6 +177,7 @@
     /**
      * Test the decoding of a SearchRequest with an empty extensible match
      */
+    @Test
     public void testDecodeSearchRequestEmptyExtensibleMatch()
     {
         byte[] asn1BER = new byte[]
@@ -221,6 +226,7 @@
      * Test the decoding of a SearchRequest with an extensible match and an
      * empty matching rule
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchEmptyMatchingRule()
     {
         byte[] asn1BER = new byte[]
@@ -270,6 +276,7 @@
      * Test the decoding of a SearchRequest with an extensible match and an
      * empty type
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchEmptyType()
     {
         byte[] asn1BER = new byte[]
@@ -319,6 +326,7 @@
      * Test the decoding of a SearchRequest with an extensible match and an
      * empty matchValue
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchEmptyMatchValue()
     {
         byte[] asn1BER = new byte[]
@@ -391,6 +399,7 @@
      * Test the decoding of a SearchRequest with an extensible match and an
      * matching rule and an empty type
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchMatchingRuleEmptyType()
     {
         byte[] asn1BER = new byte[]
@@ -440,6 +449,7 @@
      * Test the decoding of a SearchRequest with an extensible match and an
      * matching rule and an empty dnAttributes
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchDnAttributesEmptyType()
     {
         byte[] asn1BER = new byte[]
@@ -507,6 +517,7 @@
      * Test the decoding of a SearchRequest with an extensible match and a
      * matching rule and nothing else
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchMatchingRuleAlone()
     {
         byte[] asn1BER = new byte[]
@@ -555,6 +566,7 @@
      * Test the decoding of a SearchRequest with an extensible match and a type
      * and nothing else
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchTypeAlone()
     {
         byte[] asn1BER = new byte[]
@@ -603,6 +615,7 @@
      * Test the decoding of a SearchRequest with an extensible match and a match
      * Value and nothing else
      */
+    @Test
     public void testDecodeSearchRequestExtensibleMatchMatchValueAlone()
     {
         byte[] asn1BER = new byte[]



Mime
View raw message