directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1065854 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec: ./ controls/replication/syncmodifydn/
Date Mon, 31 Jan 2011 23:31:30 GMT
Author: akarasulu
Date: Mon Jan 31 23:31:30 2011
New Revision: 1065854

URL: http://svn.apache.org/viewvc?rev=1065854&view=rev
Log:
added modify dn control factory

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnFactory.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/controls/replication/syncmodifydn/SyncModifyDnDecorator.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=1065854&r1=1065853&r2=1065854&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:31:30 2011
@@ -32,6 +32,10 @@ import org.apache.directory.shared.ldap.
 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.controls.replication.syncInfoValue.ISyncInfoValue;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueFactory;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncmodifydn.ISyncModifyDn;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncmodifydn.SyncModifyDnFactory;
 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;
@@ -91,6 +95,12 @@ public class DefaultLdapCodecService imp
         
         SyncDoneValueFactory syncDoneValueFactory = new SyncDoneValueFactory( this );
         controlFactories.put( ISyncDoneValue.OID, syncDoneValueFactory );
+        
+        SyncInfoValueFactory syncInfoValueFactory = new SyncInfoValueFactory( this );
+        controlFactories.put( ISyncInfoValue.OID, syncInfoValueFactory );
+        
+        SyncModifyDnFactory syncModifyDnFactory = new SyncModifyDnFactory( this );
+        controlFactories.put( ISyncModifyDn.OID, syncModifyDnFactory );
     }
     
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnDecorator.java?rev=1065854&r1=1065853&r2=1065854&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncmodifydn/SyncModifyDnDecorator.java
Mon Jan 31 23:31:30 2011
@@ -87,6 +87,12 @@ public class SyncModifyDnDecorator exten
     }
 
 
+    public SyncModifyDnDecorator( ILdapCodecService codec, ISyncModifyDn control )
+    {
+        super( codec, control );
+    }
+
+
     /**
      * Compute the SyncStateValue length.
      * 

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



Mime
View raw message