directory-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1065856&view=rev
Log:
added sync request value control factory

Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncRequestValue/SyncRequestValueFactory.java
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/DefaultLdapCodecService.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=1065856&r1=1065855&r2=1065856&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:35:06 2011
@@ -34,6 +34,8 @@ import org.apache.directory.shared.ldap.
 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.syncRequestValue.ISyncRequestValue;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueFactory;
 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;
@@ -101,6 +103,9 @@ public class DefaultLdapCodecService imp
         
         SyncModifyDnFactory syncModifyDnFactory = new SyncModifyDnFactory( this );
         controlFactories.put( ISyncModifyDn.OID, syncModifyDnFactory );
+        
+        SyncRequestValueFactory syncRequestValueFactory = new SyncRequestValueFactory( this
);
+        controlFactories.put( ISyncRequestValue.OID, syncRequestValueFactory );
     }
     
 

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