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 2012/01/24 18:27:12 UTC
svn commit: r1235364 [24/27] - in /directory/shared/trunk:
asn1/api/src/main/java/org/apache/directory/shared/asn1/util/
asn1/api/src/test/java/org/apache/directory/shared/asn1/util/
asn1/ber/src/main/java/org/apache/directory/shared/asn1/actions/ asn1...
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureFactory.java Tue Jan 24 17:27:00 2012
@@ -20,7 +20,7 @@
package org.apache.directory.shared.ldap.extras.extended.ads_impl.storedProcedure;
-import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.DecoderException;
import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
import org.apache.directory.shared.ldap.codec.api.ExtendedResponseDecorator;
@@ -41,8 +41,8 @@ import org.apache.directory.shared.ldap.
public class StoredProcedureFactory implements ExtendedRequestFactory<StoredProcedureRequest, StoredProcedureResponse>
{
private LdapApiService codec;
-
-
+
+
/**
* Creates a new instance of StoredProcedureFactory.
*
@@ -52,8 +52,8 @@ public class StoredProcedureFactory impl
{
this.codec = codec;
}
-
-
+
+
/**
* {@inheritDoc}
*/
@@ -62,7 +62,7 @@ public class StoredProcedureFactory impl
return StoredProcedureRequest.EXTENSION_OID;
}
-
+
/**
* {@inheritDoc}
*/
@@ -77,7 +77,8 @@ public class StoredProcedureFactory impl
*/
public StoredProcedureResponse newResponse( byte[] encodedValue ) throws DecoderException
{
- StoredProcedureResponseDecorator response = new StoredProcedureResponseDecorator( codec, new StoredProcedureResponseImpl() );
+ StoredProcedureResponseDecorator response = new StoredProcedureResponseDecorator( codec,
+ new StoredProcedureResponseImpl() );
response.setResponseValue( encodedValue );
return response;
}
@@ -89,7 +90,7 @@ public class StoredProcedureFactory impl
public StoredProcedureRequest newRequest( byte[] value )
{
StoredProcedureRequestDecorator req = new StoredProcedureRequestDecorator( codec );
-
+
if ( value != null )
{
req.setRequestValue( value );
@@ -108,8 +109,7 @@ public class StoredProcedureFactory impl
{
return ( StoredProcedureRequestDecorator ) modelRequest;
}
-
-
+
return new StoredProcedureRequestDecorator( codec, ( StoredProcedureRequest ) modelRequest );
}
@@ -123,7 +123,7 @@ public class StoredProcedureFactory impl
{
return ( StoredProcedureResponseDecorator ) decoratedMessage;
}
-
+
return new StoredProcedureResponseDecorator( codec, ( StoredProcedureResponse ) decoratedMessage );
}
}
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureGrammar.java Tue Jan 24 17:27:00 2012
@@ -71,226 +71,228 @@ public final class StoredProcedureGramma
// StoredProcedure ::= SEQUENCE {
// ...
// Nothing to do.
- super.transitions[StoredProcedureStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.START_STATE,
- StoredProcedureStatesEnum.STORED_PROCEDURE_STATE,
- UniversalTag.SEQUENCE.getValue(),
- null );
+ super.transitions[StoredProcedureStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.START_STATE,
+ StoredProcedureStatesEnum.STORED_PROCEDURE_STATE,
+ UniversalTag.SEQUENCE.getValue(),
+ null );
// language OCTETSTRING, (Tag)
// ...
//
// Creates the storeProcedure and stores the language
- super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.STORED_PROCEDURE_STATE,
- StoredProcedureStatesEnum.LANGUAGE_STATE,
- UniversalTag.OCTET_STRING.getValue(),
+ super.transitions[StoredProcedureStatesEnum.STORED_PROCEDURE_STATE.ordinal()][UniversalTag.OCTET_STRING
+ .getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.STORED_PROCEDURE_STATE,
+ StoredProcedureStatesEnum.LANGUAGE_STATE,
+ UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<StoredProcedureContainer>( "Stores the language" )
- {
- public void action( StoredProcedureContainer container ) throws DecoderException
{
- TLV tlv = container.getCurrentTLV();
-
- StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
- if ( storedProcedure == null )
+ public void action( StoredProcedureContainer container ) throws DecoderException
{
- storedProcedure = new StoredProcedureRequestDecorator( LdapApiServiceFactory.getSingleton() );
- container.setStoredProcedure( storedProcedure );
- }
+ TLV tlv = container.getCurrentTLV();
- // Store the value.
- if ( tlv.getLength() == 0 )
- {
- // We can't have a void language !
- String msg = I18n.err( I18n.ERR_04038 );
- LOG.error( msg );
- throw new DecoderException( msg );
- }
- else
- {
- // Only this field's type is String by default
- String language = Strings.utf8ToString(tlv.getValue().getData());
+ StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
+ if ( storedProcedure == null )
+ {
+ storedProcedure = new StoredProcedureRequestDecorator( LdapApiServiceFactory.getSingleton() );
+ container.setStoredProcedure( storedProcedure );
+ }
- if ( LOG.isDebugEnabled() )
+ // Store the value.
+ if ( tlv.getLength() == 0 )
{
- LOG.debug( "SP language found: " + language );
+ // We can't have a void language !
+ String msg = I18n.err( I18n.ERR_04038 );
+ LOG.error( msg );
+ throw new DecoderException( msg );
}
+ else
+ {
+ // Only this field's type is String by default
+ String language = Strings.utf8ToString( tlv.getValue().getData() );
- storedProcedure.setLanguage( language );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "SP language found: " + language );
+ }
+
+ storedProcedure.setLanguage( language );
+ }
}
- }
- } );
+ } );
// procedure OCTETSTRING, (Value)
// ...
// Stores the procedure.
- super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.LANGUAGE_STATE,
- StoredProcedureStatesEnum.PROCEDURE_STATE,
- UniversalTag.OCTET_STRING.getValue(),
+ super.transitions[StoredProcedureStatesEnum.LANGUAGE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.LANGUAGE_STATE,
+ StoredProcedureStatesEnum.PROCEDURE_STATE,
+ UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<StoredProcedureContainer>( "Stores the procedure" )
- {
- public void action( StoredProcedureContainer container ) throws DecoderException
{
- TLV tlv = container.getCurrentTLV();
+ public void action( StoredProcedureContainer container ) throws DecoderException
+ {
+ TLV tlv = container.getCurrentTLV();
- StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
+ StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
- // Store the value.
- if ( tlv.getLength() == 0 )
- {
- // We can't have a void procedure !
- String msg = I18n.err( I18n.ERR_04039 );
- LOG.error( msg );
- throw new DecoderException( msg );
- }
- else
- {
- byte[] procedure = tlv.getValue().getData();
+ // Store the value.
+ if ( tlv.getLength() == 0 )
+ {
+ // We can't have a void procedure !
+ String msg = I18n.err( I18n.ERR_04039 );
+ LOG.error( msg );
+ throw new DecoderException( msg );
+ }
+ else
+ {
+ byte[] procedure = tlv.getValue().getData();
- storedProcedure.setProcedure( procedure );
- }
+ storedProcedure.setProcedure( procedure );
+ }
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Procedure found : " + storedProcedure.getProcedureSpecification() );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Procedure found : " + storedProcedure.getProcedureSpecification() );
+ }
}
- }
- } );
+ } );
// parameters SEQUENCE OF Parameter { (Value)
// ...
// The list of parameters will be created with the first parameter.
// We can have an empty list of parameters, so the PDU can be empty
- super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PROCEDURE_STATE,
- StoredProcedureStatesEnum.PARAMETERS_STATE,
- UniversalTag.SEQUENCE.getValue(),
- new GrammarAction<StoredProcedureContainer>( "Stores the parameters" )
- {
- public void action( StoredProcedureContainer container ) throws DecoderException
+ super.transitions[StoredProcedureStatesEnum.PROCEDURE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PROCEDURE_STATE,
+ StoredProcedureStatesEnum.PARAMETERS_STATE,
+ UniversalTag.SEQUENCE.getValue(),
+ new GrammarAction<StoredProcedureContainer>( "Stores the parameters" )
{
- container.setGrammarEndAllowed( true );
- }
- } );
-
+ public void action( StoredProcedureContainer container ) throws DecoderException
+ {
+ container.setGrammarEndAllowed( true );
+ }
+ } );
+
// parameter SEQUENCE OF { (Value)
// ...
// Nothing to do.
- super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETERS_STATE,
- StoredProcedureStatesEnum.PARAMETER_STATE,
- UniversalTag.SEQUENCE.getValue(),
- null );
+ super.transitions[StoredProcedureStatesEnum.PARAMETERS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETERS_STATE,
+ StoredProcedureStatesEnum.PARAMETER_STATE,
+ UniversalTag.SEQUENCE.getValue(),
+ null );
// Parameter ::= {
// type OCTETSTRING, (Value)
// ...
//
// We can create a parameter, and store its type
- super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_STATE,
- StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
- UniversalTag.OCTET_STRING.getValue(),
+ super.transitions[StoredProcedureStatesEnum.PARAMETER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_STATE,
+ StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
+ UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<StoredProcedureContainer>( "Store parameter type" )
- {
- public void action( StoredProcedureContainer container ) throws DecoderException
{
- TLV tlv = container.getCurrentTLV();
- StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
-
- // Store the value.
- if ( tlv.getLength() == 0 )
+ public void action( StoredProcedureContainer container ) throws DecoderException
{
- // We can't have a void parameter type !
- String msg = I18n.err( I18n.ERR_04040 );
- LOG.error( msg );
- throw new DecoderException( msg );
- }
- else
- {
- StoredProcedureParameter parameter = new StoredProcedureParameter();
+ TLV tlv = container.getCurrentTLV();
+ StoredProcedureRequestDecorator storedProcedure = container.getStoredProcedure();
- byte[] parameterType = tlv.getValue().getData();
+ // Store the value.
+ if ( tlv.getLength() == 0 )
+ {
+ // We can't have a void parameter type !
+ String msg = I18n.err( I18n.ERR_04040 );
+ LOG.error( msg );
+ throw new DecoderException( msg );
+ }
+ else
+ {
+ StoredProcedureParameter parameter = new StoredProcedureParameter();
- parameter.setType( parameterType );
+ byte[] parameterType = tlv.getValue().getData();
- // We store the type in the current parameter.
- storedProcedure.setCurrentParameter( parameter );
+ parameter.setType( parameterType );
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Parameter type found : " + Strings.dumpBytes(parameterType) );
- }
+ // We store the type in the current parameter.
+ storedProcedure.setCurrentParameter( parameter );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Parameter type found : " + Strings.dumpBytes( parameterType ) );
+ }
+
+ }
}
- }
- } );
+ } );
// Parameter ::= {
// ...
// value OCTETSTRING (Tag)
// }
// Store the parameter value
- super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
- StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
- UniversalTag.OCTET_STRING.getValue(),
+ super.transitions[StoredProcedureStatesEnum.PARAMETER_TYPE_STATE.ordinal()][UniversalTag.OCTET_STRING
+ .getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_TYPE_STATE,
+ StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
+ UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<StoredProcedureContainer>( "Store parameter value" )
- {
- public void action( StoredProcedureContainer container ) throws DecoderException
{
- StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
-
- TLV tlv = storedProcedureContainer.getCurrentTLV();
- StoredProcedureRequestDecorator storedProcedure = storedProcedureContainer.getStoredProcedure();
-
- // Store the value.
- if ( tlv.getLength() == 0 )
+ public void action( StoredProcedureContainer container ) throws DecoderException
{
- // We can't have a void parameter value !
- String msg = I18n.err( I18n.ERR_04041 );
- LOG.error( msg );
- throw new DecoderException( msg );
- }
- else
- {
- byte[] parameterValue = tlv.getValue().getData();
+ StoredProcedureContainer storedProcedureContainer = ( StoredProcedureContainer ) container;
+
+ TLV tlv = storedProcedureContainer.getCurrentTLV();
+ StoredProcedureRequestDecorator storedProcedure = storedProcedureContainer.getStoredProcedure();
- if ( parameterValue.length != 0 )
+ // Store the value.
+ if ( tlv.getLength() == 0 )
{
- StoredProcedureParameter parameter = storedProcedure.getCurrentParameter();
- parameter.setValue( parameterValue );
+ // We can't have a void parameter value !
+ String msg = I18n.err( I18n.ERR_04041 );
+ LOG.error( msg );
+ throw new DecoderException( msg );
+ }
+ else
+ {
+ byte[] parameterValue = tlv.getValue().getData();
+
+ if ( parameterValue.length != 0 )
+ {
+ StoredProcedureParameter parameter = storedProcedure.getCurrentParameter();
+ parameter.setValue( parameterValue );
- // We can now add a new Parameter to the procedure
- storedProcedure.addParameter( parameter );
+ // We can now add a new Parameter to the procedure
+ storedProcedure.addParameter( parameter );
- if ( LOG.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Parameter value found : " + Strings.dumpBytes( parameterValue ) );
+ }
+ }
+ else
{
- LOG.debug( "Parameter value found : " + Strings.dumpBytes(parameterValue) );
+ String msg = I18n.err( I18n.ERR_04042 );
+ LOG.error( msg );
+ throw new DecoderException( msg );
}
}
- else
- {
- String msg = I18n.err( I18n.ERR_04042 );
- LOG.error( msg );
- throw new DecoderException( msg );
- }
+
+ // The only possible END state for the grammar is here
+ container.setGrammarEndAllowed( true );
}
+ } );
- // The only possible END state for the grammar is here
- container.setGrammarEndAllowed( true );
- }
- } );
-
// Parameters ::= SEQUENCE OF Parameter
//
// Loop on next parameter
- super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
- new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
- StoredProcedureStatesEnum.PARAMETER_STATE,
- UniversalTag.SEQUENCE.getValue(),
- null );
+ super.transitions[StoredProcedureStatesEnum.PARAMETER_VALUE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<StoredProcedureContainer>( StoredProcedureStatesEnum.PARAMETER_VALUE_STATE,
+ StoredProcedureStatesEnum.PARAMETER_STATE,
+ UniversalTag.SEQUENCE.getValue(),
+ null );
}
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureRequestDecorator.java Tue Jan 24 17:27:00 2012
@@ -46,18 +46,17 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StoredProcedureRequestDecorator
- extends ExtendedRequestDecorator<StoredProcedureRequest,StoredProcedureResponse>
+public class StoredProcedureRequestDecorator
+ extends ExtendedRequestDecorator<StoredProcedureRequest, StoredProcedureResponse>
implements StoredProcedureRequest
{
private static final Logger LOG = LoggerFactory.getLogger( StoredProcedureRequestDecorator.class );
-
private StoredProcedureParameter currentParameter;
-
+
/** The stored procedure length */
private int storedProcedureLength;
-
+
/** The parameters length */
private int parametersLength;
@@ -69,14 +68,14 @@ public class StoredProcedureRequestDecor
/** The list of all parameter value lengths */
private List<Integer> paramValueLength;
-
-
+
+
public StoredProcedureRequestDecorator( LdapApiService codec )
{
super( codec, new StoredProcedureRequestImpl() );
}
-
+
public StoredProcedureRequestDecorator( LdapApiService codec, StoredProcedureRequest decoratedRequest )
{
super( codec, decoratedRequest );
@@ -86,7 +85,7 @@ public class StoredProcedureRequestDecor
}
}
-
+
public StoredProcedureParameter getCurrentParameter()
{
return currentParameter;
@@ -98,7 +97,7 @@ public class StoredProcedureRequestDecor
this.currentParameter = currentParameter;
}
-
+
/**
* Compute the StoredProcedure length
*
@@ -129,48 +128,49 @@ public class StoredProcedureRequestDecor
{
// The language
byte[] languageBytes = Strings.getBytesUtf8( getDecorated().getLanguage() );
-
+
int languageLength = 1 + TLV.getNbBytes( languageBytes.length )
+ languageBytes.length;
-
+
byte[] procedure = getDecorated().getProcedure();
-
+
// The procedure
int procedureLength = 1 + TLV.getNbBytes( procedure.length )
+ procedure.length;
-
+
// Compute parameters length value
if ( getDecorated().getParameters() != null )
{
parameterLength = new LinkedList<Integer>();
paramTypeLength = new LinkedList<Integer>();
paramValueLength = new LinkedList<Integer>();
-
+
for ( StoredProcedureParameter spParam : getDecorated().getParameters() )
{
int localParameterLength = 0;
int localParamTypeLength = 0;
int localParamValueLength = 0;
-
+
localParamTypeLength = 1 + TLV.getNbBytes( spParam.getType().length ) + spParam.getType().length;
localParamValueLength = 1 + TLV.getNbBytes( spParam.getValue().length ) + spParam.getValue().length;
-
+
localParameterLength = localParamTypeLength + localParamValueLength;
-
+
parametersLength += 1 + TLV.getNbBytes( localParameterLength ) + localParameterLength;
-
+
parameterLength.add( localParameterLength );
paramTypeLength.add( localParamTypeLength );
paramValueLength.add( localParamValueLength );
}
}
-
- int localParametersLength = 1 + TLV.getNbBytes( parametersLength ) + parametersLength;
+
+ int localParametersLength = 1 + TLV.getNbBytes( parametersLength ) + parametersLength;
storedProcedureLength = languageLength + procedureLength + localParametersLength;
- return 1 + TLV.getNbBytes( storedProcedureLength ) + storedProcedureLength;
+ return 1 + TLV.getNbBytes( storedProcedureLength ) + storedProcedureLength;
}
+
/**
* Encode the StoredProcedure message to a PDU.
*
@@ -192,7 +192,7 @@ public class StoredProcedureRequestDecor
// The procedure
Value.encode( bb, getDecorated().getProcedure() );
-
+
// The parameters sequence
bb.put( UniversalTag.SEQUENCE.getValue() );
bb.put( TLV.getBytes( parametersLength ) );
@@ -252,27 +252,26 @@ public class StoredProcedureRequestDecor
sb.append( " Parameters\n" );
int i = 1;
-
+
for ( StoredProcedureParameter spParam : getDecorated().getParameters() )
{
- sb.append( " type[" ).append( i ) .append( "] : '" ).
- append( Strings.utf8ToString(spParam.getType()) ).append( "'\n" );
- sb.append( " value[" ).append( i ) .append( "] : '" ).
- append( Strings.dumpBytes(spParam.getValue()) ).append( "'\n" );
+ sb.append( " type[" ).append( i ).append( "] : '" ).
+ append( Strings.utf8ToString( spParam.getType() ) ).append( "'\n" );
+ sb.append( " value[" ).append( i ).append( "] : '" ).
+ append( Strings.dumpBytes( spParam.getValue() ) ).append( "'\n" );
}
}
return sb.toString();
}
-
+
public void setProcedure( byte[] procedure )
{
getDecorated().setProcedure( procedure );
}
-
/**
* {@inheritDoc}
*/
@@ -280,7 +279,7 @@ public class StoredProcedureRequestDecor
{
StoredProcedureDecoder decoder = new StoredProcedureDecoder();
StoredProcedureContainer container = new StoredProcedureContainer();
-
+
container.setStoredProcedure( this );
try
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureResponseDecorator.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureResponseDecorator.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureResponseDecorator.java Tue Jan 24 17:27:00 2012
@@ -30,7 +30,8 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StoredProcedureResponseDecorator extends ExtendedResponseDecorator<StoredProcedureResponse> implements StoredProcedureResponse
+public class StoredProcedureResponseDecorator extends ExtendedResponseDecorator<StoredProcedureResponse> implements
+ StoredProcedureResponse
{
/**
* Creates a new instance of CancelResponseDecorator.
Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/storedProcedure/StoredProcedureStatesEnum.java Tue Jan 24 17:27:00 2012
@@ -73,7 +73,6 @@ public enum StoredProcedureStatesEnum im
/** Last Stored Procedure */
LAST_STORED_PROCEDURE_STATE;
-
/**
* Get the grammar name
* @param grammar The grammar code
@@ -107,7 +106,7 @@ public enum StoredProcedureStatesEnum im
return ( ( state == END_STATE.ordinal() ) ? "STORED_PROCEDURE_END_STATE" : name() );
}
-
+
/**
* {@inheritDoc}
*/
@@ -115,8 +114,8 @@ public enum StoredProcedureStatesEnum im
{
return this == END_STATE;
}
-
-
+
+
/**
* {@inheritDoc}
*/
Modified: directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/AbstractCodecServiceTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/AbstractCodecServiceTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/AbstractCodecServiceTest.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/AbstractCodecServiceTest.java Tue Jan 24 17:27:00 2012
@@ -1,4 +1,6 @@
package org.apache.directory.shared.ldap.extras;
+
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,8 +21,6 @@ package org.apache.directory.shared.ldap
*
*/
-
-
import org.apache.directory.shared.ldap.codec.api.LdapEncoder;
import org.apache.directory.shared.ldap.codec.osgi.DefaultLdapCodecService;
import org.junit.AfterClass;
Modified: directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/ppolicy/PasswordPolicyTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/ppolicy/PasswordPolicyTest.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/ppolicy/PasswordPolicyTest.java Tue Jan 24 17:27:00 2012
@@ -47,12 +47,16 @@ public class PasswordPolicyTest extends
ByteBuffer bb = ByteBuffer.allocate( 0xA );
bb.put( new byte[]
- {
- 0x30, 0x08,
- ( byte ) 0xA0, 0x03, // timeBeforeExpiration
- ( byte ) 0x80, 0x01, 0x01,
- ( byte ) 0x81, 0x01, 0x01 // ppolicyError
- } );
+ {
+ 0x30, 0x08,
+ ( byte ) 0xA0, 0x03, // timeBeforeExpiration
+ ( byte ) 0x80,
+ 0x01,
+ 0x01,
+ ( byte ) 0x81,
+ 0x01,
+ 0x01 // ppolicyError
+ } );
bb.flip();
@@ -62,12 +66,12 @@ public class PasswordPolicyTest extends
assertTrue( passwordPolicy.hasResponse() );
assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );
assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
}
-
+
@Test
public void testDecodeRespWithGraceAuthWarningAndError() throws Exception
@@ -75,39 +79,43 @@ public class PasswordPolicyTest extends
ByteBuffer bb = ByteBuffer.allocate( 0xA );
bb.put( new byte[]
- {
- 0x30, 0x08,
- ( byte ) 0xA0, 0x03, // warning
- ( byte ) 0x81, 0x01, 0x01, // graceAuthNsRemaining
- ( byte ) 0x81, 0x01, 0x01 // error
- } );
+ {
+ 0x30, 0x08,
+ ( byte ) 0xA0, 0x03, // warning
+ ( byte ) 0x81,
+ 0x01,
+ 0x01, // graceAuthNsRemaining
+ ( byte ) 0x81,
+ 0x01,
+ 0x01 // error
+ } );
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );
-
+
assertTrue( passwordPolicy.hasResponse() );
assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );
assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
- assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array()) );
+ assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
}
-
+
@Test
public void testDecodeRespWithTimeBeforeExpiryWarningOnly() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 7 );
bb.put( new byte[]
- {
- 0x30, 0x05,
- ( byte ) 0xA0, 0x03,
- ( byte ) 0x80, 0x01, 0x01 // timeBeforeExpiration
- } );
+ {
+ 0x30, 0x05,
+ ( byte ) 0xA0, 0x03,
+ ( byte ) 0x80, 0x01, 0x01 // timeBeforeExpiration
+ } );
bb.flip();
@@ -116,12 +124,12 @@ public class PasswordPolicyTest extends
assertTrue( passwordPolicy.hasResponse() );
assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
}
-
+
@Test
public void testDecodeRespWithGraceAuthWarningOnly() throws Exception
@@ -129,11 +137,11 @@ public class PasswordPolicyTest extends
ByteBuffer bb = ByteBuffer.allocate( 7 );
bb.put( new byte[]
- {
- 0x30, 0x05,
- ( byte ) 0xA0, 0x03,
- ( byte ) 0x81, 0x01, 0x01 // graceAuthNsRemaining
- } );
+ {
+ 0x30, 0x05,
+ ( byte ) 0xA0, 0x03,
+ ( byte ) 0x81, 0x01, 0x01 // graceAuthNsRemaining
+ } );
bb.flip();
@@ -142,57 +150,57 @@ public class PasswordPolicyTest extends
assertTrue( passwordPolicy.hasResponse() );
assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator) passwordPolicy ).encode(
- ByteBuffer.allocate( ( ( PasswordPolicyDecorator) passwordPolicy ).computeLength() ) );
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+ ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
}
-
-
+
+
@Test
public void testDecodeRespWithErrorOnly() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 5 );
bb.put( new byte[]
- {
- 0x30, 0x03,
- ( byte ) 0x81, 0x01, 0x01 // error
- } );
+ {
+ 0x30, 0x03,
+ ( byte ) 0x81, 0x01, 0x01 // error
+ } );
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );
-
+
assertTrue( passwordPolicy.hasResponse() );
assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
- ByteBuffer.allocate( ( ( PasswordPolicyDecorator) passwordPolicy ).computeLength() ) );
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+ ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
}
-
+
@Test
public void testDecodeRespWithoutWarningAndError() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 2 );
bb.put( new byte[]
- {
- 0x30, 0x00
- } );
+ {
+ 0x30, 0x00
+ } );
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );
-
+
assertNotNull( passwordPolicy );
assertTrue( passwordPolicy.hasResponse() );
-
- ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
+
+ ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
assertEquals( "", Strings.dumpBytes( encoded.array() ) );
}
Modified: directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/syncrepl_impl/SyncDoneValueControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/syncrepl_impl/SyncDoneValueControlTest.java?rev=1235364&r1=1235363&r2=1235364&view=diff
==============================================================================
--- directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/syncrepl_impl/SyncDoneValueControlTest.java (original)
+++ directory/shared/trunk/ldap/extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/controls/syncrepl_impl/SyncDoneValueControlTest.java Tue Jan 24 17:27:00 2012
@@ -55,30 +55,33 @@ public class SyncDoneValueControlTest ex
ByteBuffer bb = ByteBuffer.allocate( 11 );
bb.put( new byte[]
- {
- 0x30, 0x09,
+ {
+ 0x30, 0x09,
0x04, 0x04, 'x', 'k', 'c', 'd', // the cookie
- 0x01, 0x01, ( byte ) 0xFF // refreshDeletes flag TRUE
- } );
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF // refreshDeletes flag TRUE
+ } );
bb.flip();
- SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
+ SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
- SyncDoneValue control = (SyncDoneValue)((SyncDoneValueDecorator)decorator).decode( bb.array() );
-
- assertEquals( "xkcd", Strings.utf8ToString(control.getCookie()) );
+ SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );
+
+ assertEquals( "xkcd", Strings.utf8ToString( control.getCookie() ) );
assertTrue( control.isRefreshDeletes() );
-
+
// test encoding
try
{
- ByteBuffer buffer = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
+ ByteBuffer buffer = ( ( SyncDoneValueDecorator ) control ).encode( ByteBuffer
+ .allocate( ( ( SyncDoneValueDecorator ) control ).computeLength() ) );
String expected = Strings.dumpBytes( bb.array() );
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( expected, decoded );
}
- catch( EncoderException e )
+ catch ( EncoderException e )
{
fail( e.getMessage() );
}
@@ -91,17 +94,19 @@ public class SyncDoneValueControlTest ex
ByteBuffer bb = ByteBuffer.allocate( 5 );
bb.put( new byte[]
- {
- 0x30, 0x03,
- // null cookie
- 0x01, 0x01, (byte)0xFF // refreshDeletes flag TRUE
- } );
+ {
+ 0x30, 0x03,
+ // null cookie
+ 0x01,
+ 0x01,
+ ( byte ) 0xFF // refreshDeletes flag TRUE
+ } );
bb.flip();
- SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
+ SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
- SyncDoneValue control = (SyncDoneValue)((SyncDoneValueDecorator)decorator).decode( bb.array() );
+ SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );
assertNull( control.getCookie() );
assertTrue( control.isRefreshDeletes() );
@@ -109,68 +114,72 @@ public class SyncDoneValueControlTest ex
// test encoding
try
{
- ByteBuffer buffer = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
+ ByteBuffer buffer = ( ( SyncDoneValueDecorator ) control ).encode( ByteBuffer
+ .allocate( ( ( SyncDoneValueDecorator ) control ).computeLength() ) );
String expected = Strings.dumpBytes( bb.array() );
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( expected, decoded );
}
- catch( EncoderException e )
+ catch ( EncoderException e )
{
fail( e.getMessage() );
}
}
-
+
@Test
public void testSyncDoneValueWithSequenceOnly() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 2 );
bb.put( new byte[]
- {
- 0x30, 0x00
- } );
+ {
+ 0x30, 0x00
+ } );
bb.flip();
- SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
+ SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
- SyncDoneValue control = (SyncDoneValue)((SyncDoneValueDecorator)decorator).decode( bb.array() );
+ SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );
assertNull( control.getCookie() );
assertFalse( control.isRefreshDeletes() );
}
-
+
@Test
public void testSyncDoneValueControlWithEmptyCookie() throws Exception
{
ByteBuffer bb = ByteBuffer.allocate( 7 );
bb.put( new byte[]
- {
- 0x30, 0x05,
- 0x04, 0x00, // empty cookie
- 0x01, 0x01, 0x00 // refreshDeletes flag FALSE
- } );
+ {
+ 0x30, 0x05,
+ 0x04, 0x00, // empty cookie
+ 0x01,
+ 0x01,
+ 0x00 // refreshDeletes flag FALSE
+ } );
bb.flip();
- SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
+ SyncDoneValue decorator = new SyncDoneValueDecorator( codec );
- SyncDoneValue control = (SyncDoneValue)((SyncDoneValueDecorator)decorator).decode( bb.array() );
+ SyncDoneValue control = ( SyncDoneValue ) ( ( SyncDoneValueDecorator ) decorator ).decode( bb.array() );
- assertEquals( "", Strings.utf8ToString(control.getCookie()) );
+ assertEquals( "", Strings.utf8ToString( control.getCookie() ) );
assertFalse( control.isRefreshDeletes() );
// test encoding
try
{
- ByteBuffer buffer = ((SyncDoneValueDecorator)control).encode( ByteBuffer.allocate( ((SyncDoneValueDecorator)control).computeLength() ) );
+ ByteBuffer buffer = ( ( SyncDoneValueDecorator ) control ).encode( ByteBuffer
+ .allocate( ( ( SyncDoneValueDecorator ) control ).computeLength() ) );
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( "0x30 0x00 ", decoded );
}
- catch( Exception e )
+ catch ( Exception e )
{
fail( e.getMessage() );
}