You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2011/01/29 10:45:19 UTC
svn commit: r1064988 [1/2] - in /directory:
apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/
apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/
apacheds/trunk/protocol-ldap/src/main/java/org/apach...
Author: akarasulu
Date: Sat Jan 29 09:45:18 2011
New Revision: 1064988
URL: http://svn.apache.org/viewvc?rev=1064988&view=rev
Log:
fixing and migrating more controls (replication related)
Added:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/ISyncInfoValue.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueContainer.java
- copied, changed from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java
- copied, changed from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueGrammar.java
- copied, changed from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueStatesEnum.java
- copied, changed from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java
Removed:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlDecoder.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlGrammar.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlStatesEnum.java
Modified:
directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueTags.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/replication/SyncInfoValueControlTest.java
Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=1064988&r1=1064987&r2=1064988&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Sat Jan 29 09:45:18 2011
@@ -86,8 +86,9 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControlContainer;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControlDecoder;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlContainer;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueDecorator;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueContainer;
import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlDecoder;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.ISyncRequestValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueDecorator;
@@ -193,7 +194,7 @@ public abstract class ServerContext impl
ADS_CONTROLS.put( PersistentSearch.OID, ControlEnum.PERSISTENT_SEARCH_CONTROL );
ADS_CONTROLS.put( Subentries.OID, ControlEnum.SUBENTRIES_CONTROL );
ADS_CONTROLS.put( SyncDoneValueControl.CONTROL_OID, ControlEnum.SYNC_DONE_VALUE_CONTROL );
- ADS_CONTROLS.put( SyncInfoValueControl.CONTROL_OID, ControlEnum.SYNC_INFO_VALUE_CONTROL );
+ ADS_CONTROLS.put( ISyncInfoValue.OID, ControlEnum.SYNC_INFO_VALUE_CONTROL );
ADS_CONTROLS.put( ISyncModifyDn.OID, ControlEnum.SYNC_MODIFY_DN_CONTROL );
ADS_CONTROLS.put( ISyncRequestValue.OID, ControlEnum.SYNC_REQUEST_VALUE_CONTROL );
ADS_CONTROLS.put( ISyncStateValue.OID, ControlEnum.SYNC_STATE_VALUE_CONTROL );
@@ -480,10 +481,10 @@ public abstract class ServerContext impl
break;
case SYNC_INFO_VALUE_CONTROL:
- control = new SyncInfoValueControl();
+ control = new SyncInfoValueDecorator();
SyncInfoValueControlDecoder syncInfoValueControlDecoder = new SyncInfoValueControlDecoder();
- SyncInfoValueControlContainer syncInfoValueControlContainer = new SyncInfoValueControlContainer();
- syncInfoValueControlContainer.setSyncInfoValueControl( ( SyncInfoValueControl ) control );
+ SyncInfoValueContainer syncInfoValueControlContainer = new SyncInfoValueContainer();
+ syncInfoValueControlContainer.setSyncInfoValueControl( ( SyncInfoValueDecorator ) control );
bb = ByteBuffer.allocate( jndiControl.getEncodedValue().length );
bb.put( jndiControl.getEncodedValue() ).flip();
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=1064988&r1=1064987&r2=1064988&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Sat Jan 29 09:45:18 2011
@@ -60,7 +60,7 @@ import org.apache.directory.server.i18n.
import org.apache.directory.shared.ldap.model.message.controls.Cascade;
import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.ISyncRequestValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.ISyncStateValue;
import org.apache.directory.shared.ldap.model.message.controls.EntryChange;
@@ -178,7 +178,7 @@ public class DefaultPartitionNexus exten
EntryChange.OID, Subentries.OID, ManageDsaIT.OID,
Cascade.OID, PagedResults.OID,
// Replication controls
- SyncDoneValueControl.CONTROL_OID, SyncInfoValueControl.CONTROL_OID, ISyncRequestValue.OID,
+ SyncDoneValueControl.CONTROL_OID, ISyncInfoValue.OID, ISyncRequestValue.OID,
ISyncStateValue.OID );
// Add the objectClasses
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=1064988&r1=1064987&r2=1064988&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java Sat Jan 29 09:45:18 2011
@@ -63,7 +63,7 @@ import org.apache.directory.server.proto
import org.apache.directory.shared.ldap.model.message.controls.Cascade;
import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.ISyncRequestValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.ISyncStateValue;
import org.apache.directory.shared.ldap.model.message.controls.EntryChange;
@@ -243,7 +243,7 @@ public class LdapServer extends Director
this.supportedControls.add( PagedResults.OID );
// Replication controls
this.supportedControls.add( SyncDoneValueControl.CONTROL_OID );
- this.supportedControls.add( SyncInfoValueControl.CONTROL_OID );
+ this.supportedControls.add( ISyncInfoValue.OID );
this.supportedControls.add( ISyncRequestValue.OID );
this.supportedControls.add( ISyncStateValue.OID );
}
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1064988&r1=1064987&r2=1064988&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java Sat Jan 29 09:45:18 2011
@@ -42,7 +42,7 @@ import org.apache.directory.server.core.
import org.apache.directory.shared.ldap.codec.controls.ManageDsaITDecorator;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControlDecoder;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControlDecoder;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueDecorator;
import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.ISyncStateValue;
@@ -432,7 +432,7 @@ public class SyncReplConsumer implements
LOG.debug( "............... inside handleSyncInfo ..............." );
byte[] syncinfo = syncInfoResp.getResponseValue();
- SyncInfoValueControl syncInfoValue = ( SyncInfoValueControl ) decoder.decode( syncinfo, null );
+ ISyncInfoValue syncInfoValue = ( ISyncInfoValue ) decoder.decode( syncinfo, null );
byte[] cookie = syncInfoValue.getCookie();
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java?rev=1064988&r1=1064987&r2=1064988&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplProvider.java Sat Jan 29 09:45:18 2011
@@ -49,7 +49,8 @@ import org.apache.directory.server.ldap.
import org.apache.directory.server.ldap.handlers.SearchTimeLimitingMonitor;
import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl;
-import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.ISyncInfoValue;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueDecorator;
import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.ISyncRequestValue;
import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueDecorator;
import org.apache.directory.shared.ldap.codec.controls.replication.syncmodifydn.SyncModifyDnDecorator;
@@ -325,9 +326,9 @@ public class SyncReplProvider implements
if ( refreshNPersist )
{
IntermediateResponse intermResp = new IntermediateResponseImpl( req.getMessageId() );
- intermResp.setResponseName( SyncInfoValueControl.CONTROL_OID );
+ intermResp.setResponseName( ISyncInfoValue.OID );
- SyncInfoValueControl syncInfo = new SyncInfoValueControl( SynchronizationInfoEnum.NEW_COOKIE );
+ SyncInfoValueDecorator syncInfo = new SyncInfoValueDecorator( SynchronizationInfoEnum.NEW_COOKIE );
syncInfo.setCookie( cookie );
intermResp.setResponseValue( syncInfo.getValue() );
@@ -418,9 +419,9 @@ public class SyncReplProvider implements
cookie = Strings.getBytesUtf8(replicaLog.getId() + REPLICA_ID_DELIM + contextCsn);
IntermediateResponse intermResp = new IntermediateResponseImpl( req.getMessageId() );
- intermResp.setResponseName( SyncInfoValueControl.CONTROL_OID );
+ intermResp.setResponseName( ISyncInfoValue.OID );
- SyncInfoValueControl syncInfo = new SyncInfoValueControl( SynchronizationInfoEnum.NEW_COOKIE );
+ SyncInfoValueDecorator syncInfo = new SyncInfoValueDecorator( SynchronizationInfoEnum.NEW_COOKIE );
syncInfo.setCookie( cookie );
intermResp.setResponseValue( syncInfo.getValue() );
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/ISyncInfoValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/ISyncInfoValue.java?rev=1064988&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/ISyncInfoValue.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/ISyncInfoValue.java Sat Jan 29 09:45:18 2011
@@ -0,0 +1,107 @@
+/*
+ * 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.syncInfoValue;
+
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
+import org.apache.directory.shared.ldap.model.message.Control;
+
+
+/**
+ * A syncInfoValue object, as defined in RFC 4533
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface ISyncInfoValue extends Control
+{
+
+ /** This control OID */
+ public static final String OID = "1.3.6.1.4.1.4203.1.9.1.4";
+
+
+ /**
+ * Get the control type.
+ *
+ * @return the type : one of newCookie, refreshDelete, refreshPresent or syncIdSet
+ */
+ SynchronizationInfoEnum getType();
+
+
+ /**
+ * @param syncMode the syncMode to set
+ */
+ void setType( SynchronizationInfoEnum type );
+
+
+ /**
+ * @return the cookie
+ */
+ byte[] getCookie();
+
+
+ /**
+ * @param cookie the cookie to set
+ */
+ void setCookie( byte[] cookie );
+
+
+ /**
+ * @return the refreshDone
+ */
+ boolean isRefreshDone();
+
+
+ /**
+ * @param refreshDone the refreshDone to set
+ */
+ void setRefreshDone( boolean refreshDone );
+
+
+ /**
+ * @return the refreshDeletes
+ */
+ boolean isRefreshDeletes();
+
+
+ /**
+ * @param refreshDeletes the refreshDeletes to set
+ */
+ void setRefreshDeletes( boolean refreshDeletes );
+
+
+ /**
+ * @return the syncUUIDs
+ */
+ List<byte[]> getSyncUUIDs();
+
+
+ /**
+ * @param syncUUIDs the syncUUIDs to set
+ */
+ void setSyncUUIDs( List<byte[]> syncUUIDs );
+
+
+ /**
+ * @param syncUUIDs the syncUUIDs to set
+ */
+ void addSyncUUID( byte[] syncUUID );
+}
\ No newline at end of file
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java?rev=1064988&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValue.java Sat Jan 29 09:45:18 2011
@@ -0,0 +1,169 @@
+/*
+ * 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.syncInfoValue;
+
+
+import java.util.List;
+
+import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
+
+
+/**
+ * A simple {@link ISyncInfoValue} implementation to store control properties.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SyncInfoValue implements ISyncInfoValue
+{
+ /** The kind of syncInfoValue we are dealing with */
+ private SynchronizationInfoEnum type;
+
+ /** The cookie */
+ private byte[] cookie;
+
+ /** The refreshDone flag if we are dealing with refreshXXX syncInfo. Default to true */
+ private boolean refreshDone = true;
+
+ /** The refreshDeletes flag if we are dealing with syncIdSet syncInfo. Defaluts to false */
+ private boolean refreshDeletes = false;
+
+ /** The list of UUIDs if we are dealing with syncIdSet syncInfo */
+ private List<byte[]> syncUUIDs;
+
+ private boolean isCritical;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SynchronizationInfoEnum getType()
+ {
+ return type;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setType( SynchronizationInfoEnum type )
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getCookie()
+ {
+ return cookie;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCookie( byte[] cookie )
+ {
+ this.cookie = cookie;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRefreshDone()
+ {
+ return refreshDone;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRefreshDone( boolean refreshDone )
+ {
+ this.refreshDone = refreshDone;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isRefreshDeletes()
+ {
+ return refreshDeletes;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRefreshDeletes( boolean refreshDeletes )
+ {
+ this.refreshDeletes = refreshDeletes;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<byte[]> getSyncUUIDs()
+ {
+ return syncUUIDs;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setSyncUUIDs( List<byte[]> syncUUIDs )
+ {
+ this.syncUUIDs = syncUUIDs;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSyncUUID( byte[] syncUUID )
+ {
+ syncUUIDs.add( syncUUID );
+ }
+
+
+ public String getOid()
+ {
+ return OID;
+ }
+
+
+ public boolean isCritical()
+ {
+ return isCritical;
+ }
+
+
+ public void setCritical( boolean isCritical )
+ {
+ this.isCritical = isCritical;
+ }
+}
Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueContainer.java (from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueContainer.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueContainer.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java&r1=1064846&r2=1064988&rev=1064988&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControlContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueContainer.java Sat Jan 29 09:45:18 2011
@@ -28,29 +28,44 @@ import org.apache.directory.shared.asn1.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class SyncInfoValueControlContainer extends AbstractContainer
+public class SyncInfoValueContainer extends AbstractContainer
{
/** SyncInfoValueControl */
- private SyncInfoValueControl control;
+ private SyncInfoValueDecorator control;
/**
* Creates a new SyncInfoValueControlContainer object. We will store one grammar,
* it's enough ...
*/
- public SyncInfoValueControlContainer()
+ public SyncInfoValueContainer()
{
super();
+ this.control = new SyncInfoValueDecorator();
stateStack = new int[1];
- grammar = SyncInfoValueControlGrammar.getInstance();
- setTransition( SyncInfoValueControlStatesEnum.START_STATE );
+ grammar = SyncInfoValueGrammar.getInstance();
+ setTransition( SyncInfoValueStatesEnum.START_STATE );
+ }
+
+
+ /**
+ * Creates a new SyncInfoValueControlContainer object. We will store one grammar,
+ * it's enough ...
+ */
+ public SyncInfoValueContainer( SyncInfoValueDecorator control )
+ {
+ super();
+ this.control = control;
+ stateStack = new int[1];
+ grammar = SyncInfoValueGrammar.getInstance();
+ setTransition( SyncInfoValueStatesEnum.START_STATE );
}
/**
* @return Returns the syncInfoValue control.
*/
- public SyncInfoValueControl getSyncInfoValueControl()
+ public SyncInfoValueDecorator getSyncInfoValueControl()
{
return control;
}
@@ -62,11 +77,12 @@ public class SyncInfoValueControlContain
*
* @param control the SyncInfoValueControlCodec to set.
*/
- public void setSyncInfoValueControl( SyncInfoValueControl control )
+ public void setSyncInfoValueControl( SyncInfoValueDecorator control )
{
this.control = control;
}
+
/**
* Clean the container
*/
Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java (from r1064846, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java&r1=1064846&r2=1064988&rev=1064988&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueDecorator.java Sat Jan 29 09:45:18 2011
@@ -19,57 +19,47 @@
*/
package org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue;
+
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.DecoderException;
import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.codec.controls.AbstractControl;
+import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
import org.apache.directory.shared.util.Strings;
+
/**
* A syncInfoValue object, as defined in RFC 4533
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class SyncInfoValueControl extends AbstractControl
+public class SyncInfoValueDecorator extends ControlDecorator<ISyncInfoValue> implements ISyncInfoValue
{
- /** This control OID */
- public static final String CONTROL_OID = "1.3.6.1.4.1.4203.1.9.1.4";
-
- /** The kind of syncInfoValue we are dealing with */
- private SynchronizationInfoEnum type;
-
- /** The cookie */
- private byte[] cookie;
-
- /** The refreshDone flag if we are dealing with refreshXXX syncInfo. Default to true */
- private boolean refreshDone = true;
-
- /** The refreshDeletes flag if we are dealing with syncIdSet syncInfo. Defaluts to false */
- private boolean refreshDeletes = false;
-
- /** The list of UUIDs if we are dealing with syncIdSet syncInfo */
- private List<byte[]> syncUUIDs;
-
/** The syncUUIDs cumulative lentgh */
private int syncUUIDsLength;
+ private byte[] value;
+
+ /** An instance of this decoder */
+ private static final Asn1Decoder decoder = new Asn1Decoder();
+
/**
* The constructor for this codec. Dont't forget to set the type.
*/
- public SyncInfoValueControl()
+ public SyncInfoValueDecorator()
{
- super( CONTROL_OID );
-
- decoder = new SyncInfoValueControlDecoder();
+ super( new SyncInfoValue() );
}
@@ -78,7 +68,7 @@ public class SyncInfoValueControl extend
* @param type The kind of syncInfo we will store. Can be newCookie,
* refreshPresent, refreshDelete or syncIdSet
*/
- public SyncInfoValueControl( SynchronizationInfoEnum type )
+ public SyncInfoValueDecorator( SynchronizationInfoEnum type )
{
this();
@@ -90,109 +80,107 @@ public class SyncInfoValueControl extend
private int syncInfoValueLength;
/**
- * Get the control type.
- *
- * @return the type : one of newCookie, refreshDelete, refreshPresent or syncIdSet
+ * {@inheritDoc}
*/
public SynchronizationInfoEnum getType()
{
- return type;
+ return getDecorated().getType();
}
/**
- * @param syncMode the syncMode to set
+ * {@inheritDoc}
*/
public void setType( SynchronizationInfoEnum type )
{
- this.type = type;
+ this.getDecorated().setType( type );
// Initialize the arrayList if needed
- if ( ( type == SynchronizationInfoEnum.SYNC_ID_SET ) && ( syncUUIDs == null ) )
+ if ( ( type == SynchronizationInfoEnum.SYNC_ID_SET ) && ( getDecorated().getSyncUUIDs() == null ) )
{
- syncUUIDs = new ArrayList<byte[]>();
+ getDecorated().setSyncUUIDs( new ArrayList<byte[]>() );
}
}
/**
- * @return the cookie
+ * {@inheritDoc}
*/
public byte[] getCookie()
{
- return cookie;
+ return getDecorated().getCookie();
}
/**
- * @param cookie the cookie to set
+ * {@inheritDoc}
*/
public void setCookie( byte[] cookie )
{
- this.cookie = cookie;
+ getDecorated().setCookie( cookie );
}
/**
- * @return the refreshDone
+ * {@inheritDoc}
*/
public boolean isRefreshDone()
{
- return refreshDone;
+ return getDecorated().isRefreshDone();
}
/**
- * @param refreshDone the refreshDone to set
+ * {@inheritDoc}
*/
public void setRefreshDone( boolean refreshDone )
{
- this.refreshDone = refreshDone;
+ getDecorated().setRefreshDone( refreshDone );
}
/**
- * @return the refreshDeletes
+ * {@inheritDoc}
*/
public boolean isRefreshDeletes()
{
- return refreshDeletes;
+ return getDecorated().isRefreshDeletes();
}
/**
- * @param refreshDeletes the refreshDeletes to set
+ * {@inheritDoc}
*/
public void setRefreshDeletes( boolean refreshDeletes )
{
- this.refreshDeletes = refreshDeletes;
+ getDecorated().setRefreshDeletes( refreshDeletes );
}
/**
- * @return the syncUUIDs
+ * {@inheritDoc}
*/
public List<byte[]> getSyncUUIDs()
{
- return syncUUIDs;
+ return getDecorated().getSyncUUIDs();
}
/**
- * @param syncUUIDs the syncUUIDs to set
+ * {@inheritDoc}
*/
public void setSyncUUIDs( List<byte[]> syncUUIDs )
{
- this.syncUUIDs = syncUUIDs;
+ getDecorated().setSyncUUIDs( syncUUIDs );
}
/**
- * @param syncUUIDs the syncUUIDs to set
+ * {@inheritDoc}
*/
public void addSyncUUID( byte[] syncUUID )
{
- syncUUIDs.add( syncUUID );
+ getDecorated().addSyncUUID( syncUUID );
}
@@ -232,12 +220,12 @@ public class SyncInfoValueControl extend
// The mode length
syncInfoValueLength = 0;
- switch ( type )
+ switch ( getType() )
{
case NEW_COOKIE :
- if ( cookie != null )
+ if ( getCookie() != null )
{
- syncInfoValueLength = 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
+ syncInfoValueLength = 1 + TLV.getNbBytes( getCookie().length ) + getCookie().length;
}
else
{
@@ -251,13 +239,13 @@ public class SyncInfoValueControl extend
case REFRESH_DELETE :
case REFRESH_PRESENT :
- if ( cookie != null )
+ if ( getCookie() != null )
{
- syncInfoValueLength = 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
+ syncInfoValueLength = 1 + TLV.getNbBytes( getCookie().length ) + getCookie().length;
}
// The refreshDone flag, only if not true, as it default to true
- if ( !refreshDone )
+ if ( ! isRefreshDone() )
{
syncInfoValueLength += 1 + 1 + 1;
}
@@ -268,13 +256,13 @@ public class SyncInfoValueControl extend
return super.computeLength( valueLength );
case SYNC_ID_SET :
- if ( cookie != null )
+ if ( getCookie() != null )
{
- syncInfoValueLength = 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
+ syncInfoValueLength = 1 + TLV.getNbBytes( getCookie().length ) + getCookie().length;
}
// The refreshDeletes flag, default to false
- if ( refreshDeletes )
+ if ( isRefreshDeletes() )
{
syncInfoValueLength += 1 + 1 + 1;
}
@@ -282,9 +270,9 @@ public class SyncInfoValueControl extend
// The syncUUIDs if any
syncUUIDsLength = 0;
- if ( syncUUIDs.size() != 0 )
+ if ( getSyncUUIDs().size() != 0 )
{
- for ( byte[] syncUUID:syncUUIDs )
+ for ( byte[] syncUUID: getSyncUUIDs() )
{
int uuidLength = 1 + TLV.getNbBytes( syncUUID.length ) + syncUUID.length;
@@ -324,7 +312,7 @@ public class SyncInfoValueControl extend
buffer.put( UniversalTag.OCTET_STRING.getValue() );
buffer.put( TLV.getBytes( valueLength ) );
- switch ( type )
+ switch ( getType() )
{
case NEW_COOKIE :
// The first case : newCookie
@@ -332,14 +320,14 @@ public class SyncInfoValueControl extend
// As the OCTET_STRING is absorbed by the Application tag,
// we have to store the L and V separately
- if ( ( cookie == null ) || ( cookie.length == 0 ) )
+ if ( ( getCookie() == null ) || ( getCookie().length == 0 ) )
{
buffer.put( ( byte ) 0 );
}
else
{
- buffer.put( TLV.getBytes( cookie.length ) );
- buffer.put( cookie );
+ buffer.put( TLV.getBytes( getCookie().length ) );
+ buffer.put( getCookie() );
}
break;
@@ -350,15 +338,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDone flag
- if ( !refreshDone )
+ if ( ! isRefreshDone() )
{
- Value.encode( buffer, refreshDone );
+ Value.encode( buffer, isRefreshDone() );
}
break;
@@ -369,15 +357,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDone flag
- if ( !refreshDone )
+ if ( ! isRefreshDone() )
{
- Value.encode( buffer, refreshDone );
+ Value.encode( buffer, isRefreshDone() );
}
break;
@@ -388,15 +376,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDeletes flag if not false
- if ( refreshDeletes )
+ if ( isRefreshDeletes() )
{
- Value.encode( buffer, refreshDeletes );
+ Value.encode( buffer, isRefreshDeletes() );
}
// The syncUUIDs
@@ -404,9 +392,9 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncUUIDsLength ) );
// Loop on the UUIDs if any
- if ( syncUUIDs.size() != 0 )
+ if ( getSyncUUIDs().size() != 0 )
{
- for ( byte[] syncUUID:syncUUIDs )
+ for ( byte[] syncUUID: getSyncUUIDs() )
{
Value.encode( buffer , syncUUID );
}
@@ -429,22 +417,22 @@ public class SyncInfoValueControl extend
computeLength();
ByteBuffer buffer = ByteBuffer.allocate( valueLength );
- switch ( type )
+ switch ( getType() )
{
case NEW_COOKIE :
// The first case : newCookie
- buffer.put( (byte)SyncInfoValueTags.NEW_COOKIE_TAG.getValue() );
+ buffer.put( ( byte ) SyncInfoValueTags.NEW_COOKIE_TAG.getValue() );
// As the OCTET_STRING is absorbed by the Application tag,
// we have to store the L and V separately
- if ( ( cookie == null ) || ( cookie.length == 0 ) )
+ if ( ( getCookie() == null ) || ( getCookie().length == 0 ) )
{
buffer.put( ( byte ) 0 );
}
else
{
- buffer.put( TLV.getBytes( cookie.length ) );
- buffer.put( cookie );
+ buffer.put( TLV.getBytes( getCookie().length ) );
+ buffer.put( getCookie() );
}
break;
@@ -455,15 +443,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDone flag
- if ( !refreshDone )
+ if ( ! isRefreshDone() )
{
- Value.encode( buffer, refreshDone );
+ Value.encode( buffer, isRefreshDone() );
}
break;
@@ -474,15 +462,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDone flag
- if ( !refreshDone )
+ if ( ! isRefreshDone() )
{
- Value.encode( buffer, refreshDone );
+ Value.encode( buffer, isRefreshDone() );
}
break;
@@ -493,15 +481,15 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncInfoValueLength ) );
// The cookie, if any
- if ( cookie != null )
+ if ( getCookie() != null )
{
- Value.encode( buffer, cookie );
+ Value.encode( buffer, getCookie() );
}
// The refreshDeletes flag if not false
- if ( refreshDeletes )
+ if ( isRefreshDeletes() )
{
- Value.encode( buffer, refreshDeletes );
+ Value.encode( buffer, isRefreshDeletes() );
}
// The syncUUIDs
@@ -509,9 +497,9 @@ public class SyncInfoValueControl extend
buffer.put( TLV.getBytes( syncUUIDsLength ) );
// Loop on the UUIDs if any
- if ( syncUUIDs.size() != 0 )
+ if ( getSyncUUIDs().size() != 0 )
{
- for ( byte[] syncUUID:syncUUIDs )
+ for ( byte[] syncUUID: getSyncUUIDs() )
{
Value.encode( buffer , syncUUID );
}
@@ -540,32 +528,32 @@ public class SyncInfoValueControl extend
return false;
}
- SyncInfoValueControl otherControl = ( SyncInfoValueControl ) o;
+ SyncInfoValueDecorator otherControl = ( SyncInfoValueDecorator ) o;
- if ( syncUUIDs != null )
+ if ( getSyncUUIDs() != null )
{
- if ( otherControl.syncUUIDs == null )
+ if ( otherControl.getSyncUUIDs() == null )
{
return false;
}
// @TODO : check the UUIDs
- for ( @SuppressWarnings("unused") byte[] syncUuid : syncUUIDs )
+ for ( @SuppressWarnings("unused") byte[] syncUuid : getSyncUUIDs() )
{
}
}
else
{
- if ( otherControl.syncUUIDs != null )
+ if ( otherControl.getSyncUUIDs() != null )
{
return false;
}
}
- return ( refreshDeletes == otherControl.refreshDeletes ) &&
- ( refreshDone == otherControl.refreshDone ) &&
- ( type == otherControl.type ) &&
- ( Arrays.equals( cookie, otherControl.cookie ) );
+ return ( isRefreshDeletes() == otherControl.isRefreshDeletes() ) &&
+ ( isRefreshDone() == otherControl.isRefreshDone() ) &&
+ ( getType() == otherControl.getType() ) &&
+ ( Arrays.equals( getCookie(), otherControl.getCookie() ) );
}
@@ -582,54 +570,54 @@ public class SyncInfoValueControl extend
sb.append( " oid : " ).append( getOid() ).append( '\n' );
sb.append( " critical : " ).append( isCritical() ).append( '\n' );
- switch ( type )
+ switch ( getType() )
{
case NEW_COOKIE :
sb.append( " newCookie : '" ).
- append( Strings.dumpBytes(cookie) ).append( "'\n" );
+ append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
break;
case REFRESH_DELETE :
sb.append( " refreshDelete : \n" );
- if ( cookie != null )
+ if ( getCookie() != null )
{
sb.append( " cookie : '" ).
- append( Strings.dumpBytes(cookie) ).append( "'\n" );
+ append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
}
- sb.append( " refreshDone : " ).append( refreshDone ).append( '\n' );
+ sb.append( " refreshDone : " ).append( isRefreshDone() ).append( '\n' );
break;
case REFRESH_PRESENT :
sb.append( " refreshPresent : \n" );
- if ( cookie != null )
+ if ( getCookie() != null )
{
sb.append( " cookie : '" ).
- append( Strings.dumpBytes(cookie) ).append( "'\n" );
+ append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
}
- sb.append( " refreshDone : " ).append( refreshDone ).append( '\n' );
+ sb.append( " refreshDone : " ).append( isRefreshDone() ).append( '\n' );
break;
case SYNC_ID_SET :
sb.append( " syncIdSet : \n" );
- if ( cookie != null )
+ if ( getCookie() != null )
{
sb.append( " cookie : '" ).
- append( Strings.dumpBytes(cookie) ).append( "'\n" );
+ append( Strings.dumpBytes( getCookie() ) ).append( "'\n" );
}
- sb.append( " refreshDeletes : " ).append( refreshDeletes ).append( '\n' );
+ sb.append( " refreshDeletes : " ).append( isRefreshDeletes() ).append( '\n' );
sb.append( " syncUUIDS : " );
- if ( syncUUIDs.size() != 0 )
+ if ( getSyncUUIDs().size() != 0 )
{
boolean isFirst = true;
- for ( byte[] syncUUID:syncUUIDs )
+ for ( byte[] syncUUID: getSyncUUIDs() )
{
if ( isFirst )
{
@@ -655,4 +643,14 @@ public class SyncInfoValueControl extend
return sb.toString();
}
+
+
+ @Override
+ public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+ {
+ ByteBuffer bb = ByteBuffer.wrap( controlBytes );
+ SyncInfoValueContainer container = new SyncInfoValueContainer( this );
+ decoder.decode( bb, container );
+ return this;
+ }
}