directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1067514 - in /directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2: ./ reponse/
Date Sat, 05 Feb 2011 20:32:53 GMT
Author: akarasulu
Date: Sat Feb  5 20:32:53 2011
New Revision: 1067514

URL: http://svn.apache.org/viewvc?rev=1067514&view=rev
Log:
DIRSHARED-80: decoupling codec decorators from DSML parser

Modified:
    directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
    directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResponseDsml.java
    directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResultResponseDsml.java
    directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ErrorResponse.java
    directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java

Modified: directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java?rev=1067514&r1=1067513&r2=1067514&view=diff
==============================================================================
--- directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
(original)
+++ directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
Sat Feb  5 20:32:53 2011
@@ -29,7 +29,7 @@ import org.dom4j.Element;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public interface DsmlDecorator
+public interface DsmlDecorator<E>
 {
     /**
      * Converts the request/reponse to its XML representation in the DSMLv2 format
@@ -40,4 +40,12 @@ public interface DsmlDecorator
      *      the dom4j Element corresponding to the entry.
      */
     Element toDsml( Element root );
+    
+    
+    /**
+     * Gets the Message this DsmlDecorator decorates.
+     * 
+     * @return The decorated Message instance
+     */
+    E getDecorated();
 }

Modified: directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResponseDsml.java?rev=1067514&r1=1067513&r2=1067514&view=diff
==============================================================================
--- directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResponseDsml.java
(original)
+++ directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResponseDsml.java
Sat Feb  5 20:32:53 2011
@@ -20,16 +20,8 @@
 package org.apache.directory.shared.dsmlv2.reponse;
 
 
-import java.nio.ByteBuffer;
-
-import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.dsmlv2.DsmlDecorator;
-import org.apache.directory.shared.ldap.codec.CodecControl;
 import org.apache.directory.shared.ldap.codec.LdapCodecService;
-import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
-import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.Response;
-import org.dom4j.Element;
 
 
 /**
@@ -37,95 +29,15 @@ import org.dom4j.Element;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractResponseDsml<E extends Response> extends MessageDecorator<E>
implements DsmlDecorator
+public abstract class AbstractResponseDsml<E extends Response> extends AbstractDsmlMessageDecorator<E>
implements Response
 {
-
     /**
      * Instantiates a new abstract DSML response.
      *
-     * @param ldapMessage the LDAP message to decorate
-     */
-    public AbstractResponseDsml( LdapCodecService codec, E ldapMessage )
-    {
-        super( codec, ldapMessage );
-    }
-
-
-    /**
-     * {@inheritDoc}
+     * @param response the LDAP response message to decorate
      */
-    public abstract Element toDsml( Element root );
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void addAllControls( Control[] controls )
+    public AbstractResponseDsml( LdapCodecService codec, E response )
     {
-        // TODO Auto-generated method stub
-
+        super( codec, response );
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object get( Object key )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public CodecControl<? extends Control> getCurrentControl()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasControl( String oid )
-    {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object put( Object key, Object value )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void removeControl( Control control )
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-
-    public int computeLength()
-    {
-        return 0;
-    }
-
-
-    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
-    {
-        return null;
-    }
-
 }

Modified: directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResultResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResultResponseDsml.java?rev=1067514&r1=1067513&r2=1067514&view=diff
==============================================================================
--- directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResultResponseDsml.java
(original)
+++ directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/AbstractResultResponseDsml.java
Sat Feb  5 20:32:53 2011
@@ -20,14 +20,8 @@
 package org.apache.directory.shared.dsmlv2.reponse;
 
 
-import java.nio.ByteBuffer;
-
-import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.dsmlv2.DsmlDecorator;
-import org.apache.directory.shared.ldap.codec.CodecControl;
 import org.apache.directory.shared.ldap.codec.LdapCodecService;
-import org.apache.directory.shared.ldap.codec.decorators.ResponseDecorator;
-import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.LdapResult;
 import org.apache.directory.shared.ldap.model.message.ResultResponse;
 import org.dom4j.Element;
 
@@ -37,17 +31,17 @@ import org.dom4j.Element;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractResultResponseDsml<E extends ResultResponse> extends
ResponseDecorator<E> implements DsmlDecorator
+public abstract class AbstractResultResponseDsml<E extends ResultResponse> 
+    extends AbstractResponseDsml<ResultResponse> implements ResultResponse
 {
-
     /**
      * Instantiates a new abstract DSML response.
      *
      * @param ldapMessage the LDAP message to decorate
      */
-    public AbstractResultResponseDsml( LdapCodecService codec, E ldapMessage )
+    public AbstractResultResponseDsml( LdapCodecService codec, E resultResponse )
     {
-        super( codec, ldapMessage );
+        super( codec, resultResponse );
     }
 
 
@@ -60,72 +54,8 @@ public abstract class AbstractResultResp
     /**
      * {@inheritDoc}
      */
-    public void addAllControls( Control[] controls )
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object get( Object key )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public CodecControl<? extends Control> getCurrentControl()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasControl( String oid )
+    public LdapResult getLdapResult()
     {
-        // TODO Auto-generated method stub
-        return false;
+        return getDecorated().getLdapResult();
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object put( Object key, Object value )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void removeControl( Control control )
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-
-    public int computeLength()
-    {
-        return 0;
-    }
-
-
-    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
-    {
-        return null;
-    }
-
 }

Modified: directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ErrorResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ErrorResponse.java?rev=1067514&r1=1067513&r2=1067514&view=diff
==============================================================================
--- directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ErrorResponse.java
(original)
+++ directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ErrorResponse.java
Sat Feb  5 20:32:53 2011
@@ -17,11 +17,11 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.shared.dsmlv2.reponse;
 
 
 import org.apache.directory.shared.dsmlv2.DsmlDecorator;
+import org.apache.directory.shared.ldap.codec.LdapCodecService;
 import org.apache.directory.shared.ldap.model.message.AbstractResponse;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.message.Response;
@@ -43,9 +43,12 @@ import org.dom4j.Element;
  *     <li>OTHER</li>
  * </ul>
  * 
+ * @TODO review this class - maybe it should not be decorated and if it is 
+ * it should extend AbstractResultResponseDsml - by Alex
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ErrorResponse extends AbstractResponse implements Response, DsmlDecorator
+public class ErrorResponse extends AbstractResponse implements Response, DsmlDecorator<Response>
 {
     /**
      * This enum represents the different types of error response
@@ -258,4 +261,18 @@ public class ErrorResponse extends Abstr
     {
         this.errorType = errorType;
     }
+
+
+    public LdapCodecService getCodecService()
+    {
+        throw new IllegalArgumentException( "This should not be a decorator " +
+        		"but seems it was made into one. We need to do something about" +
+        		"this if this exception is being raise." );
+    }
+
+
+    public Response getDecorated()
+    {
+        return this;
+    }
 }

Modified: directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java?rev=1067514&r1=1067513&r2=1067514&view=diff
==============================================================================
--- directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
(original)
+++ directory/shared/branches/m1/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
Sat Feb  5 20:32:53 2011
@@ -41,7 +41,7 @@ import org.dom4j.Element;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapResultDsml implements DsmlDecorator
+public class LdapResultDsml implements DsmlDecorator<LdapResult>
 {
     /** The LDAP Result to decorate */
     private LdapResult result;
@@ -212,4 +212,13 @@ public class LdapResultDsml implements D
     {
         result.setResultCode( resultCode );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public LdapResult getDecorated()
+    {
+        return result;
+    }
 }



Mime
View raw message