in dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/Dsmlv2Grammar.java [1026:1187]
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
SearchRequestDsml searchRequest = new SearchRequestDsml( codec, new SearchRequestImpl() );
container.getBatchRequest().addRequest( searchRequest );
XmlPullParser xpp = container.getParser();
// Checking and adding the request's attributes
String attributeValue;
// requestID
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.REQUEST_ID );
if ( attributeValue != null )
{
searchRequest.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
}
else
{
if ( ParserUtils.isRequestIdNeeded( container ) )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03000_REQUEST_ID_REQUIRED ), xpp, null );
}
}
// dn
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.DN );
if ( attributeValue != null )
{
try
{
searchRequest.setBase( new Dn( attributeValue ) );
}
catch ( LdapInvalidDnException lide )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03039_PARSING_ERROR, lide.getMessage() ), xpp, lide );
}
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03001_DN_ATTRIBUTE_REQUIRED ), xpp, null );
}
// scope
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.SCOPE );
if ( attributeValue != null )
{
if ( DsmlLiterals.BASE_OBJECT.equals( attributeValue ) )
{
searchRequest.setScope( SearchScope.OBJECT );
}
else if ( DsmlLiterals.SINGLE_LEVEL.equals( attributeValue ) )
{
searchRequest.setScope( SearchScope.ONELEVEL );
}
else if ( DsmlLiterals.WHOLE_SUBTREE.equals( attributeValue ) )
{
searchRequest.setScope( SearchScope.SUBTREE );
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03026_UNKNOWN_SCOPE ), xpp, null );
}
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03027_SCOPE_ATTRIBUTE_REQUIRED ), xpp, null );
}
// derefAliases
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.DEREF_ALIASES );
if ( attributeValue != null )
{
if ( DsmlLiterals.NEVER_DEREF_ALIASES.equals( attributeValue ) )
{
searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
}
else if ( DsmlLiterals.DEREF_IN_SEARCHING.equals( attributeValue ) )
{
searchRequest.setDerefAliases( AliasDerefMode.DEREF_IN_SEARCHING );
}
else if ( DsmlLiterals.DEREF_FINDING_BASE_OBJ.equals( attributeValue ) )
{
searchRequest.setDerefAliases( AliasDerefMode.DEREF_FINDING_BASE_OBJ );
}
else if ( DsmlLiterals.DEREF_ALWAYS.equals( attributeValue ) )
{
searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03028_UNKNOWN_DEREFALIAS_VALUE ), xpp, null );
}
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03029_DEREFALIA_ATTRIBUTE_REQUIRED ), xpp, null );
}
// sizeLimit
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.SIZE_LIMIT );
if ( attributeValue != null )
{
try
{
searchRequest.setSizeLimit( Long.parseLong( attributeValue ) );
}
catch ( NumberFormatException nfe )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03030_SIZE_LIMIT_NOT_INTEGER ), xpp, nfe );
}
}
else
{
searchRequest.setSizeLimit( 0L );
}
// timeLimit
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.TIME_LIMIT );
if ( attributeValue != null )
{
try
{
searchRequest.setTimeLimit( Integer.parseInt( attributeValue ) );
}
catch ( NumberFormatException nfe )
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03031_TIME_LIMIT_NOT_INTEGER ), xpp, nfe );
}
}
else
{
searchRequest.setTimeLimit( 0 );
}
// typesOnly
attributeValue = xpp.getAttributeValue( Strings.EMPTY_STRING, DsmlLiterals.TYPES_ONLY );
if ( attributeValue != null )
{
if ( ( attributeValue.equals( DsmlLiterals.TRUE ) ) || ( "1".equals( attributeValue ) ) )
{
searchRequest.setTypesOnly( true );
}
else if ( ( attributeValue.equals( DsmlLiterals.FALSE ) ) || ( "0".equals( attributeValue ) ) )
{
searchRequest.setTypesOnly( false );
}
else
{
throw new XmlPullParserException( I18n.err( I18n.ERR_03032_TYPES_ONLY_NOT_BOOLEAN ), xpp, null );
}
}
else
{
searchRequest.setTypesOnly( false );
}
}