directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065849 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec: ./ controls/replication/syncDoneValue/ search/controls/persistentSearch/
Date Mon, 31 Jan 2011 23:21:40 GMT
Author: akarasulu
Date: Mon Jan 31 23:21:28 2011
New Revision: 1065849

URL: http://svn.apache.org/viewvc?rev=1065849&view=rev
Log:
added new sync done value control factor

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueFactory.java
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java?rev=1065849&r1=1065848&r2=1065849&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.java
Mon Jan 31 23:21:28 2011
@@ -30,6 +30,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.ldap.codec.controls.CascadeFactory;
 import org.apache.directory.shared.ldap.codec.controls.ManageDsaITFactory;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.ISyncDoneValue;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueFactory;
 import org.apache.directory.shared.ldap.codec.search.controls.entryChange.EntryChangeFactory;
 import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsFactory;
 import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchFactory;
@@ -86,6 +88,9 @@ public class DefaultLdapCodecService imp
 
         SubentriesFactory subentriesFactory = new SubentriesFactory( this );
         controlFactories.put( Subentries.OID, subentriesFactory );
+        
+        SyncDoneValueFactory syncDoneValueFactory = new SyncDoneValueFactory( this );
+        controlFactories.put( ISyncDoneValue.OID, syncDoneValueFactory );
     }
     
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java?rev=1065849&r1=1065848&r2=1065849&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/IControlFactory.java
Mon Jan 31 23:21:28 2011
@@ -37,11 +37,11 @@ public interface IControlFactory<C exten
     
     D newCodecControl();
     
-    D decorate( C control );
+    D decorate( C modelControl );
     
     C newControl();
     
-    javax.naming.ldap.Control toJndiControl( C control ) throws EncoderException;
+    javax.naming.ldap.Control toJndiControl( C modelControl ) throws EncoderException;
     
-    C fromJndiControl( javax.naming.ldap.Control control ) throws DecoderException;
+    C fromJndiControl( javax.naming.ldap.Control jndiControl ) throws DecoderException;
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java?rev=1065849&r1=1065848&r2=1065849&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueDecorator.java
Mon Jan 31 23:21:28 2011
@@ -60,6 +60,18 @@ public class SyncDoneValueDecorator exte
     
 
     /**
+     * Creates a new instance of SyncDoneValueDecorator.
+     *
+     * @param codec The LDAP codec
+     * @param control The control to be decorated
+     */
+    public SyncDoneValueDecorator( ILdapCodecService codec, ISyncDoneValue control )
+    {
+        super( codec, control );
+    }
+
+
+    /**
      * Compute the syncDoneValue length.
      * 0x30 L1
      * |

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueFactory.java?rev=1065849&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueFactory.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncDoneValue/SyncDoneValueFactory.java
Mon Jan 31 23:21:28 2011
@@ -0,0 +1,120 @@
+/*
+ *   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.codec.controls.replication.syncDoneValue;
+
+
+import java.nio.ByteBuffer;
+
+import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.IControlFactory;
+import org.apache.directory.shared.ldap.codec.ILdapCodecService;
+
+
+/**
+ * A {@link IControlFactory} which creates {@link ISyncDoneValue} controls.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SyncDoneValueFactory implements IControlFactory<ISyncDoneValue, SyncDoneValueDecorator>
+{
+    
+    private ILdapCodecService codec;
+    
+
+    /**
+     * Creates a new instance of SyncDoneValueFactory.
+     *
+     */
+    public SyncDoneValueFactory( ILdapCodecService codec )
+    {
+        this.codec = codec;
+    }
+    
+
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return ISyncDoneValue.OID;
+    }
+
+    
+    /**
+     * 
+     * {@inheritDoc}
+     */
+    public SyncDoneValueDecorator newCodecControl()
+    {
+        return new SyncDoneValueDecorator( codec );
+    }
+    
+
+    public SyncDoneValueDecorator decorate( ISyncDoneValue control )
+    {
+        SyncDoneValueDecorator decorator = null;
+        
+        // protect against double decoration
+        if ( control instanceof SyncDoneValueDecorator )
+        {
+            decorator = ( SyncDoneValueDecorator ) control;
+        }
+        else
+        {
+            decorator = new SyncDoneValueDecorator( codec, control );
+        }
+        
+        return decorator;
+    }
+
+    
+    public ISyncDoneValue newControl()
+    {
+        return new SyncDoneValue();
+    }
+    
+
+    public Control toJndiControl( ISyncDoneValue control ) throws EncoderException
+    {
+        SyncDoneValueDecorator decorator = decorate( control );
+        ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
+        decorator.encode( bb );
+        bb.flip();
+        return new BasicControl( control.getOid(), control.isCritical(), decorator.getValue()
);
+    }
+
+    
+    public ISyncDoneValue fromJndiControl( Control jndi ) throws DecoderException
+    {
+        SyncDoneValueDecorator decorator = newCodecControl();
+        decorator.setCritical( jndi.isCritical() );
+        decorator.setValue( jndi.getEncodedValue() );
+        byte[] controlBytes = new byte[ decorator.computeLength() ];
+        decorator.decode( controlBytes );
+        return decorator.getDecorated();
+    }
+
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java?rev=1065849&r1=1065848&r2=1065849&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
Mon Jan 31 23:21:28 2011
@@ -63,6 +63,7 @@ public class PersistentSearchFactory imp
     
     public PersistentSearchDecorator decorate( PersistentSearch control )
     {
+        // protect against double decoration
         if ( control instanceof PersistentSearchDecorator )
         {
             return ( PersistentSearchDecorator ) control;
@@ -86,8 +87,7 @@ public class PersistentSearchFactory imp
         ByteBuffer buf = ByteBuffer.allocate( decorator.computeLength() );
         decorator.encode( buf );
         buf.flip();
-        BasicControl jndi = new BasicControl( control.getOid(), control.isCritical(), buf.array()
);
-        return jndi;
+        return new BasicControl( control.getOid(), control.isCritical(), buf.array() );
     }
     
     



Mime
View raw message