directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r752968 - in /directory/shared/branches/shared-replication/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/actions/ main/java/org/apache/directory/shared/ldap/codec/extended/opera...
Date Thu, 12 Mar 2009 18:47:52 GMT
Author: elecharny
Date: Thu Mar 12 18:47:51 2009
New Revision: 752968

URL: http://svn.apache.org/viewvc?rev=752968&view=rev
Log:
o Added the error code for the CancelRequest
o Added the CancelRequest class, and the associated tests

Added:
    directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/Cancel.java
      - copied unchanged from r752739, directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/cancel/Cancel.java
    directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java
    directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelRequestTest.java
      - copied, changed from r752915, directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelTest.java
Modified:
    directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
    directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
    directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java

Modified: directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?rev=752968&r1=752967&r2=752968&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
(original)
+++ directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
Thu Mar 12 18:47:51 2009
@@ -60,11 +60,11 @@
      * authMethodNotSupported                   (7),
      * strongAuthRequired                       (8), 
      *                                          -- 9 reserved -- 
-     * referral                                 (10), -- new 
-     * adminLimitExceeded                       (11), -- new 
-     * unavailableCriticalExtension             (12), -- new 
-     * confidentialityRequired                  (13), -- new 
-     * saslBindInProgress                       (14), -- new
+     * referral                                 (10), 
+     * adminLimitExceeded                       (11), 
+     * unavailableCriticalExtension             (12), 
+     * confidentialityRequired                  (13), 
+     * saslBindInProgress                       (14),
      * noSuchAttribute                          (16), 
      * undefinedAttributeType                   (17), 
      * inappropriateMatching                    (18), 
@@ -95,8 +95,9 @@
      *                                          -- 70 reserved for CLDAP --
      * affectsMultipleDSAs                      (71), -- new 
      *                                          -- 72-79 unused -- 
-     * other                                    (80) 
-     * }                                        -- 81-90 reserved for APIs --
+     * other                                    (80),
+     * ...
+     * }
      */
     private ResultCodeEnum resultCode;
 

Modified: directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java?rev=752968&r1=752967&r2=752968&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
(original)
+++ directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
Thu Mar 12 18:47:51 2009
@@ -79,12 +79,12 @@
 
         try
         {
-            resultCode = ResultCodeEnum.getResultCode( IntegerDecoder.parse( value, 0, 90
) );
+            resultCode = ResultCodeEnum.getResultCode( IntegerDecoder.parse( value, 0, ResultCodeEnum.UNKNOWN.getResultCode()
) );
         }
         catch ( IntegerDecoderException ide )
         {
             log.error( "The result code " + StringTools.dumpBytes( value.getData() ) + "
is invalid : "
-                + ide.getMessage() + ". The result code must be between (0 .. 90)" );
+                + ide.getMessage() + ". The result code must be between (0 .. 121)" );
 
             throw new DecoderException( ide.getMessage() );
         }
@@ -129,6 +129,10 @@
             case NOT_ALLOWED_ON_RDN:
             case ENTRY_ALREADY_EXISTS:
             case AFFECTS_MULTIPLE_DSAS:
+            case CANCELED:
+            case CANNOT_CANCEL:
+            case TOO_LATE:
+            case NO_SUCH_OPERATION:
                 ldapResult.setResultCode( resultCode );
                 break;
 

Modified: directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java?rev=752968&r1=752967&r2=752968&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
(original)
+++ directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
Thu Mar 12 18:47:51 2009
@@ -643,6 +643,45 @@
     OTHER( 80 ),
     
     /**
+     * This error code is returned when an operation has been canceled using
+     * the Cancel extended operation. 
+     */
+    CANCELED( 118 ),
+    
+    
+    /**
+     * This error code is returned if the server has no knowledge of
+     * the operation requested for cancelation.
+     */
+    NO_SUCH_OPERATION( 119 ),
+    
+    
+    /**
+     * The tooLate resultCode is returned to indicate that it is too late to
+     * cancel the outstanding operation.  For example, the server may return
+     * tooLate for a request to cancel an outstanding modify operation which
+     * has already committed updates to the underlying data store.
+     */
+    TOO_LATE( 120 ),
+    
+    /**
+     * The cannotCancel resultCode is returned if the identified operation
+     * does not support cancelation or the cancel operation could not be
+     * performed.  The following classes of operations are not cancelable:
+     *
+     * -  operations which have no response,
+     *
+     * -  operations which create, alter, or destroy authentication and/or
+     *    authorization associations,
+     *
+     * -  operations which establish, alter, or tear-down security services,
+     *    and
+     *
+     * -  operations which abandon or cancel other operations.
+     */
+    CANNOT_CANCEL( 121 ),
+    
+    /**
      * A unknown result code to cover all the other cases
      */
     // -- 15 unused --
