001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020
021 package org.apache.directory.shared.dsmlv2.reponse;
022
023
024 import java.io.IOException;
025 import java.lang.reflect.Array;
026 import java.util.HashMap;
027 import java.util.HashSet;
028 import java.util.Set;
029
030 import org.apache.directory.shared.asn1.codec.DecoderException;
031 import org.apache.directory.shared.asn1.primitives.OID;
032 import org.apache.directory.shared.dsmlv2.AbstractGrammar;
033 import org.apache.directory.shared.dsmlv2.Dsmlv2Container;
034 import org.apache.directory.shared.dsmlv2.Dsmlv2StatesEnum;
035 import org.apache.directory.shared.dsmlv2.GrammarAction;
036 import org.apache.directory.shared.dsmlv2.GrammarTransition;
037 import org.apache.directory.shared.dsmlv2.IGrammar;
038 import org.apache.directory.shared.dsmlv2.ParserUtils;
039 import org.apache.directory.shared.dsmlv2.Tag;
040 import org.apache.directory.shared.dsmlv2.reponse.ErrorResponse.ErrorResponseType;
041 import org.apache.directory.shared.i18n.I18n;
042 import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
043 import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
044 import org.apache.directory.shared.ldap.codec.LdapResultCodec;
045 import org.apache.directory.shared.ldap.codec.add.AddResponseCodec;
046 import org.apache.directory.shared.ldap.codec.bind.BindResponseCodec;
047 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
048 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
049 import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
050 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
051 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
052 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
053 import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
054 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
055 import org.apache.directory.shared.ldap.codec.search.SearchResultReferenceCodec;
056 import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
057 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
058 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
059 import org.apache.directory.shared.ldap.message.control.Control;
060 import org.apache.directory.shared.ldap.name.DN;
061 import org.apache.directory.shared.ldap.util.Base64;
062 import org.apache.directory.shared.ldap.util.LdapURL;
063 import org.xmlpull.v1.XmlPullParser;
064 import org.xmlpull.v1.XmlPullParserException;
065
066
067 /**
068 * This Class represents the DSMLv2 Response Grammar
069 *
070 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
071 * @version $Rev$, $Date$
072 */
073 public class Dsmlv2ResponseGrammar extends AbstractGrammar implements IGrammar
074 {
075 /** The instance of grammar. Dsmlv2ResponseGrammar is a singleton */
076 private static Dsmlv2ResponseGrammar instance = new Dsmlv2ResponseGrammar();
077
078 // Initializing DESCR_TAGS
079 private static Set<String> DSMLV2_DESCR_TAGS = null;
080 static
081 {
082 DSMLV2_DESCR_TAGS = new HashSet<String>();
083 DSMLV2_DESCR_TAGS.add( "success" );
084 DSMLV2_DESCR_TAGS.add( "operationsError" );
085 DSMLV2_DESCR_TAGS.add( "protocolError" );
086 DSMLV2_DESCR_TAGS.add( "timeLimitExceeded" );
087 DSMLV2_DESCR_TAGS.add( "sizeLimitExceeded" );
088 DSMLV2_DESCR_TAGS.add( "compareFalse" );
089 DSMLV2_DESCR_TAGS.add( "compareTrue" );
090 DSMLV2_DESCR_TAGS.add( "authMethodNotSupported" );
091 DSMLV2_DESCR_TAGS.add( "strongAuthRequired" );
092 DSMLV2_DESCR_TAGS.add( "referral" );
093 DSMLV2_DESCR_TAGS.add( "adminLimitExceeded" );
094 DSMLV2_DESCR_TAGS.add( "unavailableCriticalExtension" );
095 DSMLV2_DESCR_TAGS.add( "confidentialityRequired" );
096 DSMLV2_DESCR_TAGS.add( "saslBindInProgress" );
097 DSMLV2_DESCR_TAGS.add( "noSuchAttribute" );
098 DSMLV2_DESCR_TAGS.add( "undefinedAttributeType" );
099 DSMLV2_DESCR_TAGS.add( "inappropriateMatching" );
100 DSMLV2_DESCR_TAGS.add( "constraintViolation" );
101 DSMLV2_DESCR_TAGS.add( "attributeOrValueExists" );
102 DSMLV2_DESCR_TAGS.add( "invalidAttributeSyntax" );
103 DSMLV2_DESCR_TAGS.add( "noSuchObject" );
104 DSMLV2_DESCR_TAGS.add( "aliasProblem" );
105 DSMLV2_DESCR_TAGS.add( "invalidDNSyntax" );
106 DSMLV2_DESCR_TAGS.add( "aliasDereferencingProblem" );
107 DSMLV2_DESCR_TAGS.add( "inappropriateAuthentication" );
108 DSMLV2_DESCR_TAGS.add( "invalidCredentials" );
109 DSMLV2_DESCR_TAGS.add( "insufficientAccessRights" );
110 DSMLV2_DESCR_TAGS.add( "busy" );
111 DSMLV2_DESCR_TAGS.add( "unavailable" );
112 DSMLV2_DESCR_TAGS.add( "unwillingToPerform" );
113 DSMLV2_DESCR_TAGS.add( "loopDetect" );
114 DSMLV2_DESCR_TAGS.add( "namingViolation" );
115 DSMLV2_DESCR_TAGS.add( "objectClassViolation" );
116 DSMLV2_DESCR_TAGS.add( "notAllowedOnNonLeaf" );
117 DSMLV2_DESCR_TAGS.add( "notAllowedOnRDN" );
118 DSMLV2_DESCR_TAGS.add( "entryAlreadyExists" );
119 DSMLV2_DESCR_TAGS.add( "objectClassModsProhibited" );
120 DSMLV2_DESCR_TAGS.add( "affectMultipleDSAs" );
121 DSMLV2_DESCR_TAGS.add( "other" );
122 }
123
124
125 @SuppressWarnings("unchecked")
126 private Dsmlv2ResponseGrammar()
127 {
128 name = Dsmlv2ResponseGrammar.class.getName();
129 statesEnum = Dsmlv2StatesEnum.getInstance();
130
131 // Create the transitions table
132 super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 300 );; // TODO Change this value
133
134 //====================================================
135 // Transitions concerning : BATCH RESPONSE
136 //====================================================
137 super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE] = new HashMap<Tag, GrammarTransition>();
138
139 // ** OPEN BATCH Reponse **
140 // State: [INIT_GRAMMAR_STATE] - Tag: <batchResponse>
141 super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE].put( new Tag( "batchResponse", Tag.START ),
142 new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
143 batchResponseCreation ) );
144
145 //====================================================
146 // Transitions concerning : BATCH RESPONSE LOOP
147 //====================================================
148 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP] = new HashMap<Tag, GrammarTransition>();
149
150 // State: [BATCH_RESPONSE_LOOP] - Tag: <addResponse>
151 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "addResponse", Tag.START ),
152 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
153 addResponseCreation ) );
154
155 // State: [BATCH_RESPONSE_LOOP] - Tag: <authResponse>
156 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "authResponse", Tag.START ),
157 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
158 authResponseCreation ) );
159
160 // State: [BATCH_RESPONSE_LOOP] - Tag: <compareResponse>
161 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "compareResponse", Tag.START ),
162 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
163 compareResponseCreation ) );
164
165 // State: [BATCH_RESPONSE_LOOP] - Tag: <delResponse>
166 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "delResponse", Tag.START ),
167 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
168 delResponseCreation ) );
169
170 // State: [BATCH_RESPONSE_LOOP] - Tag: <modifyResponse>
171 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "modifyResponse", Tag.START ),
172 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
173 modifyResponseCreation ) );
174
175 // State: [BATCH_RESPONSE_LOOP] - Tag: <modDNResponse>
176 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "modDNResponse", Tag.START ),
177 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
178 modDNResponseCreation ) );
179
180 // State: [BATCH_RESPONSE_LOOP] - Tag: <extendedResponse>
181 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "extendedResponse", Tag.START ),
182 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.EXTENDED_RESPONSE,
183 extendedResponseCreation ) );
184
185 // State: [BATCH_RESPONSE_LOOP] - Tag: <errorResponse>
186 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "errorResponse", Tag.START ),
187 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.ERROR_RESPONSE,
188 errorResponseCreation ) );
189
190 // State: [BATCH_RESPONSE_LOOP] - Tag: <searchReponse>
191 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "searchResponse", Tag.START ),
192 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.SEARCH_RESPONSE,
193 searchResponseCreation ) );
194
195 // State: [BATCH_RESPONSE_LOOP] - Tag: </batchResponse>
196 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP].put( new Tag( "batchResponse", Tag.END ),
197 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.GRAMMAR_END, null ) );
198
199 //====================================================
200 // Transitions concerning : ERROR RESPONSE
201 //====================================================
202 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE] = new HashMap<Tag, GrammarTransition>();
203 super.transitions[Dsmlv2StatesEnum.MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
204 super.transitions[Dsmlv2StatesEnum.DETAIL_START] = new HashMap<Tag, GrammarTransition>();
205 super.transitions[Dsmlv2StatesEnum.DETAIL_END] = new HashMap<Tag, GrammarTransition>();
206
207 // State: [ERROR_RESPONSE] - Tag: <message>
208 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE].put( new Tag( "message", Tag.START ), new GrammarTransition(
209 Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.MESSAGE_END, errorResponseAddMessage ) );
210
211 // State: [ERROR_RESPONSE] - Tag: <detail>
212 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE].put( new Tag( "detail", Tag.START ), new GrammarTransition(
213 Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.DETAIL_START, errorResponseAddDetail ) );
214
215 // State: [MESSAGE_END] - Tag: </errorResponse>
216 super.transitions[Dsmlv2StatesEnum.MESSAGE_END].put( new Tag( "errorResponse", Tag.END ),
217 new GrammarTransition( Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
218
219 // State: [MESSAGE_END] - Tag: <detail>
220 super.transitions[Dsmlv2StatesEnum.MESSAGE_END].put( new Tag( "detail", Tag.START ), new GrammarTransition(
221 Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.DETAIL_START, errorResponseAddDetail ) );
222
223 // State: [DETAIL_START] - Tag: </detail>
224 super.transitions[Dsmlv2StatesEnum.DETAIL_START].put( new Tag( "detail", Tag.END ), new GrammarTransition(
225 Dsmlv2StatesEnum.DETAIL_START, Dsmlv2StatesEnum.DETAIL_END, null ) );
226
227 // State: [DETAIL_END] - Tag: <detail>
228 super.transitions[Dsmlv2StatesEnum.DETAIL_END].put( new Tag( "detail", Tag.END ), new GrammarTransition(
229 Dsmlv2StatesEnum.DETAIL_END, Dsmlv2StatesEnum.DETAIL_END, errorResponseAddDetail ) );
230
231 // State: [ERROR_RESPONSE] - Tag: </errorResponse>
232 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE].put( new Tag( "errorResponse", Tag.END ),
233 new GrammarTransition( Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
234
235 //====================================================
236 // Transitions concerning : EXTENDED RESPONSE
237 //====================================================
238 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE] = new HashMap<Tag, GrammarTransition>();
239 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
240 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
241 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
242 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START] = new HashMap<Tag, GrammarTransition>();
243 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END] = new HashMap<Tag, GrammarTransition>();
244 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
245 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END] = new HashMap<Tag, GrammarTransition>();
246 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END] = new HashMap<Tag, GrammarTransition>();
247 super.transitions[Dsmlv2StatesEnum.RESPONSE_END] = new HashMap<Tag, GrammarTransition>();
248
249 // State: [EXTENDED_RESPONSE] - Tag: <control>
250 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE].put( new Tag( "control", Tag.START ),
251 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE,
252 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) );
253
254 // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: <controlValue>
255 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START].put( new Tag( "controlValue", Tag.START ),
256 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START,
257 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
258
259 // State: [EXTENDED_RESPONSE_CONTROL_VALUE_END] - Tag: </control>
260 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
261 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END,
262 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) );
263
264 // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: </control>
265 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START].put( new Tag( "control", Tag.END ),
266 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START,
267 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) );
268
269 // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <control>
270 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END].put( new Tag( "control", Tag.START ),
271 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END,
272 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) );
273
274 // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <resultCode>
275 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END].put( new Tag( "resultCode", Tag.START ),
276 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END,
277 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) );
278
279 // State: [EXTENDED_RESPONSE] - Tag: <resultCode>
280 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE].put( new Tag( "resultCode", Tag.START ),
281 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE,
282 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) );
283
284 // State: [EXTENDED_RESPONSE_RESULT_CODE_START] - Tag: </resultCode>
285 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START].put( new Tag( "resultCode", Tag.END ),
286 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START,
287 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, null ) );
288
289 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <errorMessage>
290 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put(
291 new Tag( "errorMessage", Tag.START ), new GrammarTransition(
292 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
293 Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, extendedResponseAddErrorMessage ) );
294
295 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <referral>
296 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put( new Tag( "referral", Tag.START ),
297 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END,
298 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
299
300 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <responseName>
301 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put(
302 new Tag( "responseName", Tag.START ), new GrammarTransition(
303 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
304 extendedResponseAddResponseName ) );
305
306 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <response>
307 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put( new Tag( "response", Tag.START ),
308 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_END,
309 extendedResponseAddResponse ) );
310
311 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: </extendedResponse>
312 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END].put(
313 new Tag( "extendedResponse", Tag.END ), new GrammarTransition(
314 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
315
316 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <referral>
317 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "referral", Tag.START ),
318 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
319 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
320
321 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <responseName>
322 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put(
323 new Tag( "responseName", Tag.START ), new GrammarTransition(
324 Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END,
325 extendedResponseAddResponseName ) );
326
327 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <response>
328 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "response", Tag.START ),
329 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
330 Dsmlv2StatesEnum.RESPONSE_END, extendedResponseAddResponse ) );
331
332 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: </extendedResponse>
333 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END].put( new Tag( "extendedResponse",
334 Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END,
335 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
336
337 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <referral>
338 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "referral", Tag.START ),
339 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
340 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) );
341
342 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <responseName>
343 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "responseName", Tag.START ),
344 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
345 Dsmlv2StatesEnum.RESPONSE_NAME_END, extendedResponseAddResponseName ) );
346
347 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <reponse>
348 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "reponse", Tag.START ),
349 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_END,
350 extendedResponseAddResponse ) );
351
352 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: </extendedResponse>
353 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END].put( new Tag( "extendedResponse", Tag.END ),
354 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END,
355 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
356
357 // State: [RESPONSE_NAME_END] - Tag: <response>
358 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END].put( new Tag( "response", Tag.START ),
359 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.RESPONSE_END,
360 extendedResponseAddResponse ) );
361
362 // State: [RESPONSE_NAME_END] - Tag: </extendedResponse>
363 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END].put( new Tag( "extendedResponse", Tag.END ),
364 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
365
366 // State: [RESPONSE_END] - Tag: </extendedResponse>
367 super.transitions[Dsmlv2StatesEnum.RESPONSE_END].put( new Tag( "extendedResponse", Tag.END ),
368 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
369
370 //====================================================
371 // Transitions concerning : LDAP RESULT
372 //====================================================
373 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT] = new HashMap<Tag, GrammarTransition>();
374 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
375 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
376 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
377 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START] = new HashMap<Tag, GrammarTransition>();
378 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END] = new HashMap<Tag, GrammarTransition>();
379 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END] = new HashMap<Tag, GrammarTransition>();
380 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END] = new HashMap<Tag, GrammarTransition>();
381 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END] = new HashMap<Tag, GrammarTransition>();
382
383 // State: [LDAP_RESULT] - Tag: <control>
384 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT].put( new Tag( "control", Tag.START ), new GrammarTransition(
385 Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) );
386
387 // State: [LDAP_RESULT] - Tag: <resultCode>
388 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT].put( new Tag( "resultCode", Tag.START ), new GrammarTransition(
389 Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) );
390
391 // State: [LDAP_RESULT_CONTROL_START] - Tag: <controlValue>
392 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START].put( new Tag( "controlValue", Tag.START ),
393 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START,
394 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, ldapResultControlValueCreation ) );
395
396 // State: [LDAP_RESULT_CONTROL_VALUE_END] - Tag: </control>
397 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
398 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END,
399 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) );
400
401 // State: [LDAP_RESULT_CONTROL_START] - Tag: </control>
402 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START].put( new Tag( "control", Tag.END ),
403 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START,
404 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) );
405
406 // State: [LDAP_RESULT_CONTROL_END] - Tag: <control>
407 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END].put( new Tag( "control", Tag.START ),
408 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END,
409 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) );
410
411 // State: [LDAP_RESULT_CONTROL_END] - Tag: <resultCode>
412 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END].put( new Tag( "resultCode", Tag.START ),
413 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END,
414 Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) );
415
416 // State: [LDAP_RESULT_RESULT_CODE_START] - Tag: </resultCode>
417 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START].put( new Tag( "resultCode", Tag.END ),
418 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START,
419 Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, null ) );
420
421 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <errorMessage>
422 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "errorMessage", Tag.START ),
423 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
424 Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, ldapResultAddErrorMessage ) );
425
426 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <referral>
427 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "referral", Tag.START ),
428 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
429 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
430
431 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </addResponse>
432 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "addResponse", Tag.END ),
433 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
434 null ) );
435
436 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </authResponse>
437 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "authResponse", Tag.END ),
438 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
439 null ) );
440
441 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </compareResponse>
442 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "compareResponse", Tag.END ),
443 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
444 null ) );
445
446 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </delResponse>
447 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "delResponse", Tag.END ),
448 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
449 null ) );
450
451 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modifyResponse>
452 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "modifyResponse", Tag.END ),
453 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
454 null ) );
455
456 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modDNResponse>
457 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "modDNResponse", Tag.END ),
458 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
459 null ) );
460
461 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </searchResultDone>
462 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END].put( new Tag( "searchResultDone", Tag.END ),
463 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END,
464 Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) );
465
466 // State: [SEARCH_RESULT_DONE_END] - Tag: </searchResponse>
467 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END]
468 .put( new Tag( "searchResponse", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END,
469 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
470
471 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: <referral>
472 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "referral", Tag.START ),
473 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
474 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
475
476 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </addResponse>
477 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "addResponse", Tag.END ),
478 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
479 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
480
481 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </authResponse>
482 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "authResponse", Tag.END ),
483 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
484 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
485
486 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </compareResponse>
487 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "compareResponse", Tag.END ),
488 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
489 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
490
491 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </delResponse>
492 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "delResponse", Tag.END ),
493 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
494 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
495
496 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modifyResponse>
497 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "modifyResponse", Tag.END ),
498 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
499 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
500
501 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modDNResponse>
502 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "modDNResponse", Tag.END ),
503 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
504 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) );
505
506 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </searchResultDone>
507 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END].put( new Tag( "searchResultDone", Tag.END ),
508 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END,
509 Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) );
510
511 // State: [LDAP_RESULT_REFERRAL_END] - Tag: <referral>
512 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "referral", Tag.START ),
513 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END,
514 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) );
515
516 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </addResponse>
517 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "addResponse", Tag.END ),
518 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
519 null ) );
520
521 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </authResponse>
522 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "authResponse", Tag.END ),
523 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
524 null ) );
525
526 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </compareResponse>
527 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "compareResponse", Tag.END ),
528 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
529 null ) );
530
531 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </delResponse>
532 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "delResponse", Tag.END ),
533 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
534 null ) );
535
536 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modifyResponse>
537 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "modifyResponse", Tag.END ),
538 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
539 null ) );
540
541 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modDNResponse>
542 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "modDNResponse", Tag.END ),
543 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP,
544 null ) );
545
546 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </searchResultDone>
547 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END].put( new Tag( "searchResultDone", Tag.END ),
548 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END,
549 null ) );
550
551 //====================================================
552 // Transitions concerning : SEARCH RESPONSE
553 //====================================================
554 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE] = new HashMap<Tag, GrammarTransition>();
555
556 // State: [SEARCH_REPONSE] - Tag: <searchResultEntry>
557 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE].put( new Tag( "searchResultEntry", Tag.START ),
558 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
559 searchResultEntryCreation ) );
560
561 // State: [SEARCH_REPONSE] - Tag: <searchResultReference>
562 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE].put( new Tag( "searchResultReference", Tag.START ),
563 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
564 searchResultReferenceCreation ) );
565
566 // State: [SEARCH_REPONSE] - Tag: <searchResultDone>
567 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE].put( new Tag( "searchResultDone", Tag.START ),
568 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.LDAP_RESULT,
569 searchResultDoneCreation ) );
570
571 //====================================================
572 // Transitions concerning : SEARCH RESULT ENTRY
573 //====================================================
574 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY] = new HashMap<Tag, GrammarTransition>();
575 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
576 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
577 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
578 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START] = new HashMap<Tag, GrammarTransition>();
579 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END] = new HashMap<Tag, GrammarTransition>();
580 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END] = new HashMap<Tag, GrammarTransition>();
581
582 // State: [SEARCH_RESULT_ENTRY] - Tag: <control>
583 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY].put( new Tag( "control", Tag.START ),
584 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
585 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) );
586
587 // State: [SEARCH_RESULT_ENTRY] - Tag: <attr>
588 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY].put( new Tag( "attr", Tag.START ),
589 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
590 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) );
591
592 // State: [SEARCH_RESULT_ENTRY] - Tag: </searchResultEntry>
593 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY].put( new Tag( "searchResultEntry", Tag.END ),
594 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP,
595 null ) );
596
597 // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: <controlValue>
598 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START].put(
599 new Tag( "controlValue", Tag.START ), new GrammarTransition(
600 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START,
601 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, searchResultEntryControlValueCreation ) );
602
603 // State: [SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] - Tag: </control>
604 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END].put( new Tag( "control", Tag.END ),
605 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END,
606 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) );
607
608 // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: </control>
609 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START].put( new Tag( "control", Tag.END ),
610 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START,
611 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) );
612
613 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <control>
614 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END].put( new Tag( "control", Tag.START ),
615 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END,
616 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) );
617
618 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: </searchResultEntry>
619 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END].put(
620 new Tag( "searchResultEntry", Tag.END ), new GrammarTransition(
621 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) );
622
623 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <attr>
624 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END].put( new Tag( "attr", Tag.START ),
625 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END,
626 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, null ) );
627
628 // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: </attr>
629 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START].put( new Tag( "attr", Tag.END ),
630 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START,
631 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) );
632
633 // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: <value>
634 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START].put( new Tag( "value", Tag.START ),
635 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START,
636 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
637
638 // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: <attr>
639 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END].put( new Tag( "attr", Tag.START ),
640 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END,
641 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) );
642
643 // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: </searchResultEntry>
644 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END].put( new Tag( "searchResultEntry", Tag.END ),
645 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END,
646 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) );
647
648 // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: <value>
649 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END].put( new Tag( "value", Tag.START ),
650 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END,
651 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) );
652
653 // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: </attr>
654 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END].put( new Tag( "attr", Tag.END ),
655 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END,
656 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) );
657
658 //====================================================
659 // Transitions concerning : SEARCH RESULT ENTRY LOOP
660 //====================================================
661 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP] = new HashMap<Tag, GrammarTransition>();
662
663 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultEntry>
664 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP].put( new Tag( "searchResultEntry", Tag.START ),
665 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY,
666 searchResultEntryCreation ) );
667
668 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultReference>
669 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP].put(
670 new Tag( "searchResultReference", Tag.START ), new GrammarTransition(
671 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
672 searchResultReferenceCreation ) );
673
674 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultDone>
675 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP].put( new Tag( "searchResultDone", Tag.START ),
676 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
677 searchResultDoneCreation ) );
678
679 //====================================================
680 // Transitions concerning : SEARCH RESULT REFERENCE
681 //====================================================
682 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE] = new HashMap<Tag, GrammarTransition>();
683 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START] = new HashMap<Tag, GrammarTransition>();
684 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END] = new HashMap<Tag, GrammarTransition>();
685 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] = new HashMap<Tag, GrammarTransition>();
686 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END] = new HashMap<Tag, GrammarTransition>();
687
688 // State: [SEARCH_RESULT_REFERENCE] - Tag: <control>
689 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE].put( new Tag( "control", Tag.START ),
690 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
691 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) );
692
693 // State: [SEARCH_RESULT_REFERENCE] - Tag: <ref>
694 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE].put( new Tag( "ref", Tag.START ),
695 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE,
696 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
697
698 // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: <controlValue>
699 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START].put( new Tag( "controlValue",
700 Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START,
701 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, searchResultReferenceControlValueCreation ) );
702
703 // State: [sEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] - Tag: </control>
704 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END].put(
705 new Tag( "control", Tag.END ), new GrammarTransition(
706 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END,
707 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) );
708
709 // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: </control>
710 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START].put( new Tag( "control", Tag.END ),
711 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START,
712 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) );
713
714 // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <control>
715 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END].put( new Tag( "control", Tag.START ),
716 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END,
717 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) );
718
719 // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <ref>
720 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END].put( new Tag( "ref", Tag.START ),
721 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END,
722 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
723
724 // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: <ref>
725 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END].put( new Tag( "ref", Tag.START ),
726 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END,
727 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) );
728
729 // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: </searchResultReference>
730 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END].put( new Tag( "searchResultReference",
731 Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END,
732 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, null ) );
733
734 //==========================================================
735 // Transitions concerning : SEARCH RESULT REFERENCE LOOP
736 //==========================================================
737 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP] = new HashMap<Tag, GrammarTransition>();
738
739 // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultReference>
740 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP].put( new Tag( "searchResultReference",
741 Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP,
742 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, searchResultReferenceCreation ) );
743
744 // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultDone>
745 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP].put( new Tag( "searchResultDone", Tag.START ),
746 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT,
747 searchResultDoneCreation ) );
748 }
749
750 /**
751 * GrammarAction that creates the Batch Response
752 */
753 private final GrammarAction batchResponseCreation = new GrammarAction( "Create Batch Response" )
754 {
755 public void action( Dsmlv2Container container ) throws XmlPullParserException
756 {
757 BatchResponse batchResponse = new BatchResponse();
758
759 container.setBatchResponse( batchResponse );
760
761 XmlPullParser xpp = container.getParser();
762
763 // Checking and adding the batchRequest's attributes
764 String attributeValue;
765 // requestID
766 attributeValue = xpp.getAttributeValue( "", "requestID" );
767 if ( attributeValue != null )
768 {
769 batchResponse.setRequestID( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
770 }
771 }
772 };
773
774 /**
775 * GrammarAction that creates the Add Response
776 */
777 private final GrammarAction addResponseCreation = new GrammarAction( "Create Add Response" )
778 {
779 public void action( Dsmlv2Container container ) throws XmlPullParserException
780 {
781 AddResponseCodec addResponse = new AddResponseCodec();
782
783 container.getBatchResponse().addResponse( addResponse );
784
785 LdapResultCodec ldapResult = new LdapResultCodec();
786
787 addResponse.setLdapResult( ldapResult );
788
789 XmlPullParser xpp = container.getParser();
790
791 // Checking and adding the batchRequest's attributes
792 String attributeValue;
793 // requestID
794 attributeValue = xpp.getAttributeValue( "", "requestID" );
795 if ( attributeValue != null )
796 {
797 addResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
798 }
799 // MatchedDN
800 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
801 if ( attributeValue != null )
802 {
803 try
804 {
805 ldapResult.setMatchedDN( new DN( attributeValue ) );
806 }
807 catch ( LdapInvalidDnException e )
808 {
809 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
810 }
811 }
812 }
813 };
814
815 /**
816 * GrammarAction that creates the Auth Response
817 */
818 private final GrammarAction authResponseCreation = new GrammarAction( "Create Auth Response" )
819 {
820 public void action( Dsmlv2Container container ) throws XmlPullParserException
821 {
822 BindResponseCodec bindResponse = new BindResponseCodec();
823
824 container.getBatchResponse().addResponse( bindResponse );
825
826 LdapResultCodec ldapResult = new LdapResultCodec();
827
828 bindResponse.setLdapResult( ldapResult );
829
830 XmlPullParser xpp = container.getParser();
831
832 // Checking and adding the batchRequest's attributes
833 String attributeValue;
834 // requestID
835 attributeValue = xpp.getAttributeValue( "", "requestID" );
836 if ( attributeValue != null )
837 {
838 bindResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
839
840 }
841 // MatchedDN
842 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
843 if ( attributeValue != null )
844 {
845 try
846 {
847 ldapResult.setMatchedDN( new DN( attributeValue ) );
848 }
849 catch ( LdapInvalidDnException e )
850 {
851 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
852 }
853 }
854 }
855 };
856
857 /**
858 * GrammarAction that creates the Compare Response
859 */
860 private final GrammarAction compareResponseCreation = new GrammarAction( "Create Compare Response" )
861 {
862 public void action( Dsmlv2Container container ) throws XmlPullParserException
863 {
864 CompareResponseCodec compareResponse = new CompareResponseCodec();
865
866 container.getBatchResponse().addResponse( compareResponse );
867
868 LdapResultCodec ldapResult = new LdapResultCodec();
869
870 compareResponse.setLdapResult( ldapResult );
871
872 XmlPullParser xpp = container.getParser();
873
874 // Checking and adding the batchRequest's attributes
875 String attributeValue;
876 // requestID
877 attributeValue = xpp.getAttributeValue( "", "requestID" );
878 if ( attributeValue != null )
879 {
880 compareResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
881 }
882 // MatchedDN
883 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
884 if ( attributeValue != null )
885 {
886 try
887 {
888 ldapResult.setMatchedDN( new DN( attributeValue ) );
889 }
890 catch ( LdapInvalidDnException e )
891 {
892 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
893 }
894 }
895 }
896 };
897
898 /**
899 * GrammarAction that creates the Del Response
900 */
901 private final GrammarAction delResponseCreation = new GrammarAction( "Create Del Response" )
902 {
903 public void action( Dsmlv2Container container ) throws XmlPullParserException
904 {
905 DelResponseCodec delResponse = new DelResponseCodec();
906
907 container.getBatchResponse().addResponse( delResponse );
908
909 LdapResultCodec ldapResult = new LdapResultCodec();
910
911 delResponse.setLdapResult( ldapResult );
912
913 XmlPullParser xpp = container.getParser();
914
915 // Checking and adding the batchRequest's attributes
916 String attributeValue;
917 // requestID
918 attributeValue = xpp.getAttributeValue( "", "requestID" );
919 if ( attributeValue != null )
920 {
921 delResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
922 }
923 // MatchedDN
924 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
925 if ( attributeValue != null )
926 {
927 try
928 {
929 ldapResult.setMatchedDN( new DN( attributeValue ) );
930 }
931 catch ( LdapInvalidDnException e )
932 {
933 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
934 }
935 }
936 }
937 };
938
939 /**
940 * GrammarAction that creates the Modify Response
941 */
942 private final GrammarAction modifyResponseCreation = new GrammarAction( "Create Modify Response" )
943 {
944 public void action( Dsmlv2Container container ) throws XmlPullParserException
945 {
946 ModifyResponseCodec modifyResponse = new ModifyResponseCodec();
947
948 container.getBatchResponse().addResponse( modifyResponse );
949
950 LdapResultCodec ldapResult = new LdapResultCodec();
951
952 modifyResponse.setLdapResult( ldapResult );
953
954 XmlPullParser xpp = container.getParser();
955
956 // Checking and adding the batchRequest's attributes
957 String attributeValue;
958 // requestID
959 attributeValue = xpp.getAttributeValue( "", "requestID" );
960 if ( attributeValue != null )
961 {
962 modifyResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
963 }
964 // MatchedDN
965 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
966 if ( attributeValue != null )
967 {
968 try
969 {
970 ldapResult.setMatchedDN( new DN( attributeValue ) );
971 }
972 catch ( LdapInvalidDnException e )
973 {
974 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
975 }
976 }
977 }
978 };
979
980 /**
981 * GrammarAction that creates the Mod DN Response
982 */
983 private final GrammarAction modDNResponseCreation = new GrammarAction( "Create Mod DN Response" )
984 {
985 public void action( Dsmlv2Container container ) throws XmlPullParserException
986 {
987 ModifyDNResponseCodec modifyDNResponse = new ModifyDNResponseCodec();
988
989 container.getBatchResponse().addResponse( modifyDNResponse );
990
991 LdapResultCodec ldapResult = new LdapResultCodec();
992
993 modifyDNResponse.setLdapResult( ldapResult );
994
995 XmlPullParser xpp = container.getParser();
996
997 // Checking and adding the batchRequest's attributes
998 String attributeValue;
999 // requestID
1000 attributeValue = xpp.getAttributeValue( "", "requestID" );
1001 if ( attributeValue != null )
1002 {
1003 modifyDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1004 }
1005 // MatchedDN
1006 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
1007 if ( attributeValue != null )
1008 {
1009 try
1010 {
1011 ldapResult.setMatchedDN( new DN( attributeValue ) );
1012 }
1013 catch ( LdapInvalidDnException e )
1014 {
1015 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1016 }
1017 }
1018 }
1019 };
1020
1021 /**
1022 * GrammarAction that creates the Extended Response
1023 */
1024 private final GrammarAction extendedResponseCreation = new GrammarAction( "Create Extended Response" )
1025 {
1026 public void action( Dsmlv2Container container ) throws XmlPullParserException
1027 {
1028 ExtendedResponseCodec extendedResponse = new ExtendedResponseCodec();
1029
1030 container.getBatchResponse().addResponse( extendedResponse );
1031
1032 LdapResultCodec ldapResult = new LdapResultCodec();
1033
1034 extendedResponse.setLdapResult( ldapResult );
1035
1036 XmlPullParser xpp = container.getParser();
1037
1038 // Checking and adding the batchRequest's attributes
1039 String attributeValue;
1040 // requestID
1041 attributeValue = xpp.getAttributeValue( "", "requestID" );
1042 if ( attributeValue != null )
1043 {
1044 extendedResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1045 }
1046 // MatchedDN
1047 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
1048 if ( attributeValue != null )
1049 {
1050 try
1051 {
1052 ldapResult.setMatchedDN( new DN( attributeValue ) );
1053 }
1054 catch ( LdapInvalidDnException e )
1055 {
1056 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1057 }
1058 }
1059 }
1060 };
1061
1062 /**
1063 * GrammarAction that creates the Error Response
1064 */
1065 private final GrammarAction errorResponseCreation = new GrammarAction( "Create Error Response" )
1066 {
1067 public void action( Dsmlv2Container container ) throws XmlPullParserException
1068 {
1069 ErrorResponse errorResponse = new ErrorResponse();
1070
1071 container.getBatchResponse().addResponse( errorResponse );
1072
1073 XmlPullParser xpp = container.getParser();
1074
1075 // Checking and adding the batchRequest's attributes
1076 String attributeValue;
1077 // requestID
1078 attributeValue = xpp.getAttributeValue( "", "requestID" );
1079 if ( attributeValue != null )
1080 {
1081 errorResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1082 }
1083 // type
1084 attributeValue = xpp.getAttributeValue( "", "type" );
1085 if ( attributeValue != null )
1086 {
1087 if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.NOT_ATTEMPTED ) ) )
1088 {
1089 errorResponse.setType( ErrorResponseType.NOT_ATTEMPTED );
1090 }
1091 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.COULD_NOT_CONNECT ) ) )
1092 {
1093 errorResponse.setType( ErrorResponseType.COULD_NOT_CONNECT );
1094 }
1095 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.CONNECTION_CLOSED ) ) )
1096 {
1097 errorResponse.setType( ErrorResponseType.CONNECTION_CLOSED );
1098 }
1099 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.MALFORMED_REQUEST ) ) )
1100 {
1101 errorResponse.setType( ErrorResponseType.MALFORMED_REQUEST );
1102 }
1103 else if ( attributeValue
1104 .equals( errorResponse.getTypeDescr( ErrorResponseType.GATEWAY_INTERNAL_ERROR ) ) )
1105 {
1106 errorResponse.setType( ErrorResponseType.GATEWAY_INTERNAL_ERROR );
1107 }
1108 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.AUTHENTICATION_FAILED ) ) )
1109 {
1110 errorResponse.setType( ErrorResponseType.AUTHENTICATION_FAILED );
1111 }
1112 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.UNRESOLVABLE_URI ) ) )
1113 {
1114 errorResponse.setType( ErrorResponseType.UNRESOLVABLE_URI );
1115 }
1116 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.OTHER ) ) )
1117 {
1118 errorResponse.setType( ErrorResponseType.OTHER );
1119 }
1120 else
1121 {
1122 throw new XmlPullParserException( I18n.err( I18n.ERR_03004 ), xpp, null );
1123 }
1124 }
1125 else
1126 {
1127 throw new XmlPullParserException( I18n.err( I18n.ERR_03005 ), xpp, null );
1128 }
1129 }
1130 };
1131
1132 /**
1133 * GrammarAction that adds Message to an Error Response
1134 */
1135 private final GrammarAction errorResponseAddMessage = new GrammarAction( "Add Message to Error Response" )
1136 {
1137 public void action( Dsmlv2Container container ) throws XmlPullParserException
1138 {
1139 ErrorResponse errorResponse = ( ErrorResponse ) container.getBatchResponse().getCurrentResponse();
1140
1141 XmlPullParser xpp = container.getParser();
1142 try
1143 {
1144 String nextText = xpp.nextText();
1145 if ( !nextText.equals( "" ) )
1146 {
1147 errorResponse.setMessage( nextText.trim() );
1148 }
1149 }
1150 catch ( IOException e )
1151 {
1152 throw new XmlPullParserException( e.getMessage(), xpp, null );
1153 }
1154 }
1155 };
1156
1157 /**
1158 * GrammarAction that adds Detail to an Error Response
1159 */
1160 private final GrammarAction errorResponseAddDetail = null; // TODO Look for documentation about this Detail element (the DSML documentation doesn't give enough information)
1161
1162
1163 /**
1164 * Creates a Control parsing the current node and adds it to the given parent
1165 * @param container the DSMLv2Container
1166 * @param parent the parent
1167 * @throws XmlPullParserException
1168 */
1169 private void createAndAddControl( Dsmlv2Container container, LdapMessageCodec parent ) throws XmlPullParserException
1170 {
1171 Control control = null;
1172
1173 XmlPullParser xpp = container.getParser();
1174
1175 // Checking and adding the Control's attributes
1176 String attributeValue;
1177 // TYPE
1178 attributeValue = xpp.getAttributeValue( "", "type" );
1179
1180 if ( attributeValue != null )
1181 {
1182 if ( !OID.isOID( attributeValue ) )
1183 {
1184 throw new XmlPullParserException( I18n.err( I18n.ERR_03006 ), xpp, null );
1185 }
1186
1187 control = new ControlImpl( attributeValue );
1188 parent.addControl( control );
1189 }
1190 else
1191 {
1192 throw new XmlPullParserException( I18n.err( I18n.ERR_03005 ), xpp, null );
1193 }
1194 // CRITICALITY
1195 attributeValue = xpp.getAttributeValue( "", "criticality" );
1196
1197 if ( attributeValue != null )
1198 {
1199 if ( attributeValue.equals( "true" ) )
1200 {
1201 control.setCritical( true );
1202 }
1203 else if ( attributeValue.equals( "false" ) )
1204 {
1205 control.setCritical( false );
1206 }
1207 else
1208 {
1209 throw new XmlPullParserException( I18n.err( I18n.ERR_03007 ), xpp, null );
1210 }
1211 }
1212 }
1213
1214 /**
1215 * GrammarAction that creates a Control for LDAP Result
1216 */
1217 private final GrammarAction ldapResultControlCreation = new GrammarAction( "Create Control for LDAP Result" )
1218 {
1219 public void action( Dsmlv2Container container ) throws XmlPullParserException
1220 {
1221 LdapResponseCodec ldapResponse = container.getBatchResponse().getCurrentResponse();
1222 // Search Response is a special case
1223 if ( ldapResponse instanceof SearchResponse )
1224 {
1225 ldapResponse = ( ( SearchResponse ) ldapResponse ).getSearchResultDone();
1226 }
1227
1228 createAndAddControl( container, ldapResponse );
1229 }
1230 };
1231
1232 /**
1233 * GrammarAction that creates a Control for Search Result Entry
1234 */
1235 private final GrammarAction searchResultEntryControlCreation = new GrammarAction(
1236 "Create Control for Search Result Entry" )
1237 {
1238 public void action( Dsmlv2Container container ) throws XmlPullParserException
1239 {
1240 LdapMessageCodec ldapMessage = ( ( SearchResponse ) container.getBatchResponse().getCurrentResponse() )
1241 .getCurrentSearchResultEntry();
1242 createAndAddControl( container, ldapMessage );
1243 }
1244 };
1245
1246 /**
1247 * GrammarAction that creates a Control for Search Result Entry
1248 */
1249 private final GrammarAction searchResultReferenceControlCreation = new GrammarAction(
1250 "Create Control for Search Result Reference" )
1251 {
1252 public void action( Dsmlv2Container container ) throws XmlPullParserException
1253 {
1254 LdapMessageCodec ldapMessage = ( ( SearchResponse ) container.getBatchResponse().getCurrentResponse() )
1255 .getCurrentSearchResultReference();
1256 createAndAddControl( container, ldapMessage );
1257 }
1258 };
1259
1260
1261 /**
1262 * Creates a Control Value parsing the current node and adds it to the given parent
1263 * @param container the DSMLv2Container
1264 * @param parent the parent
1265 * @throws XmlPullParserException
1266 */
1267 private void createAndAddControlValue( Dsmlv2Container container, LdapMessageCodec parent )
1268 throws XmlPullParserException
1269 {
1270 Control control = parent.getCurrentControl();
1271
1272 XmlPullParser xpp = container.getParser();
1273 try
1274 {
1275 // We have to catch the type Attribute Value before going to the next Text node
1276 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1277
1278 // Getting the value
1279 String nextText = xpp.nextText();
1280
1281 if ( !nextText.equals( "" ) )
1282 {
1283 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1284 {
1285 control.setValue( Base64.decode( nextText.trim().toCharArray() ) );
1286 }
1287 else
1288 {
1289 control.setValue( nextText.trim().getBytes() );
1290 }
1291 }
1292 }
1293 catch ( IOException e )
1294 {
1295 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1296 }
1297 }
1298
1299 /**
1300 * GrammarAction that creates a Control Value for LDAP Result
1301 */
1302 private final GrammarAction ldapResultControlValueCreation = new GrammarAction(
1303 "Add ControlValue to Control for LDAP Result" )
1304 {
1305 public void action( Dsmlv2Container container ) throws XmlPullParserException
1306 {
1307 LdapResponseCodec ldapResponse = container.getBatchResponse().getCurrentResponse();
1308 // Search Response is a special case
1309 if ( ldapResponse instanceof SearchResponse )
1310 {
1311 ldapResponse = ( ( SearchResponse ) ldapResponse ).getSearchResultDone();
1312 }
1313
1314 createAndAddControlValue( container, ldapResponse );
1315 }
1316 };
1317
1318 /**
1319 * GrammarAction that creates a Control Value for Search Result Entry
1320 */
1321 private final GrammarAction searchResultEntryControlValueCreation = new GrammarAction(
1322 "Add ControlValue to Control for Search Result Entry" )
1323 {
1324 public void action( Dsmlv2Container container ) throws XmlPullParserException
1325 {
1326 LdapMessageCodec ldapMessage = ( ( SearchResponse ) container.getBatchResponse().getCurrentResponse() )
1327 .getCurrentSearchResultEntry();
1328 createAndAddControlValue( container, ldapMessage );
1329 }
1330 };
1331
1332 /**
1333 * GrammarAction that creates a Control Value for Search Result Reference
1334 */
1335 private final GrammarAction searchResultReferenceControlValueCreation = new GrammarAction(
1336 "Add ControlValue to Control for Search Result Entry" )
1337 {
1338 public void action( Dsmlv2Container container ) throws XmlPullParserException
1339 {
1340 LdapMessageCodec ldapMessage = ( ( SearchResponse ) container.getBatchResponse().getCurrentResponse() )
1341 .getCurrentSearchResultReference();
1342 createAndAddControlValue( container, ldapMessage );
1343 }
1344 };
1345
1346 /**
1347 * GrammarAction that adds a Result Code to a LDAP Result
1348 */
1349 private final GrammarAction ldapResultAddResultCode = new GrammarAction( "Add ResultCode to LDAP Result" )
1350 {
1351 public void action( Dsmlv2Container container ) throws XmlPullParserException
1352 {
1353 LdapResponseCodec ldapResponse = container.getBatchResponse().getCurrentResponse();
1354
1355 LdapResultCodec ldapResult = null;
1356
1357 // Search Response is a special case
1358 // ResultCode can only occur in a case of Search Result Done in a Search Response
1359 if ( ldapResponse instanceof SearchResponse )
1360 {
1361 SearchResponse searchResponse = ( SearchResponse ) ldapResponse;
1362 ldapResult = searchResponse.getSearchResultDone().getLdapResult();
1363 }
1364 else
1365 {
1366 ldapResult = ldapResponse.getLdapResult();
1367 }
1368
1369 XmlPullParser xpp = container.getParser();
1370
1371 // Checking and adding the request's attributes
1372 String attributeValue;
1373 // code
1374 attributeValue = xpp.getAttributeValue( "", "code" );
1375 if ( attributeValue != null )
1376 {
1377 try
1378 {
1379 ldapResult.setResultCode( ResultCodeEnum.getResultCode( Integer.parseInt( attributeValue ) ) );
1380 }
1381 catch ( NumberFormatException e )
1382 {
1383 throw new XmlPullParserException( I18n.err( I18n.ERR_03009 ), xpp, null );
1384 }
1385 }
1386 else
1387 {
1388 throw new XmlPullParserException( I18n.err( I18n.ERR_03010 ), xpp, null );
1389 }
1390 // descr
1391 attributeValue = xpp.getAttributeValue( "", "descr" );
1392 if ( attributeValue != null )
1393 {
1394 if ( DSMLV2_DESCR_TAGS.contains( attributeValue ) == false )
1395 {
1396 throw new XmlPullParserException( I18n.err( I18n.ERR_03011, attributeValue ), xpp, null );
1397 }
1398
1399 }
1400 }
1401 };
1402
1403 /**
1404 * GrammarAction that adds a Error Message to a LDAP Result
1405 */
1406 private final GrammarAction ldapResultAddErrorMessage = new GrammarAction( "Add Error Message to LDAP Result" )
1407 {
1408 public void action( Dsmlv2Container container ) throws XmlPullParserException
1409 {
1410 LdapResponseCodec ldapResponse = container.getBatchResponse().getCurrentResponse();
1411
1412 LdapResultCodec ldapResult = null;
1413
1414 // Search Response is a special case
1415 // ResultCode can only occur in a case of Search Result Done in a Search Response
1416 if ( ldapResponse instanceof SearchResponse )
1417 {
1418 SearchResponse searchResponse = ( SearchResponse ) ldapResponse;
1419 ldapResult = searchResponse.getSearchResultDone().getLdapResult();
1420 }
1421 else
1422 {
1423 ldapResult = ldapResponse.getLdapResult();
1424 }
1425
1426 XmlPullParser xpp = container.getParser();
1427 try
1428 {
1429 String nextText = xpp.nextText();
1430 if ( !nextText.equals( "" ) )
1431 {
1432 ldapResult.setErrorMessage( nextText.trim() );
1433 }
1434 }
1435 catch ( IOException e )
1436 {
1437 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1438 }
1439 }
1440 };
1441
1442 /**
1443 * GrammarAction that adds a Referral to a LDAP Result
1444 */
1445 private final GrammarAction ldapResultAddReferral = new GrammarAction( "Add Referral to LDAP Result" )
1446 {
1447 public void action( Dsmlv2Container container ) throws XmlPullParserException
1448 {
1449 LdapResponseCodec ldapResponse = container.getBatchResponse().getCurrentResponse();
1450
1451 LdapResultCodec ldapResult = null;
1452
1453 // Search Response is a special case
1454 // ResultCode can only occur in a case of Search Result Done in a Search Response
1455 if ( ldapResponse instanceof SearchResponse )
1456 {
1457 SearchResponse searchResponse = ( SearchResponse ) ldapResponse;
1458 ldapResult = searchResponse.getSearchResultDone().getLdapResult();
1459 }
1460 else
1461 {
1462 ldapResult = ldapResponse.getLdapResult();
1463 }
1464
1465 // Initialization of the Referrals if needed
1466 if ( ldapResult.getReferrals() == null )
1467 {
1468 ldapResult.initReferrals();
1469 }
1470
1471 XmlPullParser xpp = container.getParser();
1472 try
1473 {
1474 String nextText = xpp.nextText();
1475 if ( !nextText.equals( "" ) )
1476 {
1477 try
1478 {
1479 ldapResult.addReferral( new LdapURL( nextText.trim() ) );
1480 }
1481 catch ( LdapURLEncodingException e )
1482 {
1483 throw new XmlPullParserException( e.getMessage(), xpp, null );
1484 }
1485 }
1486 }
1487 catch ( IOException e )
1488 {
1489 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1490 }
1491 }
1492 };
1493
1494 /**
1495 * GrammarAction that creates the Search Response
1496 */
1497 private final GrammarAction searchResponseCreation = new GrammarAction( "Create Search Response" )
1498 {
1499 public void action( Dsmlv2Container container ) throws XmlPullParserException
1500 {
1501 SearchResponse searchResponse = new SearchResponse();
1502
1503 container.getBatchResponse().addResponse( searchResponse );
1504
1505 XmlPullParser xpp = container.getParser();
1506
1507 // Checking and adding the batchRequest's attributes
1508 String attributeValue;
1509 // requestID
1510 attributeValue = xpp.getAttributeValue( "", "requestID" );
1511 if ( attributeValue != null )
1512 {
1513 searchResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1514 }
1515 }
1516 };
1517
1518 /**
1519 * GrammarAction that creates a Search Result Entry
1520 */
1521 private final GrammarAction searchResultEntryCreation = new GrammarAction(
1522 "Add Search Result Entry to Search Response" )
1523 {
1524 public void action( Dsmlv2Container container ) throws XmlPullParserException
1525 {
1526 SearchResultEntryCodec searchResultEntry = new SearchResultEntryCodec();
1527
1528 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1529
1530 searchResponse.addSearchResultEntry( searchResultEntry );
1531
1532 XmlPullParser xpp = container.getParser();
1533
1534 // Checking and adding the request's attributes
1535 String attributeValue;
1536 // requestID
1537 attributeValue = xpp.getAttributeValue( "", "requestID" );
1538 if ( attributeValue != null )
1539 {
1540 searchResultEntry.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1541 }
1542 // dn
1543 attributeValue = xpp.getAttributeValue( "", "dn" );
1544 if ( attributeValue != null )
1545 {
1546 try
1547 {
1548 searchResultEntry.setObjectName( new DN( attributeValue ) );
1549 }
1550 catch ( LdapInvalidDnException e )
1551 {
1552 throw new XmlPullParserException( e.getMessage(), xpp, null );
1553 }
1554 }
1555 else
1556 {
1557 throw new XmlPullParserException( "dn attribute is required", xpp, null );
1558 }
1559 }
1560 };
1561
1562 /**
1563 * GrammarAction that creates a Search Result Reference
1564 */
1565 private final GrammarAction searchResultReferenceCreation = new GrammarAction(
1566 "Add Search Result Reference to Search Response" )
1567 {
1568 public void action( Dsmlv2Container container ) throws XmlPullParserException
1569 {
1570 SearchResultReferenceCodec searchResultReference = new SearchResultReferenceCodec();
1571
1572 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1573
1574 searchResponse.addSearchResultReference( searchResultReference );
1575
1576 XmlPullParser xpp = container.getParser();
1577
1578 // Checking and adding the request's attributes
1579 String attributeValue;
1580 // requestID
1581 attributeValue = xpp.getAttributeValue( "", "requestID" );
1582 if ( attributeValue != null )
1583 {
1584 searchResultReference.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1585 }
1586 }
1587 };
1588
1589 /**
1590 * GrammarAction that creates a Search Result Done
1591 */
1592 private final GrammarAction searchResultDoneCreation = new GrammarAction(
1593 "Add Search Result Done to Search Response" )
1594 {
1595 public void action( Dsmlv2Container container ) throws XmlPullParserException
1596 {
1597 SearchResultDoneCodec searchResultDone = new SearchResultDoneCodec();
1598
1599 searchResultDone.setLdapResult( new LdapResultCodec() );
1600
1601 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1602
1603 searchResponse.setSearchResultDone( searchResultDone );
1604
1605 XmlPullParser xpp = container.getParser();
1606
1607 // Checking and adding the batchRequest's attributes
1608 String attributeValue;
1609 // requestID
1610 attributeValue = xpp.getAttributeValue( "", "requestID" );
1611 if ( attributeValue != null )
1612 {
1613 searchResultDone.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
1614 }
1615 // MatchedDN
1616 attributeValue = xpp.getAttributeValue( "", "matchedDN" );
1617 if ( attributeValue != null )
1618 {
1619 try
1620 {
1621 searchResultDone.getLdapResult().setMatchedDN( new DN( attributeValue ) );
1622 }
1623 catch ( LdapInvalidDnException e )
1624 {
1625 throw new XmlPullParserException( "" + e.getMessage(), xpp, null );
1626 }
1627 }
1628 }
1629 };
1630
1631 /**
1632 * GrammarAction that adds an Attr to a Search Result Entry
1633 */
1634 private final GrammarAction searchResultEntryAddAttr = new GrammarAction( "Add Attr to Search Result Entry" )
1635 {
1636 public void action( Dsmlv2Container container ) throws XmlPullParserException
1637 {
1638 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1639
1640 SearchResultEntryCodec searchResultEntry = searchResponse.getCurrentSearchResultEntry();
1641
1642 XmlPullParser xpp = container.getParser();
1643
1644 // Checking and adding the request's attributes
1645 String attributeValue;
1646 // name
1647 attributeValue = xpp.getAttributeValue( "", "name" );
1648 if ( attributeValue != null )
1649 {
1650 searchResultEntry.addAttributeValues( attributeValue );
1651 }
1652 else
1653 {
1654 throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null );
1655 }
1656 }
1657 };
1658
1659 /**
1660 * GrammarAction that adds a Value to an Attr of a Search Result Entry
1661 */
1662 private final GrammarAction searchResultEntryAddValue = new GrammarAction(
1663 "Add a Value to an Attr of a Search Result Entry" )
1664 {
1665 public void action( Dsmlv2Container container ) throws XmlPullParserException
1666 {
1667 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1668 SearchResultEntryCodec searchResultEntry = searchResponse.getCurrentSearchResultEntry();
1669
1670 XmlPullParser xpp = container.getParser();
1671 try
1672 {
1673 // We have to catch the type Attribute Value before going to the next Text node
1674 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1675
1676 // Getting the value
1677 String nextText = xpp.nextText();
1678 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1679 {
1680 searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) );
1681 }
1682 else
1683 {
1684 searchResultEntry.addAttributeValue( nextText );
1685 }
1686 }
1687 catch ( IOException e )
1688 {
1689 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1690 }
1691 }
1692 };
1693
1694 /**
1695 * GrammarAction that adds a Ref to a Search Result Reference
1696 */
1697 private final GrammarAction searchResultReferenceAddRef = new GrammarAction(
1698 "Add a Ref to a Search Result Reference" )
1699 {
1700 public void action( Dsmlv2Container container ) throws XmlPullParserException
1701 {
1702 SearchResponse searchResponse = ( SearchResponse ) container.getBatchResponse().getCurrentResponse();
1703 SearchResultReferenceCodec searchResultReference = searchResponse.getCurrentSearchResultReference();
1704
1705 XmlPullParser xpp = container.getParser();
1706 try
1707 {
1708 String nextText = xpp.nextText();
1709 if ( !nextText.equals( "" ) )
1710 {
1711 searchResultReference.addSearchResultReference( new LdapURL( nextText ) );
1712 }
1713 }
1714 catch ( IOException e )
1715 {
1716 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1717 }
1718 catch ( LdapURLEncodingException e )
1719 {
1720 throw new XmlPullParserException( e.getMessage(), xpp, null );
1721 }
1722 }
1723 };
1724
1725 /**
1726 * GrammarAction that adds Result Code to an Extended Response
1727 */
1728 private final GrammarAction extendedResponseAddResultCode = ldapResultAddResultCode;
1729
1730 /**
1731 * GrammarAction that creates the Search Response
1732 */
1733 private final GrammarAction extendedResponseAddErrorMessage = ldapResultAddErrorMessage;
1734
1735 /**
1736 * GrammarAction that adds a Referral to an Extended Response
1737 */
1738 private final GrammarAction extendedResponseAddReferral = ldapResultAddReferral;
1739
1740 /**
1741 * GrammarAction that adds a Response Name to an Extended Response
1742 */
1743 private final GrammarAction extendedResponseAddResponseName = new GrammarAction(
1744 "Add Response Name to Extended Response" )
1745 {
1746 public void action( Dsmlv2Container container ) throws XmlPullParserException
1747 {
1748 ExtendedResponseCodec extendedResponse = ( ExtendedResponseCodec ) container.getBatchResponse().getCurrentResponse();
1749
1750 XmlPullParser xpp = container.getParser();
1751 try
1752 {
1753 String nextText = xpp.nextText();
1754 if ( !nextText.equals( "" ) )
1755 {
1756 extendedResponse.setResponseName( new OID( nextText.trim() ) );
1757 }
1758
1759 }
1760 catch ( IOException e )
1761 {
1762 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1763 }
1764 catch ( DecoderException e )
1765 {
1766 throw new XmlPullParserException( e.getMessage(), xpp, null );
1767 }
1768 }
1769 };
1770
1771 /**
1772 * GrammarAction that adds a Response to an Extended Response
1773 */
1774 private final GrammarAction extendedResponseAddResponse = new GrammarAction( "Add Response to Extended Response" )
1775 {
1776 public void action( Dsmlv2Container container ) throws XmlPullParserException
1777 {
1778 ExtendedResponseCodec extendedResponse = ( ExtendedResponseCodec ) container.getBatchResponse().getCurrentResponse();
1779
1780 XmlPullParser xpp = container.getParser();
1781 try
1782 {
1783 // We have to catch the type Attribute Value before going to the next Text node
1784 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
1785
1786 // Getting the value
1787 String nextText = xpp.nextText();
1788 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
1789 {
1790 extendedResponse.setResponse( Base64.decode( nextText.trim().toCharArray() ) );
1791 }
1792 else
1793 {
1794 extendedResponse.setResponse( nextText.trim() );
1795 }
1796 }
1797 catch ( IOException e )
1798 {
1799 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null );
1800 }
1801 }
1802 };
1803
1804
1805 /**
1806 * Get the instance of this grammar
1807 *
1808 * @return
1809 * an instance on this grammar
1810 */
1811 public static Dsmlv2ResponseGrammar getInstance()
1812 {
1813 return instance;
1814 }
1815 }