Skip to content

Commit

Permalink
[KOGITO-6638] Enhancing error message when message has not association
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Feb 14, 2022
1 parent 666ef45 commit d86697c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
import org.drools.core.xml.BaseAbstractHandler;
import org.drools.core.xml.ExtensibleXmlParser;
import org.drools.core.xml.Handler;
import org.jbpm.bpmn2.core.*;
import org.jbpm.bpmn2.core.DataStore;
import org.jbpm.bpmn2.core.Definitions;
import org.jbpm.bpmn2.core.Error;
import org.jbpm.bpmn2.core.Escalation;
import org.jbpm.bpmn2.core.Interface;
import org.jbpm.bpmn2.core.ItemDefinition;
import org.jbpm.bpmn2.core.Message;
import org.jbpm.bpmn2.core.Signal;
import org.jbpm.compiler.xml.ProcessBuildData;
import org.jbpm.ruleflow.core.RuleFlowProcess;
import org.xml.sax.Attributes;
Expand Down Expand Up @@ -52,6 +58,7 @@ public MessageHandler() {
}
}

@Override
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName,
final Attributes attrs, final ExtensibleXmlParser parser)
Expand Down Expand Up @@ -84,18 +91,21 @@ public Object start(final String uri, final String localName,
message.setType(itemDefinition.getStructureRef());
message.setName(name);

if (message.getType() != null && !message.getType().isEmpty()) {
messages.put(id, message);
if (message.getType() == null || message.getType().isEmpty()) {
throw new ProcessParsingValidationException("A message definition requires a valid type. Check " + itemRef + " itemDefinition");
}
messages.put(id, message);
return message;
}

@Override
public Object end(final String uri, final String localName,
final ExtensibleXmlParser parser) throws SAXException {
parser.endElementBuilder();
return parser.getCurrent();
}

@Override
public Class<?> generateNodeFor() {
return Message.class;
}
Expand Down

0 comments on commit d86697c

Please sign in to comment.