directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r905354 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: codec/LdapTransformer.java message/IntermediateResponseImpl.java message/internal/InternalIntermediateResponse.java
Date Mon, 01 Feb 2010 18:24:46 GMT
Author: elecharny
Date: Mon Feb  1 18:24:45 2010
New Revision: 905354

URL: http://svn.apache.org/viewvc?rev=905354&view=rev
Log:
Added the missing IntermediateResponse classes

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/IntermediateResponseImpl.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalIntermediateResponse.java
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=905354&r1=905353&r2=905354&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
Mon Feb  1 18:24:45 2010
@@ -42,6 +42,7 @@
 import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
@@ -89,6 +90,7 @@
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
+import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.message.LdapResultImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
@@ -1100,6 +1102,40 @@
 
 
     /**
+     * Transform a Internal IntermediateResponse to a Codec IntermediateResponse
+     * 
+     * @param codecMessage The Codec IntermediateResponse to produce
+     * @param internalMessage The incoming Internal IntermediateResponse
+     */
+    private static void transformIntermediateResponse( LdapMessageCodec codecMessage, InternalMessage
internalMessage )
+    {
+        IntermediateResponseImpl internalIntermediateResponse = (IntermediateResponseImpl)
internalMessage;
+        IntermediateResponseCodec intermediateResponse = new IntermediateResponseCodec();
+
+        // Internal : String oid -> Codec : String responseName
+        try
+        {
+            intermediateResponse.setResponseName( new OID( internalIntermediateResponse.getResponseName()
) );
+        }
+        catch ( DecoderException de )
+        {
+            LOG.warn( "The OID " + internalIntermediateResponse.getResponseName() + " is
invalid : " + de.getMessage() );
+            intermediateResponse.setResponseName( null );
+        }
+
+        // Internal : byte [] value -> Codec : byte[] value
+        intermediateResponse.setResponseValue( internalIntermediateResponse.getResponseValue()
);
+
+        // Transform the ldapResult
+        intermediateResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalIntermediateResponse
+            .getLdapResult() ) );
+
+        // Set the operation into the LdapMessage
+        codecMessage.setProtocolOP( intermediateResponse );
+    }
+
+
+    /**
      * Transform a Internal ModifyResponse to a Codec ModifyResponse
      * 
      * @param codecMessage The Codec ModifyResponse to produce
@@ -1289,7 +1325,7 @@
                 break;
                 
             case INTERMEDIATE_RESP :
-                //transformIntermediateResponse( codecMessage, msg );
+                transformIntermediateResponse( codecMessage, msg );
                 break;
         }
 

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/IntermediateResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/IntermediateResponseImpl.java?rev=905354&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/IntermediateResponseImpl.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/IntermediateResponseImpl.java
Mon Feb  1 18:24:45 2010
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.message;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalIntermediateResponse;
+
+/**
+ * IntermediateResponse implementation
+ * 
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ * @version $Rev: 905344 $
+ */
+public class IntermediateResponseImpl extends InternalAbstractResultResponse implements InternalIntermediateResponse
+{
+    static final long serialVersionUID = -6646752766410531060L;
+
+    /** ResponseName for the intermediate response */
+    protected String oid;
+
+    /** Response Value for the intermediate response */
+    protected byte[] value;
+
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+    public IntermediateResponseImpl( int id )
+    {
+        super( id, TYPE );
+    }
+
+
+    // ------------------------------------------------------------------------
+    // IntermediateResponse Interface Method Implementations
+    // ------------------------------------------------------------------------
+
+    /**
+     * Gets the reponseName specific encoded
+     * 
+     * @return the response value
+     */
+    public byte[] getResponseValue()
+    {
+        if ( value == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ value.length ];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
+    }
+
+
+    /**
+     * Sets the response value
+     * 
+     * @param value the response value.
+     */
+    public void setResponseValue( byte[] value )
+    {
+        if ( value != null )
+        {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
+    }
+    
+    
+    /**
+     * Gets the OID uniquely identifying this Intemediate response (a.k.a. its
+     * name).
+     * 
+     * @return the OID of the Intemediate response type.
+     */
+    public String getResponseName()
+    {
+        return oid;
+    }
+
+
+    /**
+     * Sets the OID uniquely identifying this Intemediate response (a.k.a. its
+     * name).
+     * 
+     * @param oid the OID of the Intemediate response type.
+     */
+    public void setResponseName( String oid )
+    {
+        this.oid = oid;
+    }
+
+
+    /**
+     * Checks to see if an object equals this IntemediateResponse.
+     * 
+     * @param obj the object to be checked for equality
+     * @return true if the obj equals this IntemediateResponse, false otherwise
+     */
+    public boolean equals( Object obj )
+    {
+        if ( obj == this )
+        {
+            return true;
+        }
+
+        if ( !super.equals( obj ) )
+        {
+            return false;
+        }
+        
+        if ( !( obj instanceof InternalIntermediateResponse ) )
+        {
+            return false;
+        }
+
+        InternalIntermediateResponse resp = ( InternalIntermediateResponse ) obj;
+
+        if ( ( oid != null ) && ( resp.getResponseName() == null ) )
+        {
+            return false;
+        }
+
+        if ( ( oid == null ) && ( resp.getResponseName() != null ) )
+        {
+            return false;
+        }
+
+        if ( ( oid != null ) && ( resp.getResponseName() != null ) )
+        {
+            if ( !oid.equals( resp.getResponseName() ) )
+            {
+                return false;
+            }
+        }
+
+        if ( ( value != null ) && ( resp.getResponseValue() == null ) )
+        {
+            return false;
+        }
+
+        if ( ( value == null ) && ( resp.getResponseValue() != null ) )
+        {
+            return false;
+        }
+
+        if ( ( value != null ) && ( resp.getResponseValue() != null ) )
+        {
+            if ( !Arrays.equals( value, resp.getResponseValue() ) )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalIntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalIntermediateResponse.java?rev=905354&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalIntermediateResponse.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalIntermediateResponse.java
Mon Feb  1 18:24:45 2010
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.shared.ldap.message.internal;
+
+
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+
+
+/**
+ * Intermediate response message used to return multiple response
+ * messages for a single search request (ExtendedRequest or Control).
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Revision: 905344 $
+ */
+public interface InternalIntermediateResponse extends InternalResponse
+{
+    /** Intermediate response message type enumeration value */
+    MessageTypeEnum TYPE = MessageTypeEnum.INTERMEDIATE_RESP;
+
+
+    /**
+     * Gets the response name
+     * 
+     * @return the ResponseName OID
+     */
+    String getResponseName();
+
+
+    /**
+     * Sets the response name.
+     * 
+     * @param oid the ResponseName
+     */
+    void setResponseName( String oid );
+
+
+    /**
+     * Gets the ResponseValue.
+     * 
+     * @return the responseValue
+     */
+    byte[] getResponseValue();
+
+
+    /**
+     * Sets the respponseValue
+     * 
+     * @param value The responseValue
+     */
+    void setResponseValue( byte[] value );
+}



Mime
View raw message