directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1072829 - in /directory/shared/branches/akarasulu: ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/
Date Mon, 21 Feb 2011 03:05:43 GMT
Author: akarasulu
Date: Mon Feb 21 03:05:42 2011
New Revision: 1072829

URL: http://svn.apache.org/viewvc?rev=1072829&view=rev
Log:
DISHARED-86: implement the Cancel extOp

Added:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelRequestDecorator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelResponseDecorator.java
Modified:
    directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestDecorator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java

Modified: directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestDecorator.java?rev=1072829&r1=1072828&r2=1072829&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestDecorator.java
(original)
+++ directory/shared/branches/akarasulu/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestDecorator.java
Mon Feb 21 03:05:42 2011
@@ -37,8 +37,8 @@ import org.apache.directory.shared.util.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ExtendedRequestDecorator extends SingleReplyRequestDecorator<ExtendedRequest<ExtendedResponse>,ExtendedResponse>

-    implements ExtendedRequest<ExtendedResponse>
+public class ExtendedRequestDecorator<Q extends ExtendedRequest<P>, P extends ExtendedResponse>

+    extends SingleReplyRequestDecorator<Q,P> implements ExtendedRequest<P>
 {
     /** The extended request length */
     private int extendedRequestLength;
@@ -46,7 +46,7 @@ public class ExtendedRequestDecorator ex
     /** The OID length */
     private byte[] requestNameBytes;
 
-    private byte[] requestValue;
+    protected byte[] requestValue;
 
 
     /**
@@ -54,7 +54,7 @@ public class ExtendedRequestDecorator ex
      *
      * @param decoratedMessage the decorated ExtendedRequest
      */
-    public ExtendedRequestDecorator( LdapCodecService codec, ExtendedRequest<ExtendedResponse>
decoratedMessage )
+    public ExtendedRequestDecorator( LdapCodecService codec, Q decoratedMessage )
     {
         super( codec, decoratedMessage );
     }

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java?rev=1072829&r1=1072828&r2=1072829&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
Mon Feb 21 03:05:42 2011
@@ -22,6 +22,7 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
 import org.apache.directory.shared.ldap.extras.extended.CancelRequestImpl;
 import org.apache.directory.shared.ldap.extras.extended.CancelResponseImpl;
 import org.apache.directory.shared.ldap.extras.extended.CancelRequest;
@@ -34,8 +35,17 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CancelFactory implements ExtendedRequestFactory<CancelRequestImpl, CancelResponseImpl>
+public class CancelFactory implements ExtendedRequestFactory<CancelRequest, CancelResponse>
 {
+    private LdapCodecService codec;
+    
+    
+    public CancelFactory( LdapCodecService codec )
+    {
+        this.codec = codec;
+    }
+    
+    
     /**
      * {@inheritDoc}
      */
@@ -50,7 +60,7 @@ public class CancelFactory implements Ex
      */
     public CancelRequest newRequest()
     {
-        return new CancelRequestImpl();
+        return new CancelRequestDecorator( codec, new CancelRequestImpl() );
     }
 
 
@@ -59,7 +69,7 @@ public class CancelFactory implements Ex
      */
     public CancelResponse newResponse( byte[] encodedValue ) throws DecoderException
     {
-        CancelResponse response = new CancelResponseImpl();
+        CancelResponseDecorator response = new CancelResponseDecorator( codec, new CancelResponseImpl()
);
         response.setResponseValue( encodedValue );
         return response;
     }

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelRequestDecorator.java?rev=1072829&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelRequestDecorator.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelRequestDecorator.java
Mon Feb 21 03:05:42 2011
@@ -0,0 +1,126 @@
+/*
+ *   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.extras.extended.ads_impl;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.CancelRequest;
+import org.apache.directory.shared.ldap.extras.extended.CancelResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A Decorator for CancelRequests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CancelRequestDecorator extends ExtendedRequestDecorator<CancelRequest,CancelResponse>
implements CancelRequest
+{
+    private static final Logger LOG = LoggerFactory.getLogger( CancelRequestDecorator.class
);
+    
+    
+    public CancelRequestDecorator( LdapCodecService codec, CancelRequest decoratedMessage
)
+    {
+        super( codec, decoratedMessage );
+    }
+
+
+    public int getCancelId()
+    {
+        return getDecorated().getCancelId();
+    }
+
+
+    public void setCancelId( int cancelId )
+    {
+        if ( cancelId == getCancelId() )
+        {
+            return;
+        }
+        
+        this.requestValue = null;
+        getDecorated().setCancelId( cancelId );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public byte[] getRequestValue()
+    {
+        if ( requestValue == null )
+        {
+            try
+            {
+                Cancel cancel = new Cancel();
+                cancel.setCancelId( getDecorated().getCancelId() );
+    
+                requestValue = cancel.encode().array();
+            }
+            catch ( EncoderException e )
+            {
+                LOG.error( I18n.err( I18n.ERR_04164 ), e );
+                throw new RuntimeException( e );
+            }
+        }
+    
+        return requestValue;
+    }
+
+    
+    /**
+     * Sets the extended request's <b>requestValue</b> portion of the PDU.
+     *
+     * @param payload byte array of data encapsulating ext. req. parameters
+     */
+    @Override
+    public void setRequestValue( byte[] requestValue )
+    {
+        CancelDecoder decoder = new CancelDecoder();
+    
+        try
+        {
+            Cancel cancel = ( Cancel ) decoder.decode( requestValue );
+    
+            if ( requestValue != null )
+            {
+                this.requestValue = new byte[requestValue.length];
+                System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length
);
+            }
+            else
+            {
+                this.requestValue = null;
+            }
+            
+            getDecorated().setCancelId( cancel.getCancelId() );
+        }
+        catch ( DecoderException e )
+        {
+            LOG.error( I18n.err( I18n.ERR_04165 ), e );
+            throw new RuntimeException( e );
+        }
+    }
+}

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelResponseDecorator.java?rev=1072829&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelResponseDecorator.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelResponseDecorator.java
Mon Feb 21 03:05:42 2011
@@ -0,0 +1,46 @@
+/*
+ *   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.extras.extended.ads_impl;
+
+
+import org.apache.directory.shared.ldap.codec.api.ExtendedResponseDecorator;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.CancelResponse;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+
+
+/**
+ * A Decorator for CancelResponses.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CancelResponseDecorator extends ExtendedResponseDecorator implements CancelResponse
+{
+    /**
+     * Creates a new instance of CancelResponseDecorator.
+     *
+     * @param codec
+     * @param decoratedMessage
+     */
+    public CancelResponseDecorator( LdapCodecService codec, ExtendedResponse decoratedMessage
)
+    {
+        super( codec, decoratedMessage );
+    }
+}



Mime
View raw message