use of org.flowable.common.engine.api.FlowableException in project zaakafhandelcomponent by NL-AMS-LOCGOV.
the class FlowableIdmExtension method lookupIdmEngine.
protected IdmEngine lookupIdmEngine(final BeanManager beanManager) {
final ServiceLoader<IdmEngineLookup> idmEngineServiceLoader = ServiceLoader.load(IdmEngineLookup.class);
final Iterator<IdmEngineLookup> serviceIterator = idmEngineServiceLoader.iterator();
final List<IdmEngineLookup> discoveredLookups = new ArrayList<>();
while (serviceIterator.hasNext()) {
final IdmEngineLookup serviceInstance = serviceIterator.next();
discoveredLookups.add(serviceInstance);
}
Collections.sort(discoveredLookups, new Comparator<IdmEngineLookup>() {
@Override
public int compare(final IdmEngineLookup o1, final IdmEngineLookup o2) {
return (-1) * ((Integer) o1.getPrecedence()).compareTo(o2.getPrecedence());
}
});
IdmEngine idmEngine = null;
for (final IdmEngineLookup idmEngineLookup : discoveredLookups) {
idmEngine = idmEngineLookup.getIdmEngine();
if (idmEngine != null) {
this.idmEngineLookup = idmEngineLookup;
LOGGER.debug("IdmEngineLookup service {} returned idm engine.", idmEngineLookup.getClass());
break;
} else {
LOGGER.debug("IdmEngineLookup service {} returned 'null' value.", idmEngineLookup.getClass());
}
}
if (idmEngineLookup == null) {
throw new FlowableException("Could not find an implementation of the " + IdmEngineLookup.class.getName() + " service returning a non-null idmEngine. Giving up.");
}
final Bean<FlowableIdmServices> flowableIdmServicesBean = (Bean<FlowableIdmServices>) beanManager.getBeans(FlowableIdmServices.class).stream().findAny().orElseThrow(() -> new IllegalStateException("CDI BeanManager cannot find an instance of requested type " + FlowableIdmServices.class.getName()));
final FlowableIdmServices services = (FlowableIdmServices) beanManager.getReference(flowableIdmServicesBean, FlowableIdmServices.class, beanManager.createCreationalContext(flowableIdmServicesBean));
services.setIdmEngine(idmEngine);
return idmEngine;
}
use of org.flowable.common.engine.api.FlowableException in project ox-data-cloud by ox-data.
the class SaveModelEditorCmd method generateBpmnModel.
private BpmnModel generateBpmnModel(byte[] bytes) {
BpmnModel bpmnModel = null;
try {
XMLInputFactory xif = XMLInputFactory.newInstance();
InputStreamReader xmlIn = new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8");
XMLStreamReader xtr = xif.createXMLStreamReader(xmlIn);
bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
} catch (Exception e) {
throw new FlowableException("SaveModelEditorCmd error :" + e.getMessage());
}
return bpmnModel;
}
use of org.flowable.common.engine.api.FlowableException in project ox-data-cloud by ox-data.
the class SaveModelEditorCmd method addModelEditorSourceAndSourceExtra.
private void addModelEditorSourceAndSourceExtra(ProcessEngineConfiguration processEngineConfiguration, RepositoryService repositoryService, byte[] bytes, BpmnModel bpmnModel, String modelId) {
if (bytes != null) {
repositoryService.addModelEditorSource(modelId, bytes);
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
InputStream resource = diagramGenerator.generateDiagram(bpmnModel, "png", Collections.emptyList(), Collections.emptyList(), processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getAnnotationFontName(), processEngineConfiguration.getClassLoader(), 1.0, true);
try {
repositoryService.addModelEditorSourceExtra(modelId, IOUtils.toByteArray(resource));
} catch (IOException e) {
throw new FlowableException("SaveModelEditorCmd error :" + e.getMessage());
}
}
}
use of org.flowable.common.engine.api.FlowableException in project ox-data-cloud by ox-data.
the class CompleteTaskReadCmd method execute.
@Override
protected Void execute(CommandContext commandContext, TaskEntity task) {
if (userId == null || userId.length() == 0) {
throw new FlowableIllegalArgumentException("userId is null or empty");
}
if (!FlowableConstant.CATEGORY_TO_READ.equals(task.getCategory())) {
throw new FlowableException("task category must be 'toRead'");
}
if (!userId.equals(task.getOwner()) && !userId.equals(task.getAssignee())) {
throw new FlowableException("User does not have permission");
}
commandContext.getCommandExecutor().execute(new AddCommentCmd(taskId, task.getProcessInstanceId(), CommentTypeEnum.YY.toString(), "已阅!"));
TaskHelper.completeTask(task, null, null, null, null, commandContext);
return null;
}
use of org.flowable.common.engine.api.FlowableException in project petals-se-flowable by petalslink.
the class FlowableSE method doStart.
@Override
public void doStart() throws JBIException {
this.getLogger().fine("Start FlowableSE.doStart()");
// Create & Register event listeners
final RuntimeService runtimeService = this.flowableEngine.getRuntimeService();
this.processInstanceStartedEventListener = new ProcessInstanceStartedEventListener(this);
runtimeService.addEventListener(this.processInstanceStartedEventListener, this.processInstanceStartedEventListener.getListenEventType());
final HistoryService historyService = this.flowableEngine.getHistoryService();
this.processInstanceCompletedEventListener = new ProcessInstanceCompletedEventListener(historyService, this);
runtimeService.addEventListener(this.processInstanceCompletedEventListener, this.processInstanceCompletedEventListener.getListenEventType());
this.processInstanceCanceledEventListener = new ProcessInstanceCanceledEventListener(historyService, this);
runtimeService.addEventListener(this.processInstanceCanceledEventListener, this.processInstanceCanceledEventListener.getListenEventType());
this.serviceTaskStartedEventListener = new ServiceTaskStartedEventListener(runtimeService, this);
runtimeService.addEventListener(this.serviceTaskStartedEventListener, this.serviceTaskStartedEventListener.getListenEventType());
final TaskService taskService = this.flowableEngine.getTaskService();
this.userTaskStartedEventListener = new UserTaskStartedEventListener(this.simpleUUIDGenerator, taskService, this);
runtimeService.addEventListener(this.userTaskStartedEventListener, this.userTaskStartedEventListener.getListenEventType());
this.userTaskCompletedEventListener = new UserTaskCompletedEventListener(taskService, this);
runtimeService.addEventListener(this.userTaskCompletedEventListener, this.userTaskCompletedEventListener.getListenEventType());
this.callActivityStartedEventListener = new CallActivityStartedEventListener(runtimeService, this.simpleUUIDGenerator, this);
runtimeService.addEventListener(this.callActivityStartedEventListener, this.callActivityStartedEventListener.getListenEventType());
this.intermediateCatchMessageEventStartedEventListener = new IntermediateCatchMessageEventStartedEventListener(this.simpleUUIDGenerator, runtimeService, this);
runtimeService.addEventListener(this.intermediateCatchMessageEventStartedEventListener, this.intermediateCatchMessageEventStartedEventListener.getListenEventType());
this.intermediateCatchMessageEventEndedEventListener = new IntermediateCatchMessageEventEndedEventListener(runtimeService, this);
runtimeService.addEventListener(this.intermediateCatchMessageEventEndedEventListener, this.intermediateCatchMessageEventEndedEventListener.getListenEventType());
try {
// must be stopped when the SE is in state 'STOPPED'
if (this.enableFlowableJobExecutor) {
if (this.flowableAsyncExecutor != null) {
if (this.flowableAsyncExecutor.isActive()) {
this.getLogger().warning("Flowable Job Executor already started !!");
} else {
this.flowableAsyncTaskExecutor.start();
this.flowableAsyncExecutor.start();
}
this.configureMonitoringMBeanWithAsyncExecutorThreadPool();
this.configureMonitoringMBeanWithDatabaseConnectionPool();
} else {
this.getLogger().warning("No Flowable Job Executor exists !!");
}
} else {
this.getLogger().info("Flowable Job Executor not started because it is not activated.");
}
// TODO: Add JMX operation to start/stop the Flowable job executor when the component is started
// TODO: Add JMX operation to disable/enable the Flowable job executor when the component is running
} catch (final FlowableException e) {
throw new JBIException("An error occurred while starting the Flowable BPMN Engine.", e);
} finally {
this.getLogger().fine("End FlowableSE.doStart()");
}
}
Aggregations