Search in sources :

Example 1 with FlowableException

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;
}
Also used : ArrayList(java.util.ArrayList) IdmEngine(org.flowable.idm.engine.IdmEngine) Bean(javax.enterprise.inject.spi.Bean) FlowableException(org.flowable.common.engine.api.FlowableException)

Example 2 with FlowableException

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;
}
Also used : FlowableException(org.flowable.common.engine.api.FlowableException) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLInputFactory(javax.xml.stream.XMLInputFactory) FlowableException(org.flowable.common.engine.api.FlowableException) BpmnModel(org.flowable.bpmn.model.BpmnModel) BpmnXMLConverter(org.flowable.bpmn.converter.BpmnXMLConverter)

Example 3 with FlowableException

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());
        }
    }
}
Also used : FlowableException(org.flowable.common.engine.api.FlowableException) ProcessDiagramGenerator(org.flowable.image.ProcessDiagramGenerator)

Example 4 with FlowableException

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;
}
Also used : FlowableException(org.flowable.common.engine.api.FlowableException) AddCommentCmd(org.flowable.engine.impl.cmd.AddCommentCmd) FlowableIllegalArgumentException(org.flowable.common.engine.api.FlowableIllegalArgumentException)

Example 5 with FlowableException

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()");
    }
}
Also used : AdminRuntimeService(org.ow2.petals.se.flowable.clientserver.api.admin.AdminRuntimeService) RuntimeService(org.flowable.engine.RuntimeService) TaskService(org.flowable.engine.TaskService) UserTaskStartedEventListener(org.ow2.petals.flowable.event.UserTaskStartedEventListener) HistoryService(org.flowable.engine.HistoryService) IntermediateCatchMessageEventStartedEventListener(org.ow2.petals.flowable.event.IntermediateCatchMessageEventStartedEventListener) ProcessInstanceCompletedEventListener(org.ow2.petals.flowable.event.ProcessInstanceCompletedEventListener) ServiceTaskStartedEventListener(org.ow2.petals.flowable.event.ServiceTaskStartedEventListener) ProcessInstanceCanceledEventListener(org.ow2.petals.flowable.event.ProcessInstanceCanceledEventListener) FlowableException(org.flowable.common.engine.api.FlowableException) ProcessInstanceStartedEventListener(org.ow2.petals.flowable.event.ProcessInstanceStartedEventListener) UserTaskCompletedEventListener(org.ow2.petals.flowable.event.UserTaskCompletedEventListener) IntermediateCatchMessageEventEndedEventListener(org.ow2.petals.flowable.event.IntermediateCatchMessageEventEndedEventListener) JBIException(javax.jbi.JBIException) CallActivityStartedEventListener(org.ow2.petals.flowable.event.CallActivityStartedEventListener)

Aggregations

FlowableException (org.flowable.common.engine.api.FlowableException)25 Task (org.flowable.task.api.Task)7 Process (org.flowable.bpmn.model.Process)5 FlowableObjectNotFoundException (org.flowable.common.engine.api.FlowableObjectNotFoundException)5 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 WorkflowException (org.apache.syncope.core.workflow.api.WorkflowException)4 org.flowable.bpmn.model (org.flowable.bpmn.model)4 ProcessEngineConfiguration (org.flowable.engine.ProcessEngineConfiguration)4 RepositoryService (org.flowable.engine.RepositoryService)4 ProcessInstance (org.flowable.engine.runtime.ProcessInstance)4 java.util (java.util)3 Function (java.util.function.Function)3 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 FlowableIllegalArgumentException (org.flowable.common.engine.api.FlowableIllegalArgumentException)3 TaskFormData (org.flowable.engine.form.TaskFormData)3 ExecutionEntity (org.flowable.engine.impl.persistence.entity.ExecutionEntity)3 Deployment (org.flowable.engine.repository.Deployment)3 Model (org.flowable.engine.repository.Model)3 CollUtil (cn.hutool.core.collection.CollUtil)2