@@ -653,7 +692,7 @@
     // -- 70 reserved for CLDAP --
     // -- 72-79 unused --
     // -- 81-90 reserved for APIs --
-    UNKNOWN( 99 );
+    UNKNOWN( 122 );
     
     /** Stores the integer value of each element of the enumeration */
     private int value;
@@ -724,6 +763,7 @@
         set.add( ResultCodeEnum.COMPARE_FALSE );
         set.add( ResultCodeEnum.REFERRAL );
         set.add( ResultCodeEnum.SASL_BIND_IN_PROGRESS );
+        set.add( ResultCodeEnum.CANCELED );
         NON_ERRONEOUS_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -844,6 +884,9 @@
         set.add( ResultCodeEnum.ADMIN_LIMIT_EXCEEDED );
         set.add( ResultCodeEnum.UNWILLING_TO_PERFORM );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANNOT_CANCEL );
+        set.add( ResultCodeEnum.TOO_LATE );
+        set.add( ResultCodeEnum.NO_SUCH_OPERATION );
         SERVICE_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -943,7 +986,7 @@
      */
     public static final Set<ResultCodeEnum> BIND_CODES;
     static
-    {
+    { 	
         Set<ResultCodeEnum> set = new HashSet<ResultCodeEnum>();
         set.add( ResultCodeEnum.BUSY );
         set.add( ResultCodeEnum.OTHER );
@@ -963,6 +1006,7 @@
         set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
         set.add( ResultCodeEnum.INAPPROPRIATE_AUTHENTICATION );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         BIND_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1016,6 +1060,7 @@
         set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
         set.add( ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         SEARCH_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1077,6 +1122,7 @@
         set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
         set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         MODIFY_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1136,6 +1182,7 @@
         set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
         set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         ADD_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1183,6 +1230,7 @@
         set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
         set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         DELETE_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1240,6 +1288,7 @@
         set.add( ResultCodeEnum.CONFIDENTIALITY_REQUIRED );
         set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
         set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
+        set.add( ResultCodeEnum.CANCELED );
         MODIFYDN_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1293,6 +1342,7 @@
         set.add( ResultCodeEnum.LOOP_DETECT );
         set.add( ResultCodeEnum.REFERRAL );
         set.add( ResultCodeEnum.OTHER );
+        set.add( ResultCodeEnum.CANCELED );
         COMPARE_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1385,6 +1435,7 @@
         set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
         set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
         set.add( ResultCodeEnum.OTHER );
+        set.add( ResultCodeEnum.CANCELED );
         EXTENDED_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1481,6 +1532,10 @@
         set.add( ResultCodeEnum.OBJECT_CLASS_MODS_PROHIBITED );
         set.add( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS );
         set.add( ResultCodeEnum.OTHER );
+        set.add( ResultCodeEnum.CANNOT_CANCEL );
+        set.add( ResultCodeEnum.TOO_LATE );
+        set.add( ResultCodeEnum.NO_SUCH_OPERATION );
+        set.add( ResultCodeEnum.CANCELED );
         ALL_CODES = Collections.unmodifiableSet( set );
     }
 
@@ -1540,6 +1595,10 @@
             case 69 : return OBJECT_CLASS_MODS_PROHIBITED;
             case 71 : return AFFECTS_MULTIPLE_DSAS;
             case 80 : return OTHER;
+            case 118: return CANCELED;
+            case 129: return NO_SUCH_OPERATION;
+            case 120: return TOO_LATE;
+            case 121: return CANNOT_CANCEL;
             default : return UNKNOWN;
         }
     }

