use of org.drools.compiler.compiler.ProcessLoadError in project drools by kiegroup.
the class KnowledgeBuilderImpl method addProcessFromXml.
public void addProcessFromXml(Resource resource) {
if (processBuilder == null) {
throw new RuntimeException("Unable to instantiate a process assembler");
}
if (ResourceType.DRF.equals(resource.getResourceType())) {
addBuilderResult(new DeprecatedResourceTypeWarning(resource, "RF"));
}
this.resource = resource;
try {
List<Process> processes = processBuilder.addProcessFromXml(resource);
List<BaseKnowledgeBuilderResultImpl> errors = processBuilder.getErrors();
if (errors.isEmpty()) {
if (this.kBase != null && processes != null) {
for (Process process : processes) {
if (filterAccepts(ResourceChange.Type.PROCESS, process.getNamespace(), process.getId())) {
this.kBase.addProcess(process);
}
}
}
} else {
this.results.addAll(errors);
errors.clear();
}
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
addBuilderResult(new ProcessLoadError(resource, "Unable to load process.", e));
}
this.results = getResults(this.results);
this.resource = null;
}
use of org.drools.compiler.compiler.ProcessLoadError in project drools by kiegroup.
the class RuleFlowErrorTest method testError.
@Test
public void testError() {
ProcessLoadError err = new ProcessLoadError(null, "XXX", null);
assertEquals("XXX", err.getMessage());
Exception e = new RuntimeException("Q");
err = new ProcessLoadError(null, "X", e);
assertNotNull(err.getMessage());
assertTrue(err instanceof DroolsError);
}
use of org.drools.compiler.compiler.ProcessLoadError in project jbpm by kiegroup.
the class ProcessBuilderImpl method addProcessFromXml.
public List<Process> addProcessFromXml(final Resource resource) throws IOException {
Reader reader = resource.getReader();
KnowledgeBuilderConfigurationImpl configuration = knowledgeBuilder.getBuilderConfiguration();
XmlProcessReader xmlReader = new XmlProcessReader(configuration.getSemanticModules(), knowledgeBuilder.getRootClassLoader());
List<Process> processes = null;
try {
String portRuleFlow = System.getProperty("drools.ruleflow.port", "false");
Reader portedReader = null;
if (portRuleFlow.equalsIgnoreCase("true")) {
portedReader = portToCurrentVersion(reader);
} else {
portedReader = reader;
}
processes = xmlReader.read(portedReader);
if (processes != null) {
// stop null pointers
for (Process process : processes) {
buildProcess(process, resource);
xmlReader.getProcessBuildData().onBuildComplete(process);
}
} else {
// @TODO could we maybe add something a bit more informative about what is wrong with the XML ?
this.errors.add(new ProcessLoadError(resource, "unable to parse xml", null));
}
} catch (FactoryConfigurationError e1) {
this.errors.add(new ProcessLoadError(resource, "FactoryConfigurationError ", e1.getException()));
} catch (Exception e2) {
e2.printStackTrace();
this.errors.add(new ProcessLoadError(resource, "unable to parse xml", e2));
} finally {
reader.close();
}
return processes;
}
Aggregations