listener.setImplementationType(dialog.implementationType);
if(AlfrescoUserTask.ALFRESCO_SCRIPT_TASK_LISTENER.equalsIgnoreCase(dialog.implementation) ||
AlfrescoScriptTask.ALFRESCO_SCRIPT_EXECUTION_LISTENER.equalsIgnoreCase(dialog.implementation)) {
List<FieldExtension> extensionList = listener.getFieldExtensions();
FieldExtension scriptExtension = null;
FieldExtension runAsExtension = null;
FieldExtension scriptProcessorExtension = null;
for (FieldExtension fieldExtension : extensionList) {
if ("script".equalsIgnoreCase(fieldExtension.getFieldName())) {
scriptExtension = fieldExtension;
} else if ("runAs".equalsIgnoreCase(fieldExtension.getFieldName())) {
runAsExtension = fieldExtension;
} else if ("scriptProcessor".equalsIgnoreCase(fieldExtension.getFieldName())) {
scriptProcessorExtension = fieldExtension;
}
}
if (scriptExtension != null) {
scriptExtension.setStringValue(dialog.script);
} else {
scriptExtension = new FieldExtension();
scriptExtension.setFieldName("script");
scriptExtension.setStringValue(dialog.script);
listener.getFieldExtensions().add(scriptExtension);
}
if (runAsExtension != null) {
runAsExtension.setStringValue(dialog.runAs);
} else {
runAsExtension = new FieldExtension();
runAsExtension.setFieldName("runAs");
runAsExtension.setStringValue(dialog.runAs);
listener.getFieldExtensions().add(runAsExtension);
}
if (scriptProcessorExtension != null) {
scriptProcessorExtension.setStringValue(dialog.scriptProcessor);
} else {
scriptProcessorExtension = new FieldExtension();
scriptProcessorExtension.setFieldName("scriptProcessor");
scriptProcessorExtension.setStringValue(dialog.scriptProcessor);
listener.getFieldExtensions().add(scriptProcessorExtension);
}
} else {
setFieldsInListener(listener, dialog.fieldExtensionList);