ScriptProcessorRegistry registry = ProcessToolContext.Util.getThreadProcessToolContext().getRegistry().lookupService(
ScriptProcessorRegistry.class.getName());
Property scriptType = formProperties.get("scriptEngineType");
if (scriptType == null || scriptType.getValue() == null || ((String) scriptType.getValue()).isEmpty())
throw new Validator.InvalidValueException("script.undefined.type");
ScriptProcessor scriptProcessor = registry.getScriptProcessor((String) scriptType.getValue());
if (scriptProcessor == null)
throw new Validator.InvalidValueException("script.processor.not.found");
InputStream is = new ByteArrayInputStream(((String) code.getValue()).getBytes());
scriptProcessor.validate(is);
code.commit();
showInfoNotification("validation.script.ok");
} catch (Validator.InvalidValueException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
showWarningNotification(e.getMessage(), null);