Added: directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java?rev=752968&view=auto
==============================================================================
--- directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java
(added)
+++ directory/shared/branches/shared-replication/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java
Thu Mar 12 18:47:51 2009
@@ -0,0 +1,166 @@
+/*
+ *  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.extended;
+
+
+import javax.naming.NamingException;
+import javax.naming.ldap.ExtendedResponse;
+
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.codec.extended.operations.cancel.Cancel;
+import org.apache.directory.shared.ldap.codec.extended.operations.cancel.CancelDecoder;
+import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
+import org.apache.directory.shared.ldap.message.ResultResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Implement the extended Cancel Request as described in RFC 3909.
+ * 
+ * It's grammar is :
+ * 
+ * cancelRequestValue ::= SEQUENCE {
+ *        cancelID        MessageID
+ *                        -- MessageID is as defined in [RFC2251]
+ * }
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CancelRequest extends ExtendedRequestImpl
+{
+	/** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( CancelRequest.class );
+
+    /** The cancelId of the request to be canceled */
+    private int cancelId;
+
+    /** The requestName for this extended request */
+    public static final String EXTENSION_OID = "1.3.6.1.1.8";
+
+    /**
+     * 
+     * Creates a new instance of CancelRequest.
+     *
+     * @param messageId the message id
+     * @param cancelId the message id of the request to cancel
+     */
+    public CancelRequest( int messageId, int cancelId )
+    {
+        super( messageId );
+        setOid( EXTENSION_OID );
+        
+        this.cancelId = cancelId;
+    }
+
+    
+    /**
+     * Encode the request
+     */
+    private void encodePayload() throws EncoderException
+    {
+        Cancel cancel = new Cancel();
+        cancel.setCancelId( this.cancelId );
+
+        payload = cancel.encode( null ).array();
+    }
+    
+    /**
+     * Gets the extended request's <b>requestValue</b> portion of the PDU. The
+     * form of the data is request specific and is determined by the extended
+     * request OID.
+     * 
+     * @return byte array of data
+     */
+    public byte[] getPayload()
+    {
+        if ( payload == null )
+        {
+            try
+            {
+                encodePayload();
+            }
+            catch ( EncoderException e )
+            {
+                LOG.error( "Failed to encode payload GracefulShutdownRequest", e );
+                throw new RuntimeException( e );
+            }
+        }
+        
+        return super.getPayload();
+    }
+
+
+    /**
+     * Sets the extended request's <b>requestValue</b> portion of the PDU.
+     * 
+     * @param payload byte array of data encapsulating ext. req. parameters
+     */
+    public void setPayload( byte[] payload ) 
+    {
+        CancelDecoder decoder = new CancelDecoder();
+        
+        try
+        {
+            Cancel cancel = ( Cancel ) decoder.decode( payload );
+
+            if ( payload != null )
+            {
+                this.payload = new byte[ payload.length ];
+                System.arraycopy( payload, 0, this.payload, 0, payload.length );
+            } else {
+                this.payload = null;
+            }
+            this.cancelId = cancel.getCancelId();
+        }
+        catch ( DecoderException e )
+        {
+            LOG.error( "failed to decode payload", e );
+            throw new RuntimeException( e );
+        }
+    }
+
+
+    public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset,
int length )
+        throws NamingException
+    {
+        return ( ExtendedResponse ) getResultResponse();
+    }
+
+
+    public byte[] getEncodedValue()
+    {
+        return getPayload();
+    }
+
+
+    public ResultResponse getResultResponse()
+    {
+        if ( response == null )
+        {
+            //response = new CancelResponse( getCancelId() );
+        }
+
+        return response;
+    }
+}
+

Copied: directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelRequestTest.java
(from r752915, directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelRequestTest.java?p2=directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelRequestTest.java&p1=directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelTest.java&r1=752915&r2=752968&rev=752968&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelTest.java
(original)
+++ directory/shared/branches/shared-replication/ldap/src/test/java/org/apache/directory/shared/ldap/codec/extended/operations/CancelRequestTest.java
Thu Mar 12 18:47:51 2009
@@ -43,7 +43,7 @@
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CancelTest
+public class CancelRequestTest
 {
 	/**
 	 * Test the normal Cancel message



Mime
View raw message