You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/03/22 11:58:43 UTC
svn commit: r1668352 - in /directory/shared/trunk:
integ/src/test/java/org/apache/directory/api/ldap/codec/api/
ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/
ldap/codec/standalone/src/test/java/org/apache/directory...
Author: elecharny
Date: Sun Mar 22 10:58:42 2015
New Revision: 1668352
URL: http://svn.apache.org/r1668352
Log:
Added the VLV response code submitted by Radovan
Added:
directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java
directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContentCountResponse.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContextIdResponse.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreTargetPosition.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreVirtualListViewResult.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java
Modified:
directory/shared/trunk/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
directory/shared/trunk/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java
directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java?rev=1668352&r1=1668351&r2=1668352&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java Sun Mar 22 10:58:42 2015
@@ -54,6 +54,7 @@ public class StandaloneLdapCodecServiceT
"org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory," +
"org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory," +
"org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewRequestFactory," +
+ "org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewResponseFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory," +
Modified: directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java?rev=1668352&r1=1668351&r2=1668352&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java (original)
+++ directory/shared/trunk/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java Sun Mar 22 10:58:42 2015
@@ -47,7 +47,9 @@ import org.apache.directory.api.ldap.ext
import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequest;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewRequestFactory;
+import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewResponseFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory;
@@ -121,6 +123,11 @@ public class CodecFactoryUtil
controlFactories.put( virtualListViewRequestFactory.getOid(), virtualListViewRequestFactory );
LOG.info( "Registered pre-bundled control factory: {}", virtualListViewRequestFactory.getOid() );
+ ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
+ apiService );
+ controlFactories.put( virtualListViewResponseFactory.getOid(), virtualListViewResponseFactory );
+ LOG.info( "Registered pre-bundled control factory: {}", virtualListViewResponseFactory.getOid() );
+
ControlFactory<SyncDoneValue> SyncDoneValueFactory = new SyncDoneValueFactory( apiService );
controlFactories.put( SyncDoneValueFactory.getOid(), SyncDoneValueFactory );
LOG.info( "Registered pre-bundled control factory: {}", SyncDoneValueFactory.getOid() );
Modified: directory/shared/trunk/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java?rev=1668352&r1=1668351&r2=1668352&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java (original)
+++ directory/shared/trunk/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java Sun Mar 22 10:58:42 2015
@@ -57,6 +57,7 @@ public abstract class AbstractCodecServi
"org.apache.directory.api.ldap.codec.controls.search.subentries.SubentriesFactory," +
"org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory," +
"org.apache.directory.api.ldap.extras.controls.ppolicy_impl.VirtualListViewRequestFactory," +
+ "org.apache.directory.api.ldap.extras.controls.ppolicy_impl.VirtualListViewResponseFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory," +
Added: directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java (added)
+++ directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponse.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,81 @@
+/*
+ * 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.api.ldap.extras.controls.vlv;
+
+
+import org.apache.directory.api.ldap.model.message.Control;
+
+
+/**
+ * Virtual List View response control as specified in draft-ietf-ldapext-ldapv3-vlv-09.
+ * <pre>
+ * VirtualListViewResponse ::= SEQUENCE {
+ * targetPosition INTEGER (0 .. maxInt),
+ * contentCount INTEGER (0 .. maxInt),
+ * virtualListViewResult ENUMERATED {
+ * success (0),
+ * operationsError (1),
+ * protocolError (3),
+ * unwillingToPerform (53),
+ * insufficientAccessRights (50),
+ * timeLimitExceeded (3),
+ * adminLimitExceeded (11),
+ * innapropriateMatching (18),
+ * sortControlMissing (60),
+ * offsetRangeError (61),
+ * other(80),
+ * ...
+ * },
+ * contextID OCTET STRING OPTIONAL
+ * }
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface VirtualListViewResponse extends Control
+{
+ /** the OID of the response control */
+ String OID = "2.16.840.1.113730.3.4.10";
+
+
+ int getTargetPosition();
+
+
+ void setTargetPosition( int targetPosition );
+
+
+ int getContentCount();
+
+
+ void setContentCount( int contentCount );
+
+
+ VirtualListViewResultCode getVirtualListViewResult();
+
+
+ void setVirtualListViewResult( VirtualListViewResultCode virtualListViewResultCode );
+
+
+ byte[] getContextId();
+
+
+ void setContextId( byte[] contextId );
+}
Added: directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java (added)
+++ directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResponseImpl.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,189 @@
+/*
+ * 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.api.ldap.extras.controls.vlv;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
+import org.apache.directory.api.util.Strings;
+
+
+/**
+ * Virtual List View response control as specified in draft-ietf-ldapext-ldapv3-vlv-09.
+ *
+ * VirtualListViewResponse ::= SEQUENCE {
+ * targetPosition INTEGER (0 .. maxInt),
+ * contentCount INTEGER (0 .. maxInt),
+ * virtualListViewResult ENUMERATED {
+ * success (0),
+ * operationsError (1),
+ * protocolError (3),
+ * unwillingToPerform (53),
+ * insufficientAccessRights (50),
+ * timeLimitExceeded (3),
+ * adminLimitExceeded (11),
+ * innapropriateMatching (18),
+ * sortControlMissing (60),
+ * offsetRangeError (61),
+ * other(80),
+ * ... },
+ * contextID OCTET STRING OPTIONAL }
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class VirtualListViewResponseImpl extends AbstractControl implements VirtualListViewResponse
+{
+
+ private int targetPosition;
+ private int contentCount;
+ private VirtualListViewResultCode virtualListViewResult;
+ private byte[] contextId;
+
+
+ public VirtualListViewResponseImpl()
+ {
+ super( OID );
+ }
+
+
+ @Override
+ public int getTargetPosition()
+ {
+ return targetPosition;
+ }
+
+
+ @Override
+ public void setTargetPosition( int targetPosition )
+ {
+ this.targetPosition = targetPosition;
+ }
+
+
+ @Override
+ public int getContentCount()
+ {
+ return contentCount;
+ }
+
+
+ @Override
+ public void setContentCount( int contentCount )
+ {
+ this.contentCount = contentCount;
+ }
+
+
+ @Override
+ public VirtualListViewResultCode getVirtualListViewResult()
+ {
+ return virtualListViewResult;
+ }
+
+
+ @Override
+ public void setVirtualListViewResult( VirtualListViewResultCode virtualListViewResultCode )
+ {
+ this.virtualListViewResult = virtualListViewResultCode;
+ }
+
+
+ @Override
+ public byte[] getContextId()
+ {
+ return contextId;
+ }
+
+
+ @Override
+ public void setContextId( byte[] contextId )
+ {
+ this.contextId = contextId;
+ }
+
+
+ /**
+ * @see Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ int h = super.hashCode();
+
+ h = h * 37 + targetPosition;
+ h = h * 37 + contentCount;
+ h = h * 37 + ( ( virtualListViewResult == null ) ? 0 : virtualListViewResult.hashCode() );
+
+ if ( contextId != null )
+ {
+ for ( byte b : contextId )
+ {
+ h = h * 17 + b;
+ }
+ }
+
+ return h;
+ }
+
+
+ /**
+ * @see Object#equals(Object)
+ */
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( !super.equals( o ) )
+ {
+ return false;
+ }
+
+ VirtualListViewResponseImpl otherControl = ( VirtualListViewResponseImpl ) o;
+
+ return ( targetPosition == otherControl.getTargetPosition() ) &&
+ ( contentCount == otherControl.getContentCount() ) &&
+ ( virtualListViewResult == otherControl.getVirtualListViewResult() ) &&
+ Arrays.equals( contextId, otherControl.getContextId() );
+ }
+
+
+ /**
+ * Return a String representing this VirtualListViewResponseImpl.
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( " Virtual List View Response Control\n" );
+ sb.append( " oid : " ).append( getOid() ).append( '\n' );
+ sb.append( " critical : " ).append( isCritical() ).append( '\n' );
+ sb.append( " targetPosition : '" ).append( targetPosition ).append( "'\n" );
+ sb.append( " contentCount : '" ).append( contentCount ).append( "'\n" );
+ sb.append( " virtualListViewResult : '" ).append( virtualListViewResult ).append( "'\n" );
+
+ if ( contextId != null )
+ {
+ sb.append( " contextID : '" ).append( Strings.dumpBytes( contextId ) ).append( "'\n" );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java (added)
+++ directory/shared/trunk/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv/VirtualListViewResultCode.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,113 @@
+/*
+ * 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.api.ldap.extras.controls.vlv;
+
+
+/**
+ * Enumeration of the result codes of a Virtual List View response control as specified in draft-ietf-ldapext-ldapv3-vlv-09.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum VirtualListViewResultCode
+{
+ SUCCESS(0, "Success"),
+
+ OPERATIONSERROR(1, "Server internal failure"),
+
+ TIMELIMITEXCEEDED(3, "Timelimit exceeded"),
+
+ ADMINLIMITEXCEEDED(11, "Admin limit exceeded"),
+
+ INAPPROPRIATEMATCHING(18, "Unrecognized or inappropriate matching rule"),
+
+ INSUFFICIENTACCESSRIGHTS(50, "Insufficient access rights"),
+
+ UNWILLINGTOPERFORM(53, "Unwilling to perform"),
+
+ SORTCONTROLMISSING(60, "Sort control missing"),
+
+ OFFSETRANGEERROR(61, "Offset range error"),
+
+ OTHER(80, "Other");
+
+ private int val;
+ private String desc;
+
+
+ private VirtualListViewResultCode( int val, String desc )
+ {
+ this.val = val;
+ this.desc = desc;
+ }
+
+
+ public int getVal()
+ {
+ return val;
+ }
+
+
+ /**
+ * returns the enum value representing the given code.
+ *
+ * @param code the result code
+ * @return returns the corresponding ResultCode, throws IllegalArgumentException when there
+ * is no matching ResultCode exists for the given value.
+ */
+ public static VirtualListViewResultCode get( int code )
+ {
+ switch ( code )
+ {
+ case 0:
+ return SUCCESS;
+
+ case 1:
+ return OPERATIONSERROR;
+
+ case 3:
+ return TIMELIMITEXCEEDED;
+
+ case 11:
+ return ADMINLIMITEXCEEDED;
+
+ case 18:
+ return INAPPROPRIATEMATCHING;
+
+ case 50:
+ return INSUFFICIENTACCESSRIGHTS;
+
+ case 53:
+ return UNWILLINGTOPERFORM;
+
+ case 60:
+ return SORTCONTROLMISSING;
+
+ case 61:
+ return OFFSETRANGEERROR;
+
+ case 80:
+ return OTHER;
+
+ default:
+ throw new IllegalArgumentException( "Unknown VLV response result code " + code );
+ }
+ }
+}
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java?rev=1668352&r1=1668351&r2=1668352&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java Sun Mar 22 10:58:42 2015
@@ -35,7 +35,9 @@ import org.apache.directory.api.ldap.ext
import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
import org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequest;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewRequestFactory;
+import org.apache.directory.api.ldap.extras.controls.vlv_impl.VirtualListViewResponseFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.certGeneration.CertGenerationFactory;
import org.apache.directory.api.ldap.extras.extended.ads_impl.gracefulDisconnect.GracefulDisconnectFactory;
@@ -145,6 +147,10 @@ public class ExtrasBundleActivator imple
ControlFactory<VirtualListViewRequest> virtualListViewRequestFactory = new VirtualListViewRequestFactory( codec );
codec.registerControl( virtualListViewRequestFactory );
+ ControlFactory<VirtualListViewResponse> virtualListViewResponseFactory = new VirtualListViewResponseFactory(
+ codec );
+ codec.registerControl( virtualListViewResponseFactory );
+
ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( codec );
codec.registerControl( adDirSyncFactory );
}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContentCountResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContentCountResponse.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContentCountResponse.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContentCountResponse.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,50 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.actions.AbstractReadInteger;
+
+
+/**
+ * The action used to store the contentCount value in VLV response
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreContentCountResponse extends AbstractReadInteger<VirtualListViewResponseContainer>
+{
+ /**
+ * Instantiates a new ContentCount action.
+ */
+ public StoreContentCountResponse()
+ {
+ super( "VirtualListViewResponse contentCount" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setIntegerValue( int value, VirtualListViewResponseContainer vlvContainer )
+ {
+ vlvContainer.getDecorator().setContentCount( value );
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContextIdResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContextIdResponse.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContextIdResponse.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreContextIdResponse.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,53 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.actions.AbstractReadOctetString;
+
+
+/**
+ * The action used to store the contextId value in VLV reponse
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreContextIdResponse extends AbstractReadOctetString<VirtualListViewResponseContainer>
+{
+ /**
+ * Instantiates a new contextId action.
+ */
+ public StoreContextIdResponse()
+ {
+ super( "VirtualListViewResponse contextId", true );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setOctetString( byte[] value, VirtualListViewResponseContainer vlvContainer )
+ {
+ vlvContainer.getDecorator().setContextId( value );
+
+ // The last element is optional, we can quit here
+ vlvContainer.setGrammarEndAllowed( true );
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreTargetPosition.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreTargetPosition.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreTargetPosition.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreTargetPosition.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,50 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.actions.AbstractReadInteger;
+
+
+/**
+ * The action used to store the targetPosition value
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreTargetPosition extends AbstractReadInteger<VirtualListViewResponseContainer>
+{
+ /**
+ * Instantiates a new targetPosition action.
+ */
+ public StoreTargetPosition()
+ {
+ super( "VirtualListViewResponse targetPosition" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setIntegerValue( int value, VirtualListViewResponseContainer vlvContainer )
+ {
+ vlvContainer.getDecorator().setTargetPosition( value );
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreVirtualListViewResult.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreVirtualListViewResult.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreVirtualListViewResult.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/StoreVirtualListViewResult.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,54 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.actions.AbstractReadInteger;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResultCode;
+
+
+/**
+ * The action used to store the virtualListViewResult value
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreVirtualListViewResult extends AbstractReadInteger<VirtualListViewResponseContainer>
+{
+ /**
+ * Instantiates a new virtualListViewResult action.
+ */
+ public StoreVirtualListViewResult()
+ {
+ super( "VirtualListViewResponse virtualListViewResult" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setIntegerValue( int value, VirtualListViewResponseContainer vlvContainer )
+ {
+ VirtualListViewResultCode code = VirtualListViewResultCode.get( value );
+ vlvContainer.getDecorator().setVirtualListViewResult( code );
+
+ vlvContainer.setGrammarEndAllowed( true );
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseContainer.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,87 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.ber.AbstractContainer;
+import org.apache.directory.api.ldap.codec.api.LdapApiService;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
+
+
+/**
+ * A container for the VLV response control.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class VirtualListViewResponseContainer extends AbstractContainer
+{
+ private VirtualListViewResponseDecorator control;
+
+ private LdapApiService codec;
+
+
+ public VirtualListViewResponseContainer( LdapApiService codec )
+ {
+ super();
+ this.codec = codec;
+ grammar = VirtualListViewResponseGrammar.getInstance();
+ setTransition( VirtualListViewResponseStates.START_STATE );
+ }
+
+
+ public VirtualListViewResponseContainer( VirtualListViewResponseDecorator control, LdapApiService codec )
+ {
+ this( codec );
+ decorate( control );
+ }
+
+
+ public VirtualListViewResponseDecorator getDecorator()
+ {
+ return control;
+ }
+
+
+ public void decorate( VirtualListViewResponse control )
+ {
+ if ( control instanceof VirtualListViewResponseDecorator )
+ {
+ this.control = ( VirtualListViewResponseDecorator ) control;
+ }
+ else
+ {
+ this.control = new VirtualListViewResponseDecorator( codec, control );
+ }
+ }
+
+
+ public void setVirtualListViewResponseControl( VirtualListViewResponseDecorator control )
+ {
+ this.control = control;
+ }
+
+
+ public void clean()
+ {
+ super.clean();
+ control = null;
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseDecorator.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,232 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.api.asn1.Asn1Object;
+import org.apache.directory.api.asn1.DecoderException;
+import org.apache.directory.api.asn1.EncoderException;
+import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.asn1.ber.tlv.BerValue;
+import org.apache.directory.api.asn1.ber.tlv.TLV;
+import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.api.i18n.I18n;
+import org.apache.directory.api.ldap.codec.api.ControlDecorator;
+import org.apache.directory.api.ldap.codec.api.LdapApiService;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponseImpl;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResultCode;
+
+
+/**
+ * The VirtualListView response decorator
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class VirtualListViewResponseDecorator extends ControlDecorator<VirtualListViewResponse> implements
+ VirtualListViewResponse
+{
+ private int vlvSeqLength;
+
+ private static final Asn1Decoder decoder = new Asn1Decoder();
+
+
+ public VirtualListViewResponseDecorator( LdapApiService codec )
+ {
+ this( codec, new VirtualListViewResponseImpl() );
+ }
+
+
+ public VirtualListViewResponseDecorator( LdapApiService codec, VirtualListViewResponse vlvRequest )
+ {
+ super( codec, vlvRequest );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int computeLength()
+ {
+ vlvSeqLength = 1 + 1 + BerValue.getNbBytes( getTargetPosition() );
+ vlvSeqLength += 1 + 1 + BerValue.getNbBytes( getContentCount() );
+
+ // result code : always one byte long
+ vlvSeqLength += 1 + 1 + 1;
+
+ if ( getContextId() != null )
+ {
+ vlvSeqLength += 1 + TLV.getNbBytes( getContextId().length ) + getContextId().length;
+ }
+
+ valueLength = 1 + TLV.getNbBytes( vlvSeqLength ) + vlvSeqLength;
+
+ return valueLength;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+ {
+ if ( buffer == null )
+ {
+ throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
+ }
+
+ buffer.put( UniversalTag.SEQUENCE.getValue() );
+ buffer.put( TLV.getBytes( vlvSeqLength ) );
+
+ BerValue.encode( buffer, getTargetPosition() );
+ BerValue.encode( buffer, getContentCount() );
+
+ BerValue.encodeEnumerated( buffer, getVirtualListViewResult().getVal() );
+
+ if ( getContextId() != null )
+ {
+ BerValue.encode( buffer, getContextId() );
+ }
+
+ return buffer;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getValue()
+ {
+ if ( value == null )
+ {
+ try
+ {
+ computeLength();
+ ByteBuffer buffer = ByteBuffer.allocate( valueLength );
+
+ value = encode( buffer ).array();
+ }
+ catch ( Exception e )
+ {
+ return null;
+ }
+ }
+
+ return value;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+ {
+ ByteBuffer buffer = ByteBuffer.wrap( controlBytes );
+ VirtualListViewResponseContainer container = new VirtualListViewResponseContainer( this, getCodecService() );
+ decoder.decode( buffer, container );
+
+ return this;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getTargetPosition()
+ {
+ return getDecorated().getTargetPosition();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setTargetPosition( int targetPosition )
+ {
+ getDecorated().setTargetPosition( targetPosition );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getContentCount()
+ {
+ return getDecorated().getContentCount();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setContentCount( int contentCount )
+ {
+ getDecorated().setContentCount( contentCount );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public VirtualListViewResultCode getVirtualListViewResult()
+ {
+ return getDecorated().getVirtualListViewResult();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setVirtualListViewResult( VirtualListViewResultCode virtualListViewResult )
+ {
+ getDecorated().setVirtualListViewResult( virtualListViewResult );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public byte[] getContextId()
+ {
+ return getDecorated().getContextId();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setContextId( byte[] contextId )
+ {
+ getDecorated().setContextId( contextId );
+ }
+
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseFactory.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,65 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.ldap.codec.api.CodecControl;
+import org.apache.directory.api.ldap.codec.api.ControlFactory;
+import org.apache.directory.api.ldap.codec.api.LdapApiService;
+import org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponse;
+
+
+/**
+ * A {@link ControlFactory} for {@link VirtualListViewResponse} controls.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class VirtualListViewResponseFactory implements ControlFactory<VirtualListViewResponse>
+{
+ private LdapApiService codec;
+
+
+ public VirtualListViewResponseFactory( LdapApiService codec )
+ {
+ this.codec = codec;
+ }
+
+
+ @Override
+ public String getOid()
+ {
+ return VirtualListViewResponse.OID;
+ }
+
+
+ @Override
+ public CodecControl<VirtualListViewResponse> newCodecControl()
+ {
+ return new VirtualListViewResponseDecorator( codec );
+ }
+
+
+ @Override
+ public CodecControl<VirtualListViewResponse> newCodecControl( VirtualListViewResponse control )
+ {
+ return new VirtualListViewResponseDecorator( codec, control );
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseGrammar.java Sun Mar 22 10:58:42 2015
@@ -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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
+import org.apache.directory.api.asn1.ber.grammar.Grammar;
+import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
+import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The grammar for the VLV response which described as :
+ *
+ * <pre>
+ * VirtualListViewResponse ::= SEQUENCE {
+ * targetPosition INTEGER (0 .. maxInt),
+ * contentCount INTEGER (0 .. maxInt),
+ * virtualListViewResult ENUMERATED {
+ * success (0),
+ * operationsError (1),
+ * protocolError (3),
+ * unwillingToPerform (53),
+ * insufficientAccessRights (50),
+ * timeLimitExceeded (3),
+ * adminLimitExceeded (11),
+ * innapropriateMatching (18),
+ * sortControlMissing (60),
+ * offsetRangeError (61),
+ * other(80),
+ * ...
+ * },
+ * contextID OCTET STRING OPTIONAL
+ * }
+ * </pre>
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class VirtualListViewResponseGrammar extends AbstractGrammar<VirtualListViewResponseContainer>
+{
+ static final Logger LOG = LoggerFactory.getLogger( VirtualListViewResponseGrammar.class );
+
+ static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+ private static Grammar<?> instance = new VirtualListViewResponseGrammar();
+
+
+ @SuppressWarnings("unchecked")
+ private VirtualListViewResponseGrammar()
+ {
+ setName( VirtualListViewResponseGrammar.class.getName() );
+
+ super.transitions = new GrammarTransition[VirtualListViewResponseStates.END_STATE.ordinal()][256];
+
+ super.transitions[VirtualListViewResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<VirtualListViewResponseContainer>(
+ VirtualListViewResponseStates.START_STATE,
+ VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
+ UniversalTag.SEQUENCE.getValue(),
+ null );
+
+ super.transitions[VirtualListViewResponseStates.VLV_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()] =
+ new GrammarTransition<VirtualListViewResponseContainer>(
+ VirtualListViewResponseStates.VLV_SEQUENCE_STATE,
+ VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
+ UniversalTag.INTEGER.getValue(),
+ new StoreTargetPosition() );
+
+ super.transitions[VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE.ordinal()][UniversalTag.INTEGER
+ .getValue()] =
+ new GrammarTransition<VirtualListViewResponseContainer>(
+ VirtualListViewResponseStates.VLV_TARGET_POSITION_STATE,
+ VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
+ UniversalTag.INTEGER.getValue(),
+ new StoreContentCountResponse() );
+
+ super.transitions[VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE.ordinal()][UniversalTag.ENUMERATED
+ .getValue()] =
+ new GrammarTransition<VirtualListViewResponseContainer>(
+ VirtualListViewResponseStates.VLV_CONTENT_COUNT_STATE,
+ VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
+ UniversalTag.ENUMERATED.getValue(),
+ new StoreVirtualListViewResult() );
+
+ super.transitions[VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE.ordinal()][UniversalTag.OCTET_STRING
+ .getValue()] =
+ new GrammarTransition<VirtualListViewResponseContainer>(
+ VirtualListViewResponseStates.VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
+ VirtualListViewResponseStates.VLV_CONTEXT_ID_STATE,
+ UniversalTag.OCTET_STRING.getValue(),
+ new StoreContextIdResponse() );
+ }
+
+
+ public static Grammar<?> getInstance()
+ {
+ return instance;
+ }
+}
Added: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java?rev=1668352&view=auto
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java (added)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/vlv_impl/VirtualListViewResponseStates.java Sun Mar 22 10:58:42 2015
@@ -0,0 +1,79 @@
+/*
+ * 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.api.ldap.extras.controls.vlv_impl;
+
+
+import org.apache.directory.api.asn1.ber.grammar.Grammar;
+import org.apache.directory.api.asn1.ber.grammar.States;
+
+
+/**
+ * This class store the VirtualListViewResponse grammar constants. It is also used for
+ * debugging purposes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum VirtualListViewResponseStates implements States
+{
+ START_STATE,
+ VLV_SEQUENCE_STATE,
+ VLV_TARGET_POSITION_STATE,
+ VLV_CONTENT_COUNT_STATE,
+ VLV_VIRTUAL_LIST_VIEW_RESULT_STATE,
+ VLV_CONTEXT_ID_STATE,
+ END_STATE;
+
+ public String getGrammarName( int grammar )
+ {
+ return "VLV_RESPONSE_GRAMMAR";
+ }
+
+
+ public String getGrammarName( Grammar<?> grammar )
+ {
+ if ( grammar instanceof VirtualListViewResponseGrammar )
+ {
+ return "VLV_RESPONSE_GRAMMAR";
+ }
+
+ return "UNKNOWN GRAMMAR";
+ }
+
+
+ public String getState( int state )
+ {
+ return ( ( state == END_STATE.ordinal() ) ? "VLV_RESPONSE_END_STATE" : name() );
+ }
+
+
+ @Override
+ public boolean isEndState()
+ {
+ return this == END_STATE;
+ }
+
+
+ @Override
+ public Enum<?> getStartState()
+ {
+ return START_STATE;
+ }
+}