if ( trigger == null ) {
throw new ValidationException(new ErrorMessage("trigger/triggerParameterMissing"));
}
// Decode instruction
StringTokenizer tokenizer = new StringTokenizer(StringValueDescriptor.ANY.valueOf(parameter.get(INSTRUCTION_IDENTIFIER+trigger), context).toString(), ";");
URI actionURI = new URIValue(tokenizer.nextToken());
boolean validate = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
boolean wizard = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
String lastStep = tokenizer.nextToken();
String targetStep = tokenizer.nextToken();
String domain = tokenizer.nextToken();
List involvedParamters = new ArrayList();
while ( tokenizer.hasMoreTokens() ) {
involvedParamters.add(tokenizer.nextToken());
}
Store store = context.getStore(Store.SESSION);
// 1. Store all (request) parameters into requested domain
Map map;
MapValue mapResource = (MapValue)store.get(domain);
if ( mapResource == null ) {
map = new HashMap();
mapResource = new MapValue(map);
store.put(domain, mapResource);
} else {
map = mapResource.getMap();
}
map.put(ControlComposer.VALIDATE, new BooleanValue(validate));
map.put(Process.STEP, new StringValue(targetStep));
map.putAll(parameter);
if ( validate ) {
// 2. Validate parameters
Processor processor = ProcessorManager.getInstance().getProcessor(actionURI);
try {
// Validate only given parameters to enable wizard like forms
ParameterDescriptor[] parameterDescriptors = processor.getParameterDescriptors();
for ( int i = 0; i < parameterDescriptors.length; i++ ) {
String parameterName = parameterDescriptors[i].getName();
if ( involvedParamters.contains(parameterName) ) {
map.put(parameterName, ProcessorManager.prepareValue(parameterDescriptors[i], parameter.get(parameterName), context));
}
}
if ( wizard ) {
// Don't validate target step form
map.put(ControlComposer.VALIDATE, BooleanValue.FALSE);
}
} catch ( ValidationException exception ) {
// 3. Go back to form step if validation failes
map.put(Process.STEP, new StringValue(lastStep));
}
}
// 4. Launch target step if validation is successfull
Processor formProcess = ProcessorManager.getInstance().getProcessor(new URIValue(domain));
map.remove(RESULT);
Result formResult = formProcess.process(parameter, context);
map.put(RESULT, formResult);
Processor bookmark = ProcessorManager.getInstance().getProcessor(context.getBookmark());
return bookmark.process(parameter, context);