use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParseUtil method parseInputParameterElement.
/**
* Parses a input parameter and adds it to the {@link IoMapping}.
*
* @param inputParameterElement the input parameter element
* @param ioMapping the mapping to add the element
* @throws BpmnParseException if the input parameter element is malformed
*/
public static void parseInputParameterElement(Element inputParameterElement, IoMapping ioMapping) {
String nameAttribute = inputParameterElement.attribute("name");
if (nameAttribute == null || nameAttribute.isEmpty()) {
throw new BpmnParseException("Missing attribute 'name' for inputParameter", inputParameterElement);
}
ParameterValueProvider valueProvider = parseNestedParamValueProvider(inputParameterElement);
// add parameter
ioMapping.addInputParameter(new InputParameter(nameAttribute, valueProvider));
}
use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParseUtil method parseCamundaScript.
/**
* Parses a camunda script element.
*
* @param scriptElement the script element ot parse
* @return the generated executable script
* @throws BpmnParseException if the a attribute is missing or the script cannot be processed
*/
public static ExecutableScript parseCamundaScript(Element scriptElement) {
String scriptLanguage = scriptElement.attribute("scriptFormat");
if (scriptLanguage == null || scriptLanguage.isEmpty()) {
throw new BpmnParseException("Missing attribute 'scriptFormatAttribute' for 'script' element", scriptElement);
} else {
String scriptResource = scriptElement.attribute("resource");
String scriptSource = scriptElement.getText();
try {
return ScriptUtil.getScript(scriptLanguage, scriptSource, scriptResource, getExpressionManager());
} catch (ProcessEngineException e) {
throw new BpmnParseException("Unable to process script", scriptElement, e);
}
}
}
use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParseUtil method parseOutputParameterElement.
/**
* Parses a output parameter and adds it to the {@link IoMapping}.
*
* @param outputParameterElement the output parameter element
* @param ioMapping the mapping to add the element
* @throws BpmnParseException if the output parameter element is malformed
*/
public static void parseOutputParameterElement(Element outputParameterElement, IoMapping ioMapping) {
String nameAttribute = outputParameterElement.attribute("name");
if (nameAttribute == null || nameAttribute.isEmpty()) {
throw new BpmnParseException("Missing attribute 'name' for outputParameter", outputParameterElement);
}
ParameterValueProvider valueProvider = parseNestedParamValueProvider(outputParameterElement);
// add parameter
ioMapping.addOutputParameter(new OutputParameter(nameAttribute, valueProvider));
}
use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class ConnectorParseListener method parseServiceTask.
@Override
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
Element connectorDefinition = findCamundaExtensionElement(serviceTaskElement, "connector");
if (connectorDefinition != null) {
Element connectorIdElement = connectorDefinition.element("connectorId");
String connectorId = null;
if (connectorIdElement != null) {
connectorId = connectorIdElement.getText().trim();
}
if (connectorIdElement == null || connectorId.isEmpty()) {
throw new BpmnParseException("No 'id' defined for connector.", connectorDefinition);
}
IoMapping ioMapping = parseInputOutput(connectorDefinition);
activity.setActivityBehavior(new ServiceTaskConnectorActivityBehavior(connectorId, ioMapping));
}
}
use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParseUtil method parseParamValueProvider.
/**
* @throws BpmnParseException if the parameter is invalid
*/
protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) {
// LIST
if ("list".equals(parameterElement.getTagName())) {
List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>();
for (Element element : parameterElement.elements()) {
// parse nested provider
providerList.add(parseParamValueProvider(element));
}
return new ListValueProvider(providerList);
}
// MAP
if ("map".equals(parameterElement.getTagName())) {
TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>();
for (Element entryElement : parameterElement.elements("entry")) {
// entry must provide key
String keyAttribute = entryElement.attribute("key");
if (keyAttribute == null || keyAttribute.isEmpty()) {
throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
}
// parse nested provider
providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement));
}
return new MapValueProvider(providerMap);
}
// SCRIPT
if ("script".equals(parameterElement.getTagName())) {
ExecutableScript executableScript = parseCamundaScript(parameterElement);
if (executableScript != null) {
return new ScriptValueProvider(executableScript);
} else {
return new NullValueProvider();
}
}
String textContent = parameterElement.getText().trim();
if (!textContent.isEmpty()) {
// EL
return new ElValueProvider(getExpressionManager().createExpression(textContent));
} else {
// NULL value
return new NullValueProvider();
}
}
Aggregations