Skip to content

Commit 1266ba2

Browse files
committed
refactoring, removed wrong PluginException (Issue #948)
1 parent de882e3 commit 1266ba2

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/WorkflowService.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,9 @@ public List<ItemCollection> evalWorkflowResultXML(ItemCollection event, String x
11961196
* matching the given XML tag and name attribtue. A custom XML configuriaton may
11971197
* contain one or many XML tags with the same name. Each result ItemCollection
11981198
* holds the tag values of each XML tag.
1199-
*
1199+
* <p>
12001200
* Example:
1201+
* <p>
12011202
*
12021203
* <pre>
12031204
* {@code
@@ -1207,6 +1208,10 @@ public List<ItemCollection> evalWorkflowResultXML(ItemCollection event, String x
12071208
* </imixs-config>
12081209
* }
12091210
* </pre>
1211+
* <p>
1212+
* If the xmlExpression does not contain the requested XML tag, the method
1213+
* returns an empty list.
1214+
*
12101215
*
12111216
* @param event
12121217
* @param xmlTag - xml tag to be evaluated
@@ -1222,27 +1227,23 @@ public List<ItemCollection> evalXMLExpressionList(String xmlExpression, String x
12221227
List<ItemCollection> result = new ArrayList<ItemCollection>();
12231228
// find all xml configs with the given tat name
12241229
ItemCollection configItemCol = evalXMLExpression(xmlExpression, xmlTag, documentContext, resolveItemValues);
1225-
if (configItemCol == null) {
1226-
// no configuration found!
1227-
throw new PluginException(WorkflowService.class.getSimpleName(), INVALID_TAG_FORMAT,
1228-
"Missing XML definition");
1229-
}
1230-
1231-
List<String> xmlDefinitions = configItemCol.getItemValueList(name, String.class);
1232-
if (xmlDefinitions != null) {
1233-
for (String definitionXML : xmlDefinitions) {
1234-
if (definitionXML.trim().isEmpty()) {
1235-
// no definition
1236-
continue;
1237-
}
1238-
// evaluate the definition (XML format expected here!)
1239-
ItemCollection xmlItemCol = XMLParser.parseItemStructure(definitionXML);
1240-
if (xmlItemCol != null) {
1241-
result.add(xmlItemCol);
1230+
if (configItemCol != null) {
1231+
// configuration found, test definition name....
1232+
List<String> xmlDefinitions = configItemCol.getItemValueList(name, String.class);
1233+
if (xmlDefinitions != null) {
1234+
for (String definitionXML : xmlDefinitions) {
1235+
if (definitionXML.trim().isEmpty()) {
1236+
// no definition
1237+
continue;
1238+
}
1239+
// evaluate the definition (XML format expected here!)
1240+
ItemCollection xmlItemCol = XMLParser.parseItemStructure(definitionXML);
1241+
if (xmlItemCol != null) {
1242+
result.add(xmlItemCol);
1243+
}
12421244
}
12431245
}
12441246
}
1245-
12461247
return result;
12471248

12481249
}
@@ -1269,8 +1270,11 @@ public List<ItemCollection> evalXMLExpressionList(String xmlExpression, String x
12691270
* <p>
12701271
* This example will result in a new item 'somedata' with the $uniqueid prefixed
12711272
* with 'ABC'
1272-
*
1273+
* <p>
12731274
* You can also activate the debug mode with the optional tag 'debug="true"'
1275+
* <P>
1276+
* If the xmlExpression does not contain the requested XML tag, the method
1277+
* returns null
12741278
*
12751279
* @see https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
12761280
* @param event
@@ -1289,17 +1293,15 @@ public ItemCollection evalXMLExpression(String xmlExpression, String xmlTag, Ite
12891293
if (xmlExpression.trim().isEmpty()) {
12901294
return null;
12911295
}
1292-
1293-
debug = xmlExpression.toLowerCase().contains("debug=\"ture\"");
12941296
if (xmlTag == null || xmlTag.isEmpty()) {
12951297
logger.warning("cannot eval workflow result - no tag name specified. Verify model!");
12961298
return null;
12971299
}
1298-
12991300
// if no <tag exists we skip the evaluation...
13001301
if (xmlExpression.indexOf("<" + xmlTag) == -1) {
13011302
return null;
13021303
}
1304+
debug = xmlExpression.toLowerCase().contains("debug=\"true\"");
13031305

13041306
// replace dynamic values?
13051307
if (resolveItemValues) {

0 commit comments

Comments
 (0)