You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/06 14:17:46 UTC
svn commit: r483066 [5/10] - in
/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src:
main/java/org/apache/directory/ldapstudio/dsmlv2/
main/java/org/apache/directory/ldapstudio/dsmlv2/engine/
main/java/org/apache/directory/ldapstudio/ds...
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@@ -32,95 +33,102 @@
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
+
public class Dsmlv2ResponseParser
-{
+{
private Dsmlv2Container container;
-
- public Dsmlv2ResponseParser() throws XmlPullParserException
- {
+
+
+ public Dsmlv2ResponseParser() throws XmlPullParserException
+ {
this.container = new Dsmlv2Container();
-
+
this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );
-
+
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
// factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
-
+
container.setParser( xpp );
}
-
+
+
public void setInput( String str ) throws FileNotFoundException, XmlPullParserException
{
- container.getParser().setInput( new StringReader( str ) );
+ container.getParser().setInput( new StringReader( str ) );
}
-
+
+
public void setInputFile( String fileName ) throws FileNotFoundException, XmlPullParserException
{
Reader reader = new FileReader( fileName );
container.getParser().setInput( reader );
}
-
+
+
public void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
{
- container.getParser().setInput( inputStream, inputEncoding);
+ container.getParser().setInput( inputStream, inputEncoding );
}
-
-
+
+
public void parse() throws Exception
- {
+ {
Dsmlv2ResponseGrammar grammar = Dsmlv2ResponseGrammar.getInstance();
-
+
grammar.executeAction( container );
}
-
+
+
public void parseBatchResponse() throws XmlPullParserException
- {
- XmlPullParser xpp = container.getParser();
-
- int eventType = xpp.getEventType();
- do
+ {
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ if ( eventType == XmlPullParser.START_DOCUMENT )
{
- if ( eventType == XmlPullParser.START_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.END_STATE );
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
- {
- processTag( container, Tag.END );
- }
- try
- {
- eventType = xpp.next();
- }
- catch ( IOException e )
- {
- throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
- }
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
}
- while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
}
+ while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
+ }
+
-
private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
- {
+ {
XmlPullParser xpp = container.getParser();
-
+
String tagName = xpp.getName().toLowerCase();
-
- GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType) );
-
- if (transition != null)
+
+ GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );
+
+ if ( transition != null )
{
container.setState( transition.getNextState() );
-
+
if ( transition.hasAction() )
{
// System.out.println( transition.getAction().toString() );// TODO Suppress
@@ -129,15 +137,18 @@
}
else
{
- throw new XmlPullParserException( "The tag " + new Tag(tagName, tagType) + " can't be found at this position" , xpp, null );
+ throw new XmlPullParserException( "The tag " + new Tag( tagName, tagType )
+ + " can't be found at this position", xpp, null );
}
}
-
+
+
public BatchResponse getBatchResponse()
{
return container.getBatchResponse();
}
-
+
+
/**
* Returns the next Request or null if there's no more request
* @return the next Request or null if there's no more request
@@ -148,9 +159,10 @@
{
if ( container.getBatchResponse() == null )
{
- throw new XmlPullParserException( "The batch response needs to be parsed before parsing a response", container.getParser(), null );
+ throw new XmlPullParserException( "The batch response needs to be parsed before parsing a response",
+ container.getParser(), null );
}
-
+
XmlPullParser xpp = container.getParser();
int eventType = xpp.getEventType();
@@ -164,7 +176,8 @@
}
catch ( IOException e )
{
- throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
}
eventType = xpp.getEventType();
}
@@ -192,17 +205,20 @@
}
catch ( IOException e )
{
- throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp, null );
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
}
}
while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
return container.getBatchResponse().getCurrentResponse();
}
-
+
+
public void parseAllResponses() throws Exception
{
- while ( getNextResponse() != null ) {
+ while ( getNextResponse() != null )
+ {
continue;
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2StatesEnum.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
/**
* This class store the Dsml grammar's constants. It is also used for debugging
* purpose
@@ -31,63 +32,60 @@
//====================================================
/** The <batchRequest> tag */
public static final int BATCHREQUEST_START_TAG = 104;
-
+
public static final int BATCHREQUEST_LOOP = 105;
-
+
/** The </batchRequest> tag */
public static final int BATCHREQUEST_END_TAG = 1;
-
-
+
//====================================================
// <abandonRequest> ... </abandonRequest>
//====================================================
/** The <abandonRequest> tag */
public static final int ABANDON_REQUEST_START_TAG = 2;
-
+
/** The <control> tag */
public static final int ABANDON_REQUEST_CONTROL_START_TAG = 4;
-
+
/** The </control> tag */
public static final int ABANDON_REQUEST_CONTROL_END_TAG = 5;
-
+
/** The <controlValue> tag */
public static final int ABANDON_REQUEST_CONTROLVALUE_START_TAG = 6;
-
+
/** The </controlValue> tag */
public static final int ABANDON_REQUEST_CONTROLVALUE_END_TAG = 7;
-
-
+
//====================================================
// <addRequest> ... </addRequest>
//====================================================
/** The <addRequest> tag */
public static final int ADD_REQUEST_START_TAG = 8;
-
+
/** The <control> tag */
public static final int ADD_REQUEST_CONTROL_START_TAG = 10;
-
+
/** The </control> tag */
public static final int ADD_REQUEST_CONTROL_END_TAG = 11;
/** The <controlValue> tag */
public static final int ADD_REQUEST_CONTROLVALUE_START_TAG = 12;
-
+
/** The </controlValue> tag */
public static final int ADD_REQUEST_CONTROLVALUE_END_TAG = 13;
-
+
/** The <attr> tag */
public static final int ADD_REQUEST_ATTR_START_TAG = 14;
-
+
/** The </attr> tag */
public static final int ADD_REQUEST_ATTR_END_TAG = 15;
-
+
/** The <value> tag */
public static final int ADD_REQUEST_VALUE_START_TAG = 16;
-
+
/** The </value> tag */
public static final int ADD_REQUEST_VALUE_END_TAG = 17;
-
-
+
//====================================================
// <authRequest> ... </authRequest>
//====================================================
@@ -96,17 +94,16 @@
/** The <control> tag */
public static final int AUTH_REQUEST_CONTROL_START_TAG = 20;
-
+
/** The </control> tag */
public static final int AUTH_REQUEST_CONTROL_END_TAG = 21;
/** The <controlValue> tag */
public static final int AUTH_REQUEST_CONTROLVALUE_START_TAG = 22;
-
+
/** The </controlValue> tag */
public static final int AUTH_REQUEST_CONTROLVALUE_END_TAG = 23;
-
-
+
//====================================================
// <compareRequest> ... </compareRequest>
//====================================================
@@ -115,47 +112,45 @@
/** The <control> tag */
public static final int COMPARE_REQUEST_CONTROL_START_TAG = 26;
-
+
/** The </control> tag */
public static final int COMPARE_REQUEST_CONTROL_END_TAG = 27;
/** The <controlValue> tag */
public static final int COMPARE_REQUEST_CONTROLVALUE_START_TAG = 28;
-
+
/** The </controlValue> tag */
public static final int COMPARE_REQUEST_CONTROLVALUE_END_TAG = 29;
/** The <assertion> tag */
public static final int COMPARE_REQUEST_ASSERTION_START_TAG = 30;
-
+
/** The </assertion> tag */
public static final int COMPARE_REQUEST_ASSERTION_END_TAG = 31;
/** The <value> tag */
public static final int COMPARE_REQUEST_VALUE_START_TAG = 32;
-
+
/** The </value> tag */
public static final int COMPARE_REQUEST_VALUE_END_TAG = 33;
-
//====================================================
// <delRequest> ... </delRequest>
//====================================================
/** The <delRequest> tag */
public static final int DEL_REQUEST_START_TAG = 34;
-
+
/** The <control> tag */
public static final int DEL_REQUEST_CONTROL_START_TAG = 36;
-
+
/** The </control> tag */
public static final int DEL_REQUEST_CONTROL_END_TAG = 37;
/** The <controlValue> tag */
public static final int DEL_REQUEST_CONTROLVALUE_START_TAG = 38;
-
+
/** The </controlValue> tag */
public static final int DEL_REQUEST_CONTROLVALUE_END_TAG = 39;
-
//====================================================
// <extendedRequest> ... </extendedRequest>
@@ -165,29 +160,28 @@
/** The <control> tag */
public static final int EXTENDED_REQUEST_CONTROL_START_TAG = 42;
-
+
/** The </control> tag */
public static final int EXTENDED_REQUEST_CONTROL_END_TAG = 43;
/** The <controlValue> tag */
public static final int EXTENDED_REQUEST_CONTROLVALUE_START_TAG = 44;
-
+
/** The </controlValue> tag */
public static final int EXTENDED_REQUEST_CONTROLVALUE_END_TAG = 45;
-
+
/** The <requestName> tag */
public static final int EXTENDED_REQUEST_REQUESTNAME_START_TAG = 46;
-
+
/** The </requestName> tag */
public static final int EXTENDED_REQUEST_REQUESTNAME_END_TAG = 47;
-
+
/** The <requestValue> tag */
public static final int EXTENDED_REQUEST_REQUESTVALUE_START_TAG = 48;
-
+
/** The </requestValue> tag */
public static final int EXTENDED_REQUEST_REQUESTVALUE_END_TAG = 49;
-
//====================================================
// <modDNRequest> ... </modDNRequest>
//====================================================
@@ -196,93 +190,91 @@
/** The <control> tag */
public static final int MODIFY_DN_REQUEST_CONTROL_START_TAG = 52;
-
+
/** The </control> tag */
public static final int MODIFY_DN_REQUEST_CONTROL_END_TAG = 53;
/** The <controlValue> tag */
public static final int MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG = 54;
-
+
/** The </controlValue> tag */
public static final int MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG = 55;
-
//====================================================
// <modifyRequest> ... </modifyRequest>
//====================================================
/** The <modifyRequest> tag */
public static final int MODIFY_REQUEST_START_TAG = 56;
-
+
/** The <control> tag */
public static final int MODIFY_REQUEST_CONTROL_START_TAG = 58;
-
+
/** The </control> tag */
public static final int MODIFY_REQUEST_CONTROL_END_TAG = 59;
/** The <controlValue> tag */
public static final int MODIFY_REQUEST_CONTROLVALUE_START_TAG = 60;
-
+
/** The </controlValue> tag */
public static final int MODIFY_REQUEST_CONTROLVALUE_END_TAG = 61;
/** The <modification> tag */
public static final int MODIFY_REQUEST_MODIFICATION_START_TAG = 62;
-
+
/** The </modification> tag */
public static final int MODIFY_REQUEST_MODIFICATION_END_TAG = 63;
/** The <value> tag */
public static final int MODIFY_REQUEST_VALUE_START_TAG = 64;
-
+
/** The </value> tag */
public static final int MODIFY_REQUEST_VALUE_END_TAG = 65;
-
-
+
//====================================================
// <searchRequest> ... </searchRequest>
//====================================================
/** The <searchRequest> tag */
public static final int SEARCH_REQUEST_START_TAG = 66;
-
+
/** The <control> tag */
public static final int SEARCH_REQUEST_CONTROL_START_TAG = 68;
-
+
/** The </control> tag */
public static final int SEARCH_REQUEST_CONTROL_END_TAG = 69;
/** The <controlValue> tag */
public static final int SEARCH_REQUEST_CONTROLVALUE_START_TAG = 70;
-
+
/** The </controlValue> tag */
public static final int SEARCH_REQUEST_CONTROLVALUE_END_TAG = 71;
/** The <filter> tag */
public static final int SEARCH_REQUEST_FILTER_START_TAG = 72;
-
+
/** The </filter> tag */
public static final int SEARCH_REQUEST_FILTER_END_TAG = 73;
-
+
/** The <attributes> tag */
public static final int SEARCH_REQUEST_ATTRIBUTES_START_TAG = 74;
-
+
/** The </attributes> tag */
public static final int SEARCH_REQUEST_ATTRIBUTES_END_TAG = 75;
-
+
/** The <attribute> tag */
public static final int SEARCH_REQUEST_ATTRIBUTE_START_TAG = 76;
-
+
/** The </attribute> tag */
public static final int SEARCH_REQUEST_ATTRIBUTE_END_TAG = 77;
-
+
/** The <equalityMatch> tag */
public static final int SEARCH_REQUEST_EQUALITYMATCH_START_TAG = 84;
-
+
/** The <subStrings> tag */
public static final int SEARCH_REQUEST_SUBSTRINGS_START_TAG = 86;
-
+
/** The </subStrings> tag */
public static final int SEARCH_REQUEST_SUBSTRINGS_END_TAG = 87;
-
+
/** The <greaterOrEqual> tag */
public static final int SEARCH_REQUEST_GREATEROREQUAL_START_TAG = 88;
@@ -291,99 +283,98 @@
/** The <present> tag */
public static final int SEARCH_REQUEST_PRESENT_START_TAG = 92;
-
+
/** The <approxMatch> tag */
public static final int SEARCH_REQUEST_APPROXMATCH_START_TAG = 94;
-
+
/** The <extensibleMatch> tag */
public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG = 96;
-
+
/** The <value> tag */
public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG = 109;
-
+
/** The </value> tag */
public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG = 110;
-
+
/** The <initial> tag */
public static final int SEARCH_REQUEST_INITIAL_START_TAG = 98;
-
+
/** The </initial> tag */
public static final int SEARCH_REQUEST_INITIAL_END_TAG = 99;
-
+
/** The <any> tag */
public static final int SEARCH_REQUEST_ANY_START_TAG = 100;
-
+
/** The </any> tag */
public static final int SEARCH_REQUEST_ANY_END_TAG = 101;
-
+
/** The <final> tag */
public static final int SEARCH_REQUEST_FINAL_START_TAG = 102;
-
+
/** The </final> tag */
public static final int SEARCH_REQUEST_FINAL_END_TAG = 103;
-
+
/** The <value> tag */
public static final int SEARCH_REQUEST_VALUE_START_TAG = 107;
-
+
/** The </value> tag */
public static final int SEARCH_REQUEST_VALUE_END_TAG = 108;
-
+
/** The Filter Loop state */
public static final int SEARCH_REQUEST_FILTER_LOOP = 106;
-
-
+
//****************
// DSML Response
//****************
-
+
/** The Batch Response Loop state */
public static final int BATCH_RESPONSE_LOOP = 200;
-
+
/** The Error Response Loop state */
public static final int ERROR_RESPONSE = 201;
-
+
/** The Message Start state */
public static final int MESSAGE_START = 202;
-
+
/** The Message End state */
public static final int MESSAGE_END = 203;
-
+
/** The Detail Start state */
public static final int DETAIL_START = 204;
-
+
/** The Detail End state */
public static final int DETAIL_END = 205;
-
+
/** The Extended Response state */
public static final int EXTENDED_RESPONSE = 206;
-
+
/** The Extended Response Control Start state */
public static final int EXTENDED_RESPONSE_CONTROL_START = 207;
-
+
/** The Extended Response Control End state */
public static final int EXTENDED_RESPONSE_CONTROL_END = 208;
-
+
/** The Extended Response Control Value Start state */
public static final int EXTENDED_RESPONSE_CONTROL_VALUE_START = 245;
-
+
/** The Extended Response Control Value End state */
public static final int EXTENDED_RESPONSE_CONTROL_VALUE_END = 246;
-
+
/** The Extended Response Result Code Start state */
public static final int EXTENDED_RESPONSE_RESULT_CODE_START = 209;
-
+
/** The Extended Response Result Code End state */
public static final int EXTENDED_RESPONSE_RESULT_CODE_END = 210;
-
+
/** The Extended Response Error Message Start state */
public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_START = 211;
-
+
/** The Extended Response Error Message End state */
public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_END = 212;
-
+
/** The Extended Response Referral Start state */
public static final int EXTENDED_RESPONSE_REFERRAL_START = 213;
-
+
/** The Extended Response Referral End state */
public static final int EXTENDED_RESPONSE_REFERRAL_END = 214;
@@ -392,7 +383,7 @@
/** The Response Name End state */
public static final int RESPONSE_NAME_END = 216;
-
+
/** The Response Start state */
public static final int RESPONSE_START = 217;
@@ -407,7 +398,7 @@
/** The LDAP Result Control End state */
public static final int LDAP_RESULT_CONTROL_END = 221;
-
+
/** The LDAP Result Control Value Start state */
public static final int LDAP_RESULT_CONTROL_VALUE_START = 247;
@@ -434,7 +425,7 @@
/** The LDAP Result End state */
public static final int LDAP_RESULT_END = 228;
-
+
/** The Search Response state */
public static final int SEARCH_RESPONSE = 229;
@@ -446,7 +437,7 @@
/** The Search Result Entry Control End state */
public static final int SEARCH_RESULT_ENTRY_CONTROL_END = 232;
-
+
/** The Search Result Entry Control Value Start state */
public static final int SEARCH_RESULT_ENTRY_CONTROL_VALUE_START = 249;
@@ -467,42 +458,43 @@
/** The Search Result Entry Loop state */
public static final int SEARCH_RESULT_ENTRY_LOOP = 237;
-
+
/** The Search Result Reference state */
public static final int SEARCH_RESULT_REFERENCE = 238;
-
+
/** The Search Result Reference Control Start state */
public static final int SEARCH_RESULT_REFERENCE_CONTROL_START = 239;
-
+
/** The Search Result Reference Control End state */
public static final int SEARCH_RESULT_REFERENCE_CONTROL_END = 240;
-
+
/** The Search Result Reference Control Value Start state */
public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START = 251;
-
+
/** The Search Result Reference Control Value End state */
public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END = 252;
-
+
/** The Search Result Reference Ref Start state */
public static final int SEARCH_RESULT_REFERENCE_REF_START = 241;
-
+
/** The Search Result Reference Ref End state */
public static final int SEARCH_RESULT_REFERENCE_REF_END = 242;
-
+
/** The Search Result Reference Loop state */
public static final int SEARCH_RESULT_REFERENCE_LOOP = 243;
-
+
/** The Search Result Done End state */
public static final int SEARCH_RESULT_DONE_END = 244;
-
-
+
/** The instance */
private static Dsmlv2StatesEnum instance = new Dsmlv2StatesEnum();
-
+
+
private Dsmlv2StatesEnum()
{
}
-
+
+
/**
* Get an instance of this class
*
@@ -513,6 +505,7 @@
return instance;
}
+
/** Get the current state for a specified grammar */
public String getState( int state )
{
@@ -566,7 +559,7 @@
return "COMPARE_REQUEST_START_TAG";
case COMPARE_REQUEST_CONTROL_START_TAG:
return "COMPARE_REQUEST_CONTROL_START_TAG";
- case COMPARE_REQUEST_CONTROL_END_TAG:
+ case COMPARE_REQUEST_CONTROL_END_TAG:
return "COMPARE_REQUEST_CONTROL_END_TAG";
case COMPARE_REQUEST_CONTROLVALUE_START_TAG:
return "COMPARE_REQUEST_CONTROLVALUE_START_TAG";
@@ -592,7 +585,7 @@
return "DEL_REQUEST_CONTROLVALUE_END_TAG";
case EXTENDED_REQUEST_START_TAG:
return "EXTENDED_REQUEST_START_TAG";
- case EXTENDED_REQUEST_CONTROL_START_TAG:
+ case EXTENDED_REQUEST_CONTROL_START_TAG:
return "EXTENDED_REQUEST_CONTROL_START_TAG";
case EXTENDED_REQUEST_CONTROL_END_TAG:
return "EXTENDED_REQUEST_CONTROL_END_TAG";
@@ -662,7 +655,7 @@
return "SEARCH_REQUEST_EQUALITYMATCH_START_TAG";
case SEARCH_REQUEST_SUBSTRINGS_START_TAG:
return "SEARCH_REQUEST_SUBSTRINGS_START_TAG";
- case SEARCH_REQUEST_SUBSTRINGS_END_TAG:
+ case SEARCH_REQUEST_SUBSTRINGS_END_TAG:
return "SEARCH_REQUEST_SUBSTRINGS_END_TAG";
case SEARCH_REQUEST_GREATEROREQUAL_START_TAG:
return "SEARCH_REQUEST_GREATEROREQUAL_START_TAG";
@@ -696,113 +689,113 @@
return "SEARCH_REQUEST_VALUE_END_TAG";
case SEARCH_REQUEST_FILTER_LOOP:
return "SEARCH_REQUEST_FILTER_LOOP";
-
+
case BATCH_RESPONSE_LOOP:
- return "BATCH_RESPONSE_LOOP";
+ return "BATCH_RESPONSE_LOOP";
case ERROR_RESPONSE:
- return "ERROR_RESPONSE";
+ return "ERROR_RESPONSE";
case MESSAGE_START:
- return "MESSAGE_START";
+ return "MESSAGE_START";
case MESSAGE_END:
- return "MESSAGE_END";
+ return "MESSAGE_END";
case DETAIL_START:
- return "DETAIL_START";
+ return "DETAIL_START";
case DETAIL_END:
- return "DETAIL_END";
+ return "DETAIL_END";
case EXTENDED_RESPONSE:
- return "EXTENDED_RESPONSE";
+ return "EXTENDED_RESPONSE";
case EXTENDED_RESPONSE_CONTROL_START:
- return "EXTENDED_RESPONSE_CONTROL_START";
+ return "EXTENDED_RESPONSE_CONTROL_START";
case EXTENDED_RESPONSE_CONTROL_END:
- return "EXTENDED_RESPONSE_CONTROL_END";
+ return "EXTENDED_RESPONSE_CONTROL_END";
case EXTENDED_RESPONSE_CONTROL_VALUE_START:
- return "EXTENDED_RESPONSE_CONTROL_VALUE_START";
+ return "EXTENDED_RESPONSE_CONTROL_VALUE_START";
case EXTENDED_RESPONSE_CONTROL_VALUE_END:
- return "EXTENDED_RESPONSE_CONTROL_VALUE_END";
+ return "EXTENDED_RESPONSE_CONTROL_VALUE_END";
case EXTENDED_RESPONSE_RESULT_CODE_START:
- return "EXTENDED_RESPONSE_RESULT_CODE_START";
+ return "EXTENDED_RESPONSE_RESULT_CODE_START";
case EXTENDED_RESPONSE_RESULT_CODE_END:
- return "EXTENDED_RESPONSE_RESULT_CODE_END";
+ return "EXTENDED_RESPONSE_RESULT_CODE_END";
case EXTENDED_RESPONSE_ERROR_MESSAGE_START:
- return "EXTENDED_RESPONSE_ERROR_MESSAGE_START";
+ return "EXTENDED_RESPONSE_ERROR_MESSAGE_START";
case EXTENDED_RESPONSE_ERROR_MESSAGE_END:
- return "EXTENDED_RESPONSE_ERROR_MESSAGE_END";
+ return "EXTENDED_RESPONSE_ERROR_MESSAGE_END";
case EXTENDED_RESPONSE_REFERRAL_START:
- return "EXTENDED_RESPONSE_REFERRAL_START";
+ return "EXTENDED_RESPONSE_REFERRAL_START";
case EXTENDED_RESPONSE_REFERRAL_END:
- return "EXTENDED_RESPONSE_REFERRAL_END";
+ return "EXTENDED_RESPONSE_REFERRAL_END";
case RESPONSE_NAME_START:
- return "RESPONSE_NAME_START";
+ return "RESPONSE_NAME_START";
case RESPONSE_NAME_END:
- return "RESPONSE_NAME_END";
+ return "RESPONSE_NAME_END";
case RESPONSE_START:
- return "RESPONSE_START";
+ return "RESPONSE_START";
case RESPONSE_END:
- return "RESPONSE_END";
+ return "RESPONSE_END";
case LDAP_RESULT:
- return "LDAP_RESULT";
+ return "LDAP_RESULT";
case LDAP_RESULT_CONTROL_START:
- return "LDAP_RESULT_CONTROL_START";
+ return "LDAP_RESULT_CONTROL_START";
case LDAP_RESULT_CONTROL_END:
- return "LDAP_RESULT_CONTROL_END";
+ return "LDAP_RESULT_CONTROL_END";
case LDAP_RESULT_CONTROL_VALUE_START:
- return "LDAP_RESULT_CONTROL_VALUE_START";
+ return "LDAP_RESULT_CONTROL_VALUE_START";
case LDAP_RESULT_CONTROL_VALUE_END:
- return "LDAP_RESULT_CONTROL_VALUE_END";
+ return "LDAP_RESULT_CONTROL_VALUE_END";
case LDAP_RESULT_RESULT_CODE_START:
- return "LDAP_RESULT_RESULT_CODE_START";
+ return "LDAP_RESULT_RESULT_CODE_START";
case LDAP_RESULT_RESULT_CODE_END:
- return "LDAP_RESULT_RESULT_CODE_END";
+ return "LDAP_RESULT_RESULT_CODE_END";
case LDAP_RESULT_ERROR_MESSAGE_START:
- return "LDAP_RESULT_ERROR_MESSAGE_START";
+ return "LDAP_RESULT_ERROR_MESSAGE_START";
case LDAP_RESULT_ERROR_MESSAGE_END:
- return "LDAP_RESULT_ERROR_MESSAGE_END";
+ return "LDAP_RESULT_ERROR_MESSAGE_END";
case LDAP_RESULT_REFERRAL_START:
- return "LDAP_RESULT_REFERRAL_START";
+ return "LDAP_RESULT_REFERRAL_START";
case LDAP_RESULT_REFERRAL_END:
- return "LDAP_RESULT_REFERRAL_END";
+ return "LDAP_RESULT_REFERRAL_END";
case LDAP_RESULT_END:
- return "LDAP_RESULT_END";
+ return "LDAP_RESULT_END";
case SEARCH_RESPONSE:
- return "SEARCH_RESPONSE";
+ return "SEARCH_RESPONSE";
case SEARCH_RESULT_ENTRY:
- return "SEARCH_RESULT_ENTRY";
+ return "SEARCH_RESULT_ENTRY";
case SEARCH_RESULT_ENTRY_CONTROL_START:
- return "SEARCH_RESULT_ENTRY_CONTROL_START";
+ return "SEARCH_RESULT_ENTRY_CONTROL_START";
case SEARCH_RESULT_ENTRY_CONTROL_END:
- return "SEARCH_RESULT_ENTRY_CONTROL_END";
+ return "SEARCH_RESULT_ENTRY_CONTROL_END";
case SEARCH_RESULT_ENTRY_CONTROL_VALUE_START:
- return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_START";
+ return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_START";
case SEARCH_RESULT_ENTRY_CONTROL_VALUE_END:
- return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_END";
+ return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_END";
case SEARCH_RESULT_ENTRY_ATTR_START:
- return "SEARCH_RESULT_ENTRY_ATTR_START";
+ return "SEARCH_RESULT_ENTRY_ATTR_START";
case SEARCH_RESULT_ENTRY_ATTR_END:
- return "SEARCH_RESULT_ENTRY_ATTR_END";
+ return "SEARCH_RESULT_ENTRY_ATTR_END";
case SEARCH_RESULT_ENTRY_VALUE_START:
- return "SEARCH_RESULT_ENTRY_VALUE_START";
+ return "SEARCH_RESULT_ENTRY_VALUE_START";
case SEARCH_RESULT_ENTRY_VALUE_END:
- return "SEARCH_RESULT_ENTRY_VALUE_END";
+ return "SEARCH_RESULT_ENTRY_VALUE_END";
case SEARCH_RESULT_ENTRY_LOOP:
- return "SEARCH_RESULT_ENTRY_LOOP";
+ return "SEARCH_RESULT_ENTRY_LOOP";
case SEARCH_RESULT_REFERENCE:
- return "SEARCH_RESULT_REFERENCE";
+ return "SEARCH_RESULT_REFERENCE";
case SEARCH_RESULT_REFERENCE_CONTROL_START:
- return "SEARCH_RESULT_REFERENCE_CONTROL_START";
+ return "SEARCH_RESULT_REFERENCE_CONTROL_START";
case SEARCH_RESULT_REFERENCE_CONTROL_END:
- return "SEARCH_RESULT_REFERENCE_CONTROL_END";
+ return "SEARCH_RESULT_REFERENCE_CONTROL_END";
case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START:
- return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START";
+ return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START";
case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END:
- return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END";
+ return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END";
case SEARCH_RESULT_REFERENCE_REF_START:
- return "SEARCH_RESULT_REFERENCE_REF_START";
+ return "SEARCH_RESULT_REFERENCE_REF_START";
case SEARCH_RESULT_REFERENCE_REF_END:
- return "SEARCH_RESULT_REFERENCE_REF_END";
+ return "SEARCH_RESULT_REFERENCE_REF_END";
case SEARCH_RESULT_REFERENCE_LOOP:
- return "SEARCH_RESULT_REFERENCE_LOOP";
+ return "SEARCH_RESULT_REFERENCE_LOOP";
case SEARCH_RESULT_DONE_END:
- return "SEARCH_RESULT_DONE_END";
+ return "SEARCH_RESULT_DONE_END";
default:
return "UNKNOWN";
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarAction.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
/**
* A top level grammar class that store meta informations about the actions.
* Those informations are not mandatory, but they can be usefull for debugging.
@@ -44,7 +45,7 @@
* @param name
* The name of the create daction
*/
- public GrammarAction(String name)
+ public GrammarAction( String name )
{
this.name = name;
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/GrammarTransition.java Wed Dec 6 05:17:42 2006
@@ -55,7 +55,7 @@
* @param action
* The action to execute. It could be null.
*/
- public GrammarTransition(int currentState, int nextState, GrammarAction action)
+ public GrammarTransition( int currentState, int nextState, GrammarAction action )
{
this.currentState = currentState;
this.nextState = nextState;
@@ -106,9 +106,9 @@
StringBuffer sb = new StringBuffer();
- sb.append( "Transition from <" ).append( statesEnum.getState( currentState ) ).append( "> to <" )
- .append( statesEnum.getState( nextState ) ).append( ">, action : " ).append(
- ( ( action == null ) ? "no action" : action.toString() ) ).append( ">" );
+ sb.append( "Transition from <" ).append( statesEnum.getState( currentState ) ).append( "> to <" ).append(
+ statesEnum.getState( nextState ) ).append( ">, action : " ).append(
+ ( ( action == null ) ? "no action" : action.toString() ) ).append( ">" );
return sb.toString();
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IAction.java Wed Dec 6 05:17:42 2006
@@ -20,7 +20,9 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import org.xmlpull.v1.XmlPullParserException;
+
/**
* IAction interface just contains the method 'action' which must be implemented
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IGrammar.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import org.apache.directory.shared.asn1.codec.DecoderException;
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/IStates.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
/**
* This interface is used to store the different states of a grammar.
*/
@@ -34,6 +35,7 @@
/** The END_STATE */
static int END_STATE = -1;
+
/** Get the current state for a specified grammar */
- String getState(int state );
+ String getState( int state );
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Tag.java Wed Dec 6 05:17:42 2006
@@ -20,41 +20,48 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
public class Tag
{
private String name;
private int type;
-
+
public static int START = 0;
public static int END = 1;
-
+
+
public Tag( String name, int type )
{
setName( name );
setType( type );
}
+
public String getName()
{
return name;
}
+
public void setName( String name )
{
this.name = name.toLowerCase();
}
+
public int getType()
{
return type;
}
+
public void setType( int type )
{
this.type = type;
}
+
@Override
public boolean equals( Object obj )
{
@@ -62,7 +69,7 @@
{
Tag tag = ( Tag ) obj;
return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
-
+
}
else
{
@@ -70,24 +77,26 @@
}
}
+
@Override
public int hashCode()
{
-
- return name.hashCode() + type<<24;
+
+ return name.hashCode() + type << 24;
}
+
@Override
public String toString()
{
- if (name != null)
+ if ( name != null )
{
- return "<" + ( (type == Tag.END) ? "/" : "" ) + name + ">";
+ return "<" + ( ( type == Tag.END ) ? "/" : "" ) + name + ">";
}
else
{
return "Unknown tag";
}
}
-
+
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/engine/Dsmlv2Engine.java Wed Dec 6 05:17:42 2006
@@ -96,13 +96,11 @@
private String user;
private String password;
-
private Asn1Decoder ldapDecoder = new LdapDecoder();
-
+
private IAsn1Container ldapMessageContainer = new LdapMessageContainer();
private Dsmlv2Parser parser;
-
private boolean continueOnError;
private boolean exit = false;
@@ -112,7 +110,8 @@
private int bbposition;
private Document xmlResponse;
private BatchRequest batchRequest;
-
+
+
/**
* Default Constructor
*
@@ -128,7 +127,8 @@
this.user = user;
this.password = password;
}
-
+
+
/**
* Processes the file given and return the result of the operations
* @param fileName The path to the file
@@ -141,11 +141,11 @@
parser = new Dsmlv2Parser();
parser.setInput( fileName );
-
+
return processDSML();
}
-
-
+
+
/**
* Processes the file given and return the result of the operations
* @param fileName The path to the file
@@ -158,10 +158,11 @@
parser = new Dsmlv2Parser();
parser.setInputFile( fileName );
-
+
return processDSML();
}
-
+
+
/**
* Processes the file given and return the result of the operations
* @param inputStream contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null).
@@ -170,15 +171,17 @@
* @throws XmlPullParserException
* @throws FileNotFoundException
*/
- public String processDSML( InputStream inputStream, String inputEncoding ) throws XmlPullParserException, FileNotFoundException
+ public String processDSML( InputStream inputStream, String inputEncoding ) throws XmlPullParserException,
+ FileNotFoundException
{
parser = new Dsmlv2Parser();
parser.setInput( inputStream, inputEncoding );
-
+
return processDSML();
}
+
/**
* Processes the Request document
* @return The XML reponse in DSMLv2 Format
@@ -188,7 +191,7 @@
// Creating XML Document and root Element 'batchResponse'
xmlResponse = DocumentHelper.createDocument();
xmlResponse.addElement( "batchResponse" );
-
+
// Binding to LDAP Server
try
{
@@ -199,11 +202,11 @@
// Unable to connect to server
// We create a new ErrorResponse and return the XML response.
ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.COULD_NOT_CONNECT, e.getMessage() );
-
+
errorResponse.toDsml( xmlResponse.getRootElement() );
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
-
+
// Processing BatchRequest:
// - Parsing and Getting BatchRequest
// - Getting and registering options from BatchRequest
@@ -214,13 +217,13 @@
catch ( XmlPullParserException e )
{
// We create a new ErrorResponse and return the XML response.
- ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
- + " - Line "+ e.getLineNumber() + " - Column " + e.getColumnNumber() );
-
+ ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+ + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+
errorResponse.toDsml( xmlResponse.getRootElement() );
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
-
+
// Processing each request:
// - Getting a new request
// - Checking if the request is well formed
@@ -235,9 +238,9 @@
catch ( XmlPullParserException e )
{
// We create a new ErrorResponse and return the XML response.
- ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
- + " - Line "+ e.getLineNumber() + " - Column " + e.getColumnNumber() );
-
+ ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+ + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+
errorResponse.toDsml( xmlResponse.getRootElement() );
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
@@ -256,26 +259,27 @@
errorResponse.toDsml( xmlResponse.getRootElement() );
return xmlResponse.asXML();
}
-
+
try
{
processRequest( request );
}
catch ( Exception e )
{
- // We create a new ErrorResponse and return the XML response.
- ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.GATEWAY_INTERNAL_ERROR, "Internal Error: " + e.getMessage() );
-
+ // We create a new ErrorResponse and return the XML response.
+ ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.GATEWAY_INTERNAL_ERROR,
+ "Internal Error: " + e.getMessage() );
+
errorResponse.toDsml( xmlResponse.getRootElement() );
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
-
+
// Checking if we need to exit processing (if an error has ocurred if onError == Exit)
if ( exit )
{
break;
}
-
+
// Getting next request
try
{
@@ -284,17 +288,18 @@
catch ( XmlPullParserException e )
{
// We create a new ErrorResponse and return the XML response.
- ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
- + " - Line "+ e.getLineNumber() + " - Column " + e.getColumnNumber() );
-
+ ErrorResponse errorResponse = new ErrorResponse( 0, ErrorResponseType.MALFORMED_REQUEST, e.getMessage()
+ + " - Line " + e.getLineNumber() + " - Column " + e.getColumnNumber() );
+
errorResponse.toDsml( xmlResponse.getRootElement() );
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
}
-
+
return styleDocument( xmlResponse, "DSMLv2.xslt" ).asXML();
}
-
+
+
/**
* Processes a single request
* @param request the request to process
@@ -303,7 +308,8 @@
* @throws NamingException
* @throws DecoderException
*/
- private void processRequest(LdapMessage request) throws EncoderException, IOException, DecoderException, NamingException
+ private void processRequest( LdapMessage request ) throws EncoderException, IOException, DecoderException,
+ NamingException
{
LdapMessage message = new LdapMessage();
@@ -312,21 +318,20 @@
message.setMessageId( request.getMessageId() );
ByteBuffer bb = null;
-
+
bb = message.encode( null );
-
+
bb.flip();
-
sendMessage( bb );
-
+
bb.clear();
bb.position( bb.capacity() );
// Get the response
LdapMessage response = null;
-
+
response = readResponse( bb );
-
+
if ( LdapConstants.ADD_RESPONSE == response.getMessageType() )
{
AddResponseDsml addResponseDsml = new AddResponseDsml( response );
@@ -362,7 +367,7 @@
ExtendedResponseDsml extendedResponseDsml = new ExtendedResponseDsml( response );
extendedResponseDsml.toDsml( xmlResponse.getRootElement() );
}
- else if ( ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
+ else if ( ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
|| ( LdapConstants.SEARCH_RESULT_REFERENCE == response.getMessageType() )
|| ( LdapConstants.SEARCH_RESULT_DONE == response.getMessageType() ) )
{
@@ -372,14 +377,14 @@
// - 1 (only) SearchResultDone
// So we have to include those individual reponses in a "General" SearchResponse
Element searchResponse = xmlResponse.getRootElement().addElement( "searchResponse" );
-
+
// RequestID
int requestID = response.getMessageId();
if ( requestID != 0 )
{
searchResponse.addAttribute( "requestID", "" + requestID );
}
-
+
while ( LdapConstants.SEARCH_RESULT_DONE != response.getMessageType() )
{
if ( LdapConstants.SEARCH_RESULT_ENTRY == response.getMessageType() )
@@ -392,14 +397,14 @@
SearchResultReferenceDsml searchResultReferenceDsml = new SearchResultReferenceDsml( response );
searchResultReferenceDsml.toDsml( searchResponse );
}
-
+
response = readResponse( bb );
}
-
+
SearchResultDoneDsml searchResultDoneDsml = new SearchResultDoneDsml( response );
searchResultDoneDsml.toDsml( searchResponse );
}
-
+
LdapResponse realResponse = response.getLdapResponse();
if ( !continueOnError )
@@ -410,12 +415,13 @@
&& ( realResponse.getLdapResult().getResultCode() != LdapResultEnum.REFERRAL ) )
{
// Turning on Exit flag
- exit = true;
+ exit = true;
}
}
-
+
}
+
/**
* Processes the BatchRequest
* - Parsing and Getting BatchRequest
@@ -426,8 +432,7 @@
{
// Parsing BatchRequest
parser.parseBatchRequest();
-
-
+
// Getting BatchRequest
batchRequest = parser.getBatchRequest();
@@ -440,28 +445,28 @@
continueOnError = false;
}
-
if ( batchRequest.getRequestID() != 0 )
{
xmlResponse.getRootElement().addAttribute( "requestID", "" + batchRequest.getRequestID() );
- }
+ }
}
+
/**
* XML Pretty Printer XSLT Tranformation
* @param document
* @param stylesheet
* @return
*/
- public Document styleDocument( Document document, String stylesheet ){
+ public Document styleDocument( Document document, String stylesheet )
+ {
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = null;
try
{
- transformer = factory.newTransformer(
- new StreamSource( Dsmlv2Engine.class.getResourceAsStream( stylesheet ) )
- );
+ transformer = factory
+ .newTransformer( new StreamSource( Dsmlv2Engine.class.getResourceAsStream( stylesheet ) ) );
}
catch ( TransformerConfigurationException e1 )
{
@@ -502,40 +507,6 @@
{
serverAddress = new InetSocketAddress( host, port );
channel = SocketChannel.open( serverAddress );
-
-// SecurityManager security = System.getSecurityManager();
-// security.checkConnect( host, port );
-// channel = SocketChannel.open();
-// channel.configureBlocking( false );
-// channel.socket().setSoTimeout( 1 );
-// channel.connect( serverAddress );
-
-// try
-// {
-// Socket sock = new Socket();
-// System.out.println( sock.getSendBufferSize() );
-//// sock.setSoLinger( true, 20 );
-// sock.connect( new InetSocketAddress( host, port ) );
-// }
-// catch( IOException ioe )
-// {
-// System.out.println( "error" );
-// }
-
-
-// while ( channel.isConnectionPending() )
-// {
-// System.out.println("pending" + channel.socket().getSoTimeout());
-// try
-// {
-// Thread.sleep( 1000 );
-// }
-// catch ( InterruptedException e )
-// {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// }
channel.configureBlocking( true );
}
@@ -551,7 +522,8 @@
channel.write( bb );
bb.clear();
}
-
+
+
/**
* Reads the response to a request
* @param bb
@@ -564,7 +536,7 @@
{
LdapMessage messageResp = null;
-
+
if ( bb.hasRemaining() )
{
bb.position( bbposition );
@@ -576,27 +548,26 @@
bb.flip();
while ( ldapMessageContainer.getState() != TLVStateEnum.PDU_DECODED )
{
-
+
int nbRead = channel.read( bb );
if ( nbRead == -1 )
{
- System.err.println("fsdfsdfsdfsd");
+ System.err.println( "fsdfsdfsdfsd" );
}
-
+
bb.flip();
ldapDecoder.decode( bb, ldapMessageContainer );
bbposition = bb.position();
bbLimit = bb.limit();
bb.flip();
}
-
+
messageResp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
if ( messageResp instanceof BindResponse )
{
- BindResponse resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage()
- .getBindResponse();
+ BindResponse resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage().getBindResponse();
if ( resp.getLdapResult().getResultCode() != 0 )
{
@@ -606,7 +577,7 @@
else if ( messageResp instanceof ExtendedResponse )
{
ExtendedResponse resp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage()
- .getExtendedResponse();
+ .getExtendedResponse();
if ( resp.getLdapResult().getResultCode() != 0 )
{
@@ -615,8 +586,7 @@
}
( ( LdapMessageContainer ) ldapMessageContainer ).clean();
-
-
+
return messageResp;
}
@@ -649,9 +619,9 @@
sendMessage( bb );
bb.clear();
-
+
bb.position( bb.limit() );
-
+
readResponse( bb );
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/ErrorResponse.java Wed Dec 6 05:17:42 2006
@@ -55,7 +55,8 @@
public ErrorResponse()
{
}
-
+
+
/**
* Default constructor
* @param requestID The requestID of the response
@@ -145,27 +146,39 @@
}
}
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public int getRequestID() {
- return requestID;
- }
-
- public void setRequestID(int requestID) {
- this.requestID = requestID;
- }
-
- public ErrorResponseType getType() {
- return type;
- }
-
- public void setType(ErrorResponseType type) {
- this.type = type;
- }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+
+ public int getRequestID()
+ {
+ return requestID;
+ }
+
+
+ public void setRequestID( int requestID )
+ {
+ this.requestID = requestID;
+ }
+
+
+ public ErrorResponseType getType()
+ {
+ return type;
+ }
+
+
+ public void setType( ErrorResponseType type )
+ {
+ this.type = type;
+ }
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/LdapMessageDecorator.java Wed Dec 6 05:17:42 2006
@@ -370,7 +370,7 @@
{
return instance.getUnBindRequest();
}
-
+
/* (non-Javadoc)
* @see org.apache.directory.shared.ldap.codec.LdapMessage#setMessageId(int)
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/reponse/SearchResponse.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2.reponse;
+
import java.util.ArrayList;
import java.util.List;
@@ -28,23 +29,27 @@
import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+
public class SearchResponse extends LdapResponse
{
- private List<SearchResultEntry> searchResultEntryList;
- private List<SearchResultReference> searchResultReferenceList;
- private SearchResultDone searchResultDone;
-
- public SearchResponse()
- {
- searchResultEntryList = new ArrayList<SearchResultEntry>();
- searchResultReferenceList = new ArrayList<SearchResultReference>();
- }
-
- public boolean addSearchResultEntry(SearchResultEntry searchResultEntry)
+ private List<SearchResultEntry> searchResultEntryList;
+ private List<SearchResultReference> searchResultReferenceList;
+ private SearchResultDone searchResultDone;
+
+
+ public SearchResponse()
+ {
+ searchResultEntryList = new ArrayList<SearchResultEntry>();
+ searchResultReferenceList = new ArrayList<SearchResultReference>();
+ }
+
+
+ public boolean addSearchResultEntry( SearchResultEntry searchResultEntry )
{
return searchResultEntryList.add( searchResultEntry );
}
-
+
+
public SearchResultEntry getCurrentSearchResultEntry()
{
if ( searchResultEntryList.size() > 0 )
@@ -56,31 +61,41 @@
return null;
}
}
-
- public boolean addSearchResultReference(SearchResultReference searchResultReference)
+
+
+ public boolean addSearchResultReference( SearchResultReference searchResultReference )
{
return searchResultReferenceList.add( searchResultReference );
}
-
+
+
public SearchResultReference getCurrentSearchResultReference()
{
return searchResultReferenceList.get( searchResultReferenceList.size() - 1 );
}
- public SearchResultDone getSearchResultDone() {
- return searchResultDone;
- }
-
- public void setSearchResultDone(SearchResultDone searchResultDone) {
- this.searchResultDone = searchResultDone;
- }
-
- public List<SearchResultEntry> getSearchResultEntryList() {
- return searchResultEntryList;
- }
-
- public List<SearchResultReference> getSearchResultReferenceList() {
- return searchResultReferenceList;
- }
+
+ public SearchResultDone getSearchResultDone()
+ {
+ return searchResultDone;
+ }
+
+
+ public void setSearchResultDone( SearchResultDone searchResultDone )
+ {
+ this.searchResultDone = searchResultDone;
+ }
+
+
+ public List<SearchResultEntry> getSearchResultEntryList()
+ {
+ return searchResultEntryList;
+ }
+
+
+ public List<SearchResultReference> getSearchResultReferenceList()
+ {
+ return searchResultReferenceList;
+ }
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractResponseTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractResponseTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractResponseTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractResponseTest.java Wed Dec 6 05:17:42 2006
@@ -20,11 +20,13 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import junit.framework.TestCase;
import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2ResponseParser;
import org.xmlpull.v1.XmlPullParserException;
+
public class AbstractResponseTest extends TestCase
{
public void testParsingFail( Class testClass, String filename )
@@ -32,14 +34,14 @@
try
{
Dsmlv2ResponseParser parser = new Dsmlv2ResponseParser();
-
+
parser.setInput( testClass.getResource( filename ).getFile() );
-
- parser.parse( );
+
+ parser.parse();
}
catch ( XmlPullParserException e )
{
- assertTrue(e.getMessage(), true );
+ assertTrue( e.getMessage(), true );
return;
}
catch ( Exception e )
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AbstractTest.java Wed Dec 6 05:17:42 2006
@@ -20,11 +20,13 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import junit.framework.TestCase;
import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Parser;
import org.xmlpull.v1.XmlPullParserException;
+
/**
* This is the Abstract TestCase that each test should extend.
*/
@@ -40,14 +42,14 @@
try
{
Dsmlv2Parser parser = new Dsmlv2Parser();
-
+
parser.setInputFile( testClass.getResource( filename ).getFile() );
-
- parser.parse( );
+
+ parser.parse();
}
catch ( XmlPullParserException e )
{
- assertTrue(e.getMessage(), true );
+ assertTrue( e.getMessage(), true );
return;
}
catch ( Exception e )
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AllTests.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AllTests.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AllTests.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/AllTests.java Wed Dec 6 05:17:42 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.dsmlv2;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -46,6 +47,7 @@
import org.apache.directory.ldapstudio.dsmlv2.searchResponse.searchResultDone.SearchResultDoneTest;
import org.apache.directory.ldapstudio.dsmlv2.searchResponse.searchResultEntry.SearchResultEntryTest;
import org.apache.directory.ldapstudio.dsmlv2.searchResponse.searchResultReference.SearchResultReferenceTest;
+
/**
* This is the complete Test Suite for DSMLv2 Parser (Request and Response)
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/abandonRequest/AbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/abandonRequest/AbandonRequestTest.java?view=diff&rev=483066&r1=483065&r2=483066
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/abandonRequest/AbandonRequestTest.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/test/java/org/apache/directory/ldapstudio/dsmlv2/abandonRequest/AbandonRequestTest.java Wed Dec 6 05:17:42 2006
@@ -20,17 +20,19 @@
package org.apache.directory.ldapstudio.dsmlv2.abandonRequest;
+
import org.apache.directory.ldapstudio.dsmlv2.AbstractTest;
import org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Parser;
import org.apache.directory.shared.ldap.codec.Control;
import org.apache.directory.shared.ldap.codec.abandon.AbandonRequest;
import org.apache.directory.shared.ldap.util.StringTools;
+
/**
* Tests for the Abandon Request parsing
*/
public class AbandonRequestTest extends AbstractTest
-{
+{
/**
* Test parsing of a request without the abandonID attribute
*/
@@ -38,7 +40,8 @@
{
testParsingFail( AbandonRequestTest.class, "request_without_abandonID_attribute.xml" );
}
-
+
+
/**
* Test parsing of a request with the abandonID attribute
*/
@@ -48,8 +51,9 @@
try
{
parser = new Dsmlv2Parser();
-
- parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_abandonID_attribute.xml" ).getFile() );
+
+ parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_abandonID_attribute.xml" )
+ .getFile() );
parser.parse();
}
@@ -57,12 +61,13 @@
{
fail( e.getMessage() );
}
-
+
AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
-
- assertEquals(123, abandonRequest.getAbandonedMessageId() );
+
+ assertEquals( 123, abandonRequest.getAbandonedMessageId() );
}
-
+
+
/**
* Test parsing of a request with the (optional) requestID attribute
*/
@@ -72,117 +77,157 @@
try
{
parser = new Dsmlv2Parser();
-
- parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).getFile() );
-
+
+ parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_requestID_attribute.xml" )
+ .getFile() );
+
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
-
+
AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
-
+
assertEquals( 456, abandonRequest.getMessageId() );
}
-
+
+
/**
* Test parsing of a request with a (optional) Control element
*/
public void testRequestWith1Control()
{
Dsmlv2Parser parser = null;
-
+
try
{
parser = new Dsmlv2Parser();
-
+
parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_1_control.xml" ).getFile() );
-
+
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
-
+
AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
-
+
assertEquals( 1, abandonRequest.getControls().size() );
-
+
Control control = abandonRequest.getCurrentControl();
-
+
assertTrue( control.getCriticality() );
-
+
assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
-
+
assertEquals( "Some text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
}
-
+
+
+ /**
+ * Test parsing of a request with a (optional) Control element with empty value
+ */
+ public void testRequestWith1ControlEmptyValue()
+ {
+ Dsmlv2Parser parser = null;
+
+ try
+ {
+ parser = new Dsmlv2Parser();
+
+ parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_1_control_empty_value.xml" )
+ .getFile() );
+
+ parser.parse();
+ }
+ catch ( Exception e )
+ {
+ fail( e.getMessage() );
+ }
+
+ AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
+
+ assertEquals( 1, abandonRequest.getControls().size() );
+
+ Control control = abandonRequest.getCurrentControl();
+
+ assertTrue( control.getCriticality() );
+
+ assertEquals( "1.2.840.113556.1.4.643", control.getControlType() );
+
+ assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
+ }
+
+
/**
* Test parsing of a request with 2 (optional) Control elements
*/
public void testRequestWith2Controls()
{
Dsmlv2Parser parser = null;
-
+
try
{
parser = new Dsmlv2Parser();
-
+
parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_2_controls.xml" ).getFile() );
-
- parser.parse( );
+
+ parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
-
+
AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
-
+
assertEquals( 2, abandonRequest.getControls().size() );
-
+
Control control = abandonRequest.getCurrentControl();
-
+
assertFalse( control.getCriticality() );
-
+
assertEquals( "1.2.840.113556.1.4.789", control.getControlType() );
-
+
assertEquals( "Some other text", StringTools.utf8ToString( ( byte[] ) control.getControlValue() ) );
}
-
+
+
/**
* Test parsing of a request with 3 (optional) Control elements without value
*/
public void testRequestWith3ControlsWithoutValue()
{
Dsmlv2Parser parser = null;
-
+
try
{
parser = new Dsmlv2Parser();
-
- parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_3_controls_without_value.xml" ).getFile() );
-
+
+ parser.setInputFile( AbandonRequestTest.class.getResource( "request_with_3_controls_without_value.xml" )
+ .getFile() );
+
parser.parse();
}
catch ( Exception e )
{
fail( e.getMessage() );
}
-
+
AbandonRequest abandonRequest = ( AbandonRequest ) parser.getBatchRequest().getCurrentRequest();
-
+
assertEquals( 3, abandonRequest.getControls().size() );
-
+
Control control = abandonRequest.getCurrentControl();
-
+
assertTrue( control.getCriticality() );
-
+
assertEquals( "1.2.840.113556.1.4.456", control.getControlType() );
-
+
assertEquals( StringTools.EMPTY_BYTES, control.getControlValue() );
}
}