directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [directory-ldap-api] 05/05: o Added the SyncStateValue factory in the list of response factories (it was missing) o used SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID instead of "2.5.13.1" o Fixed the creation of Intermediate Response : the controls and LdapResdult are now copied
Date Tue, 01 Jan 2019 11:17:29 GMT
This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit c4145424389d21b1c4aaf7ea0742bc2895ec7127
Author: Emmanuel Lecharny <elecharny@apache.org>
AuthorDate: Tue Jan 1 12:12:05 2019 +0100

    o Added the SyncStateValue factory in the list of response factories (it
    was missing)
    o used SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID instead of
    "2.5.13.1"
    o Fixed the creation of Intermediate Response : the controls and
    LdapResdult are now copied
---
 .../StoreIntermediateResponseName.java             | 20 +++++++++-
 .../ldap/codec/standalone/CodecFactoryUtil.java    |  1 +
 .../ldap/schema/loader/SchemaManagerAddTest.java   | 43 +++++++++++-----------
 .../ldap/schema/loader/SchemaManagerDelTest.java   |  5 ++-
 4 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/intermediate/StoreIntermediateResponseName.java
b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/intermediate/StoreIntermediateResponseName.java
index 6d3a64e..43661c6 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/intermediate/StoreIntermediateResponseName.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/actions/response/intermediate/StoreIntermediateResponseName.java
@@ -27,7 +27,9 @@ import org.apache.directory.api.asn1.util.Oid;
 import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.IntermediateOperationFactory;
 import org.apache.directory.api.ldap.codec.api.LdapMessageContainerDirect;
+import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.IntermediateResponse;
+import org.apache.directory.api.ldap.model.message.LdapResult;
 import org.apache.directory.api.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -92,7 +94,23 @@ public class StoreIntermediateResponseName extends GrammarAction<LdapMessageCont
                 {
                     // Ok, let's create the new operation, which will replace
                     // the one created during the init phase
-                    container.setMessage( intermediateFactory.newResponse() );
+                    IntermediateResponse newIntermediateResponse = intermediateFactory.newResponse();
+                    newIntermediateResponse.setMessageId( intermediateResponse.getMessageId()
);
+                    
+                    // Copy the LdapResult 
+                    LdapResult ldapResult = intermediateResponse.getLdapResult();
+                    newIntermediateResponse.getLdapResult().setDiagnosticMessage( ldapResult.getDiagnosticMessage()
);
+                    newIntermediateResponse.getLdapResult().setMatchedDn( ldapResult.getMatchedDn()
);
+                    newIntermediateResponse.getLdapResult().setReferral( ldapResult.getReferral()
);
+                    newIntermediateResponse.getLdapResult().setResultCode( ldapResult.getResultCode()
);
+                    
+                    // Copy the controls
+                    for ( Control control : intermediateResponse.getControls().values() )
+                    {
+                        newIntermediateResponse.addControl( control );
+                    }
+                    
+                    container.setMessage( newIntermediateResponse );
                     container.setIntermediateFactory( intermediateFactory );
                 }
                 else
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
index bbe7d16..836f453 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
@@ -292,6 +292,7 @@ public final class CodecFactoryUtil
         // SyncStateValue
         ControlFactory<SyncStateValue> syncStateValueFactory = new SyncStateValueFactory(
apiService );
         requestControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory
);
+        responseControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory
);
 
         if ( LOG.isInfoEnabled() )
         {
diff --git a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
index 505468a..b5b7275 100644
--- a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
+++ b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerAddTest.java
@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.api.util.FileUtils;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -221,7 +222,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
 
@@ -251,7 +252,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -279,7 +280,7 @@ public class SchemaManagerAddTest
 
         // Create the collective attribute first
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -295,7 +296,7 @@ public class SchemaManagerAddTest
 
         // Now try to create an AT which is a subtype of teh create collective attribute
         MutableAttributeType subType = new MutableAttributeType( "1.1.1" );
-        subType.setEqualityOid( "2.5.13.1" );
+        subType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         subType.setOrderingOid( null );
         subType.setSubstringOid( null );
         subType.setSuperiorOid( "1.1.0" );
@@ -323,7 +324,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -356,7 +357,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -390,7 +391,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -423,7 +424,7 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -572,9 +573,9 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
-        attributeType.setOrderingOid( "2.5.13.1" );
-        attributeType.setSubstringOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
         attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
 
@@ -598,9 +599,9 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "2.5.18.4" );
-        attributeType.setEqualityOid( "2.5.13.1" );
-        attributeType.setOrderingOid( "2.5.13.1" );
-        attributeType.setSubstringOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
 
         // It should fail
         assertFalse( schemaManager.add( attributeType ) );
@@ -633,9 +634,9 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
-        attributeType.setOrderingOid( "2.5.13.1" );
-        attributeType.setSubstringOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
         attributeType.setNames( "Test", "cn" );
 
@@ -667,9 +668,9 @@ public class SchemaManagerAddTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
-        attributeType.setOrderingOid( "2.5.13.1" );
-        attributeType.setSubstringOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
+        attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
         attributeType.setNames( "Test", "referral" );
 
@@ -719,7 +720,7 @@ public class SchemaManagerAddTest
         AttributeType result = schemaManager.lookupAttributeTypeRegistry( "1.1.0" );
 
         assertEquals( "1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid() );
-        assertEquals( "2.5.13.1", result.getEqualityOid() );
+        assertEquals( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID, result.getEqualityOid()
);
         assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
         assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
     }
diff --git a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
index a820c74..3a755db 100644
--- a/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
+++ b/ldap/schema/data/src/test/java/org/apache/directory/api/ldap/schema/loader/SchemaManagerDelTest.java
@@ -31,6 +31,7 @@ import java.io.IOException;
 import java.util.List;
 
 import org.apache.directory.api.util.FileUtils;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -228,7 +229,7 @@ public class SchemaManagerDelTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
-        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
         attributeType.setOrderingOid( null );
         attributeType.setSubstringOid( null );
 
@@ -512,7 +513,7 @@ public class SchemaManagerDelTest
         int goidSize = schemaManager.getGlobalOidRegistry().size();
 
         // AT with OID 2.5.18.4 has syntax 1.3.6.1.4.1.1466.115.121.1.12 which is used by
MR 2.5.13.1
-        MatchingRule mr = new MatchingRule( "2.5.13.1" );
+        MatchingRule mr = new MatchingRule( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID
);
         assertFalse( schemaManager.delete( mr ) );
 
         assertEquals( mrSize, schemaManager.getMatchingRuleRegistry().size() );


Mime
View raw message