http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/GenerateToken.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/GenerateToken.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/GenerateToken.java deleted file mode 100644 index a5e70e5..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/GenerateToken.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.apache.syncope.core.persistence.api.dao.ConfDAO; -import org.apache.syncope.core.persistence.api.entity.user.User; -import org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class GenerateToken extends AbstractActivitiServiceTask { - - @Autowired - private ConfDAO confDAO; - - @Override - protected void doExecute(final String executionId) { - User user = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER, User.class); - - user.generateToken( - confDAO.find("token.length", 256L).intValue(), - confDAO.find("token.expireTime", 60L).intValue()); - - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.USER, user); - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Notify.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Notify.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Notify.java deleted file mode 100644 index 54e7852..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Notify.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.types.AuditElements; -import org.apache.syncope.core.persistence.api.entity.user.User; -import org.apache.syncope.core.provisioning.api.notification.NotificationManager; -import org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * General-purpose notification task for usage within workflow. - * It requires a pre-existing <tt>Notification</tt> with category <tt>CUSTOM</tt> and result <tt>SUCCESS</tt>. - * An <tt>event</tt> workflow variable needs to be provided as well. - */ -@Component -public class Notify extends AbstractActivitiServiceTask { - - @Autowired - private NotificationManager notificationManager; - - @Override - protected void doExecute(final String executionId) { - User user = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER, User.class); - UserTO userTO = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER_TO, UserTO.class); - String event = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.EVENT, String.class); - - if (StringUtils.isNotBlank(event)) { - notificationManager.createTasks( - AuditElements.EventCategoryType.CUSTOM, - null, - null, - event, - AuditElements.Result.SUCCESS, - userTO, - null, - user.getToken()); - } else { - LOG.debug("Not sending any notification since no event was found"); - } - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/PasswordReset.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/PasswordReset.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/PasswordReset.java deleted file mode 100644 index 8a33bfb..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/PasswordReset.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.apache.syncope.common.lib.patch.PasswordPatch; -import org.apache.syncope.common.lib.patch.UserPatch; -import org.apache.syncope.core.provisioning.api.PropagationByResource; -import org.apache.syncope.core.persistence.api.dao.UserDAO; -import org.apache.syncope.core.persistence.api.entity.user.User; -import org.apache.syncope.core.provisioning.api.data.UserDataBinder; -import org.apache.syncope.core.workflow.api.WorkflowException; -import org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class PasswordReset extends AbstractActivitiServiceTask { - - @Autowired - private UserDAO userDAO; - - @Autowired - private UserDataBinder dataBinder; - - @Override - protected void doExecute(final String executionId) { - User user = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER, User.class); - String token = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.TOKEN, String.class); - String password = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.PASSWORD, String.class); - - if (!user.checkToken(token)) { - throw new WorkflowException(new IllegalArgumentException("Wrong token: " + token + " for " + user)); - } - - user.removeToken(); - - UserPatch userPatch = new UserPatch(); - userPatch.setKey(user.getKey()); - userPatch.setPassword(new PasswordPatch.Builder(). - onSyncope(true). - resources(userDAO.findAllResourceKeys(user.getKey())). - value(password).build()); - - PropagationByResource propByRes = dataBinder.update(user, userPatch); - - // report updated user and propagation by resource as result - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.USER, user); - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.USER_PATCH, userPatch); - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Reactivate.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Reactivate.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Reactivate.java deleted file mode 100644 index 18102f2..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Reactivate.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.springframework.stereotype.Component; - -@Component -public class Reactivate extends AbstractActivitiServiceTask { - - @Override - protected void doExecute(final String executionId) { - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Recertify.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Recertify.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Recertify.java deleted file mode 100644 index 2ebc05a..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Recertify.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import java.util.Date; -import org.apache.syncope.core.persistence.api.dao.UserDAO; -import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory; -import org.apache.syncope.core.persistence.api.entity.EntityFactory; -import org.apache.syncope.core.persistence.api.entity.user.User; -import org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Recertify extends AbstractActivitiServiceTask { - - @Autowired - protected UserDAO userDAO; - - @Autowired - protected EntityFactory entityFactory; - - @Autowired - protected AnyUtilsFactory anyUtilsFactory; - - @Override - protected void doExecute(final String executionId) { - LOG.debug("Processing Recertification {}", executionId); - User user = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER, User.class); - String submitter = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.FORM_SUBMITTER, String.class); - - LOG.debug("Saving Recertification information for user {}", user.getUsername()); - - user.setLastRecertificator(submitter); - user.setLastRecertification(new Date()); - - userDAO.save(user); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Suspend.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Suspend.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Suspend.java deleted file mode 100644 index 903b2ee..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Suspend.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.springframework.stereotype.Component; - -@Component -public class Suspend extends AbstractActivitiServiceTask { - - @Override - protected void doExecute(final String executionId) { - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Update.java ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Update.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Update.java deleted file mode 100644 index 163cf1c..0000000 --- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/task/Update.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.workflow.activiti.task; - -import org.apache.syncope.common.lib.patch.UserPatch; -import org.apache.syncope.core.provisioning.api.PropagationByResource; -import org.apache.syncope.core.persistence.api.entity.user.User; -import org.apache.syncope.core.provisioning.api.data.UserDataBinder; -import org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Update extends AbstractActivitiServiceTask { - - @Autowired - private UserDataBinder dataBinder; - - @Override - protected void doExecute(final String executionId) { - User user = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER, User.class); - UserPatch userPatch = engine.getRuntimeService(). - getVariable(executionId, ActivitiUserWorkflowAdapter.USER_PATCH, UserPatch.class); - - PropagationByResource propByRes = dataBinder.update(user, userPatch); - - // report updated user and propagation by resource as result - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.USER, user); - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.USER_PATCH, userPatch); - engine.getRuntimeService().setVariable(executionId, ActivitiUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/resources/userWorkflow.bpmn20.xml ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/resources/userWorkflow.bpmn20.xml b/core/workflow-activiti/src/main/resources/userWorkflow.bpmn20.xml deleted file mode 100644 index 1174418..0000000 --- a/core/workflow-activiti/src/main/resources/userWorkflow.bpmn20.xml +++ /dev/null @@ -1,287 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:activiti="http://activiti.org/bpmn" - xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" - xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" - xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" - typeLanguage="http://www.w3.org/2001/XMLSchema" - expressionLanguage="http://www.w3.org/1999/XPath" - targetNamespace="http://activiti.org/bpmn20"> - - <process id="userWorkflow" name="User Workflow" isExecutable="true"> - <startEvent id="theStart"/> - <sequenceFlow id="flow1" sourceRef="theStart" targetRef="create"/> - <serviceTask id="create" name="Create" activiti:expression="#{create.execute(execution.processInstanceId)}"/> - <sequenceFlow id="flow2" sourceRef="create" targetRef="activate"/> - <scriptTask id="activate" name="Activate" scriptFormat="groovy" activiti:autoStoreVariables="false"> - <script>execution.setVariable("propagateEnable", Boolean.TRUE);</script> - </scriptTask> - <sequenceFlow id="flow3" sourceRef="activate" targetRef="active"/> - <userTask id="active" name="Active"/> - <sequenceFlow id="flow8" sourceRef="active" targetRef="activeGw"/> - <exclusiveGateway id="activeGw"/> - <sequenceFlow id="active2Update" sourceRef="activeGw" targetRef="update"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'update'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="active2Suspend" sourceRef="activeGw" targetRef="suspend"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'suspend'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="active2Delete" sourceRef="activeGw" targetRef="delete"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'delete'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="active2RequestPasswordReset" sourceRef="activeGw" targetRef="generateToken4PasswordReset"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'requestPasswordReset'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="active2ConfirmPasswordReset" sourceRef="activeGw" targetRef="checkToken4ConfirmPasswordReset"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'confirmPasswordReset'}]]></conditionExpression> - </sequenceFlow> - <serviceTask id="update" name="Update" activiti:expression="#{update.execute(execution.processInstanceId)}"/> - <sequenceFlow id="sid-EA22026A-25F0-4ED0-AB6E-9CE9CE74623C" sourceRef="update" targetRef="active"/> - <serviceTask id="suspend" name="Suspend" activiti:expression="#{suspend.execute(execution.processInstanceId)}"/> - <sequenceFlow id="flow10" sourceRef="suspend" targetRef="suspended"/> - <userTask id="suspended" name="Suspended"/> - <sequenceFlow id="flow11" sourceRef="suspended" targetRef="suspendedGw"/> - <exclusiveGateway id="suspendedGw"/> - <sequenceFlow id="suspended2Reactivate" sourceRef="suspendedGw" targetRef="reactivate"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'reactivate'}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="suspended2Delete" sourceRef="suspendedGw" targetRef="delete"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'delete'}]]></conditionExpression> - </sequenceFlow> - <serviceTask id="reactivate" name="Reactivate" activiti:expression="#{reactivate.execute(execution.processInstanceId)}"/> - <sequenceFlow id="flow12" sourceRef="reactivate" targetRef="active"/> - - <serviceTask id="generateToken4PasswordReset" name="Generate Token" activiti:expression="#{generateToken.execute(execution.processInstanceId)}"/> - <sequenceFlow id="sid-7F78CE07-A7A1-467F-BB4B-40FB234AEFF7" sourceRef="generateToken4PasswordReset" targetRef="notify4RequestPasswordReset"/> - <serviceTask id="notify4RequestPasswordReset" name="Notification" activiti:expression="#{notify.execute(execution.processInstanceId)}"/> - <sequenceFlow id="sid-CF9ACA40-7750-47C3-A508-7250D24D4F1F" sourceRef="notify4RequestPasswordReset" targetRef="active"/> - - <serviceTask id="checkToken4ConfirmPasswordReset" name="Check token, remove and update password" activiti:expression="#{passwordReset.execute(execution.processInstanceId)}"/> - <sequenceFlow id="sid-3E9FE01D-CC60-4A95-B356-CA0DC000FAD6" sourceRef="checkToken4ConfirmPasswordReset" targetRef="notify4ConfirmPasswordReset"/> - <serviceTask id="notify4ConfirmPasswordReset" name="Notification" activiti:expression="#{notify.execute(execution.processInstanceId)}"/> - <sequenceFlow id="sid-A37806A7-6B7B-48A2-BB37-DAE640231144" sourceRef="notify4ConfirmPasswordReset" targetRef="active"/> - - <serviceTask id="delete" name="Delete" activiti:expression="#{delete.execute(execution.processInstanceId)}"/> - <sequenceFlow id="flow99" sourceRef="delete" targetRef="theEnd"/> - <!-- Recertification tasks --> - <userTask id="recertificationRequest" name="Recertification Request" activiti:formKey="recertify"> - <extensionElements> - <activiti:formProperty id="username" name="Username" type="string" expression="${user.username}" writable="false"/> - <activiti:formProperty id="approve" name="Recertify?" type="boolean" required="true"/> - <activiti:formProperty id="rejectReason" name="Reason for not recertifying" type="string" variable="rejectReason"/> - </extensionElements> - </userTask> - <serviceTask id="recertify-task" name="Recertify" activiti:expression="#{recertify.execute(execution.processInstanceId)}"/> - <sequenceFlow id="recert-request-start-flow" sourceRef="activeGw" targetRef="recertificationRequest"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${task == 'request-certify'}]]></conditionExpression> - </sequenceFlow> - <exclusiveGateway id="recert-condition"/> - <sequenceFlow id="recert-flow1" sourceRef="recertificationRequest" targetRef="recertify-task"/> - <sequenceFlow id="recert-flow2" sourceRef="recertify-task" targetRef="recert-condition"/> - <sequenceFlow id="recert-approved-flow" sourceRef="recert-condition" targetRef="active"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approve}]]></conditionExpression> - </sequenceFlow> - <sequenceFlow id="recert-denied-flow" sourceRef="recert-condition" targetRef="suspend"> - <conditionExpression xsi:type="tFormalExpression"><![CDATA[${!approve}]]></conditionExpression> - </sequenceFlow> - <!-- End Recertification flow --> - <endEvent id="theEnd"/> - </process> - - <bpmndi:BPMNDiagram id="BPMNDiagram_userWorkflow"> - <bpmndi:BPMNPlane bpmnElement="userWorkflow" id="BPMNPlane_userWorkflow"> - <bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart"> - <omgdc:Bounds height="35.0" width="35.0" x="540.0" y="521.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="create" id="BPMNShape_create"> - <omgdc:Bounds height="60.0" width="100.0" x="620.0" y="509.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="activate" id="BPMNShape_activate"> - <omgdc:Bounds height="80.0" width="100.0" x="828.0" y="500.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="active" id="BPMNShape_active"> - <omgdc:Bounds height="60.0" width="100.0" x="1030.0" y="511.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="activeGw" id="BPMNShape_activeGw"> - <omgdc:Bounds height="40.0" width="40.0" x="1400.0" y="520.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="update" id="BPMNShape_update"> - <omgdc:Bounds height="60.0" width="100.0" x="1370.0" y="615.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="suspend" id="BPMNShape_suspend"> - <omgdc:Bounds height="60.0" width="100.0" x="1490.0" y="370.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="suspended" id="BPMNShape_suspended"> - <omgdc:Bounds height="60.0" width="100.0" x="1640.0" y="370.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="suspendedGw" id="BPMNShape_suspendedGw"> - <omgdc:Bounds height="40.0" width="40.0" x="1820.0" y="380.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="reactivate" id="BPMNShape_reactivate"> - <omgdc:Bounds height="60.0" width="100.0" x="1940.0" y="290.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="generateToken4PasswordReset" id="BPMNShape_generateToken4PasswordReset"> - <omgdc:Bounds height="81.0" width="121.0" x="1515.0" y="604.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="notify4RequestPasswordReset" id="BPMNShape_notify4RequestPasswordReset"> - <omgdc:Bounds height="81.0" width="121.0" x="1515.0" y="750.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="checkToken4ConfirmPasswordReset" id="BPMNShape_checkToken4ConfirmPasswordReset"> - <omgdc:Bounds height="81.0" width="121.0" x="1725.0" y="664.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="notify4ConfirmPasswordReset" id="BPMNShape_notify4ConfirmPasswordReset"> - <omgdc:Bounds height="81.0" width="121.0" x="1725.0" y="810.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="delete" id="BPMNShape_delete"> - <omgdc:Bounds height="60.0" width="100.0" x="1940.0" y="438.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="recertificationRequest" id="BPMNShape_recertificationRequest"> - <omgdc:Bounds height="80.0" width="100.0" x="1370.0" y="375.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="recertify-task" id="BPMNShape_recertify-task"> - <omgdc:Bounds height="80.0" width="100.0" x="1230.0" y="375.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="recert-condition" id="BPMNShape_recert-condition"> - <omgdc:Bounds height="40.0" width="40.0" x="1178.0" y="475.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape bpmnElement="theEnd" id="BPMNShape_theEnd"> - <omgdc:Bounds height="35.0" width="35.0" x="2080.0" y="451.0"></omgdc:Bounds> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1"> - <omgdi:waypoint x="575.0" y="538.0"></omgdi:waypoint> - <omgdi:waypoint x="620.0" y="539.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> - <omgdi:waypoint x="720.0" y="539.0"></omgdi:waypoint> - <omgdi:waypoint x="828.0" y="540.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"> - <omgdi:waypoint x="928.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1030.0" y="541.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8"> - <omgdi:waypoint x="1130.0" y="541.0"></omgdi:waypoint> - <omgdi:waypoint x="1400.0" y="540.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="active2Update" id="BPMNEdge_active2Update"> - <omgdi:waypoint x="1420.0" y="560.0"></omgdi:waypoint> - <omgdi:waypoint x="1420.0" y="615.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="active2Suspend" id="BPMNEdge_active2Suspend"> - <omgdi:waypoint x="1440.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1540.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1540.0" y="430.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="active2Delete" id="BPMNEdge_active2Delete"> - <omgdi:waypoint x="1440.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1990.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1990.0" y="498.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="active2RequestPasswordReset" id="BPMNEdge_active2RequestPasswordReset"> - <omgdi:waypoint x="1440.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1575.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1575.0" y="604.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="active2ConfirmPasswordReset" id="BPMNEdge_active2ConfirmPasswordReset"> - <omgdi:waypoint x="1440.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1785.0" y="540.0"></omgdi:waypoint> - <omgdi:waypoint x="1785.0" y="664.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-EA22026A-25F0-4ED0-AB6E-9CE9CE74623C" id="BPMNEdge_sid-EA22026A-25F0-4ED0-AB6E-9CE9CE74623C"> - <omgdi:waypoint x="1370.0" y="645.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="645.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="571.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10"> - <omgdi:waypoint x="1590.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1640.0" y="400.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11"> - <omgdi:waypoint x="1740.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1820.0" y="400.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="suspended2Reactivate" id="BPMNEdge_suspended2Reactivate"> - <omgdi:waypoint x="1860.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1902.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1902.0" y="320.0"></omgdi:waypoint> - <omgdi:waypoint x="1940.0" y="320.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="suspended2Delete" id="BPMNEdge_suspended2Delete"> - <omgdi:waypoint x="1860.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1990.0" y="400.0"></omgdi:waypoint> - <omgdi:waypoint x="1990.0" y="438.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12"> - <omgdi:waypoint x="1990.0" y="290.0"></omgdi:waypoint> - <omgdi:waypoint x="1990.0" y="261.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="261.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="511.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-7F78CE07-A7A1-467F-BB4B-40FB234AEFF7" id="BPMNEdge_sid-7F78CE07-A7A1-467F-BB4B-40FB234AEFF7"> - <omgdi:waypoint x="1575.0" y="685.0"></omgdi:waypoint> - <omgdi:waypoint x="1575.0" y="750.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-CF9ACA40-7750-47C3-A508-7250D24D4F1F" id="BPMNEdge_sid-CF9ACA40-7750-47C3-A508-7250D24D4F1F"> - <omgdi:waypoint x="1515.0" y="790.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="790.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="571.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-3E9FE01D-CC60-4A95-B356-CA0DC000FAD6" id="BPMNEdge_sid-3E9FE01D-CC60-4A95-B356-CA0DC000FAD6"> - <omgdi:waypoint x="1785.0" y="745.0"></omgdi:waypoint> - <omgdi:waypoint x="1785.0" y="810.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="sid-A37806A7-6B7B-48A2-BB37-DAE640231144" id="BPMNEdge_sid-A37806A7-6B7B-48A2-BB37-DAE640231144"> - <omgdi:waypoint x="1725.0" y="850.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="850.0"></omgdi:waypoint> - <omgdi:waypoint x="1080.0" y="571.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="flow99" id="BPMNEdge_flow99"> - <omgdi:waypoint x="2040.0" y="468.0"></omgdi:waypoint> - <omgdi:waypoint x="2080.0" y="468.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="recert-request-start-flow" id="BPMNEdge_recert-request-start-flow"> - <omgdi:waypoint x="1420.0" y="520.0"></omgdi:waypoint> - <omgdi:waypoint x="1420.0" y="455.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="recert-flow1" id="BPMNEdge_recert-flow1"> - <omgdi:waypoint x="1370.0" y="415.0"></omgdi:waypoint> - <omgdi:waypoint x="1330.0" y="415.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="recert-flow2" id="BPMNEdge_recert-flow2"> - <omgdi:waypoint x="1280.0" y="455.0"></omgdi:waypoint> - <omgdi:waypoint x="1280.0" y="495.0"></omgdi:waypoint> - <omgdi:waypoint x="1218.0" y="495.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="recert-approved-flow" id="BPMNEdge_recert-approved-flow"> - <omgdi:waypoint x="1198.0" y="515.0"></omgdi:waypoint> - <omgdi:waypoint x="1194.0" y="541.0"></omgdi:waypoint> - <omgdi:waypoint x="1130.0" y="541.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge bpmnElement="recert-denied-flow" id="BPMNEdge_recert-denied-flow"> - <omgdi:waypoint x="1198.0" y="475.0"></omgdi:waypoint> - <omgdi:waypoint x="1198.0" y="313.0"></omgdi:waypoint> - <omgdi:waypoint x="1540.0" y="313.0"></omgdi:waypoint> - <omgdi:waypoint x="1540.0" y="370.0"></omgdi:waypoint> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</definitions> http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/resources/workflow.properties ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/resources/workflow.properties b/core/workflow-activiti/src/main/resources/workflow.properties deleted file mode 100644 index 771b11c..0000000 --- a/core/workflow-activiti/src/main/resources/workflow.properties +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -wf.directory=${conf.directory} -historyLevel=activity -jobExecutorActivate=true -uwfAdapter=org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter -gwfAdapter=org.apache.syncope.core.workflow.java.DefaultGroupWorkflowAdapter -awfAdapter=org.apache.syncope.core.workflow.java.DefaultAnyObjectWorkflowAdapter http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml ---------------------------------------------------------------------- diff --git a/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml b/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml deleted file mode 100644 index 78c625e..0000000 --- a/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context.xsd"> - - <bean id="userWorkflowDef" class="org.apache.syncope.core.spring.ResourceWithFallbackLoader"> - <property name="primary" value="file:${wf.directory}/userWorkflow.bpmn20.xml"/> - <property name="fallback" value="classpath:userWorkflow.bpmn20.xml"/> - </bean> - - <bean id="activitiUtils" class="org.apache.syncope.core.workflow.activiti.ActivitiUtils"/> - - <bean id="syncopeActivitiUserManager" class="org.apache.syncope.core.workflow.activiti.SyncopeUserManager"/> - <bean id="syncopeActivitiGroupManager" class="org.apache.syncope.core.workflow.activiti.SyncopeGroupManager"/> - - <bean class="org.activiti.spring.SpringProcessEngineConfiguration" scope="prototype"> - <property name="transactionsExternallyManaged" value="true"/> - <property name="databaseSchemaUpdate" value="true"/> - - <property name="jpaHandleTransaction" value="true"/> - <property name="jpaCloseEntityManager" value="false"/> - - <property name="history" value="${historyLevel}"/> - <property name="jobExecutorActivate" value="${jobExecutorActivate}"/> - - <property name="customSessionFactories"> - <list> - <bean class="org.apache.syncope.core.workflow.activiti.SyncopeSessionFactory"> - <property name="syncopeSession" ref="syncopeActivitiUserManager"/> - </bean> - <bean class="org.apache.syncope.core.workflow.activiti.SyncopeSessionFactory"> - <property name="syncopeSession" ref="syncopeActivitiGroupManager"/> - </bean> - </list> - </property> - <property name="customPreVariableTypes"> - <list> - <bean class="org.apache.syncope.core.workflow.activiti.SyncopeEntitiesVariableType"/> - </list> - </property> - </bean> - - <bean class="org.apache.syncope.core.workflow.activiti.spring.DomainProcessEngineFactoryBean"/> - - <context:component-scan base-package="org.apache.syncope.core.workflow.activiti"/> - -</beans> http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-flowable/pom.xml ---------------------------------------------------------------------- diff --git a/core/workflow-flowable/pom.xml b/core/workflow-flowable/pom.xml new file mode 100644 index 0000000..8346c9d --- /dev/null +++ b/core/workflow-flowable/pom.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.syncope</groupId> + <artifactId>syncope-core</artifactId> + <version>2.1.0-SNAPSHOT</version> + </parent> + + <name>Apache Syncope Core Workflow Flowable</name> + <description>Apache Syncope Core Workflow Flowable</description> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-workflow-flowable</artifactId> + <packaging>jar</packaging> + + <properties> + <rootpom.basedir>${basedir}/../..</rootpom.basedir> + </properties> + + <dependencies> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-email</artifactId> + </dependency> + <dependency> + <groupId>org.apache.geronimo.javamail</groupId> + <artifactId>geronimo-javamail_1.4_mail</artifactId> + </dependency> + + <dependency> + <groupId>org.flowable</groupId> + <artifactId>flowable-engine</artifactId> + </dependency> + <dependency> + <groupId>org.flowable</groupId> + <artifactId>flowable-spring</artifactId> + </dependency> + <dependency> + <groupId>org.flowable</groupId> + <artifactId>flowable-json-converter</artifactId> + </dependency> + + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-all</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.syncope.core</groupId> + <artifactId>syncope-core-workflow-java</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDefinitionLoader.java ---------------------------------------------------------------------- diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDefinitionLoader.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDefinitionLoader.java new file mode 100644 index 0000000..a387c30 --- /dev/null +++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDefinitionLoader.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.workflow.flowable; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import javax.annotation.Resource; +import org.activiti.engine.ProcessEngine; +import org.activiti.engine.repository.ProcessDefinition; +import org.activiti.spring.SpringProcessEngineConfiguration; +import org.apache.commons.io.IOUtils; +import org.apache.syncope.core.spring.ResourceWithFallbackLoader; +import org.apache.syncope.core.persistence.api.SyncopeLoader; +import org.apache.syncope.core.workflow.flowable.spring.DomainProcessEngine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class FlowableDefinitionLoader implements SyncopeLoader { + + private static final Logger LOG = LoggerFactory.getLogger(FlowableDefinitionLoader.class); + + @Resource(name = "userWorkflowDef") + private ResourceWithFallbackLoader userWorkflowDef; + + @Autowired + private DomainProcessEngine dpEngine; + + @Override + public Integer getPriority() { + return Integer.MIN_VALUE; + } + + @Override + public void load() { + byte[] wfDef = new byte[0]; + + InputStream wfIn = null; + try { + wfIn = userWorkflowDef.getResource().getInputStream(); + wfDef = IOUtils.toByteArray(wfIn); + } catch (IOException e) { + LOG.error("While loading " + userWorkflowDef.getResource().getFilename(), e); + } finally { + IOUtils.closeQuietly(wfIn); + } + + for (Map.Entry<String, ProcessEngine> entry : dpEngine.getEngines().entrySet()) { + List<ProcessDefinition> processes = entry.getValue().getRepositoryService(). + createProcessDefinitionQuery().processDefinitionKey(FlowableUserWorkflowAdapter.WF_PROCESS_ID). + list(); + LOG.debug(FlowableUserWorkflowAdapter.WF_PROCESS_ID + " Flowable processes in repository: {}", processes); + + // Only loads process definition from file if not found in repository + if (processes.isEmpty()) { + entry.getValue().getRepositoryService().createDeployment().addInputStream( + userWorkflowDef.getResource().getFilename(), new ByteArrayInputStream(wfDef)).deploy(); + + ProcessDefinition procDef = entry.getValue().getRepositoryService().createProcessDefinitionQuery(). + processDefinitionKey(FlowableUserWorkflowAdapter.WF_PROCESS_ID).latestVersion(). + singleResult(); + + FlowableDeployUtils.deployModel(entry.getValue(), procDef); + + LOG.debug("Flowable Workflow definition loaded for domain {}", entry.getKey()); + } + + // jump to the next ID block + for (int i = 0; i < entry.getValue().getProcessEngineConfiguration().getIdBlockSize(); i++) { + SpringProcessEngineConfiguration.class.cast(entry.getValue().getProcessEngineConfiguration()). + getIdGenerator().getNextId(); + } + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/7098ca9f/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDeployUtils.java ---------------------------------------------------------------------- diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDeployUtils.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDeployUtils.java new file mode 100644 index 0000000..4d28cd2 --- /dev/null +++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDeployUtils.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.workflow.flowable; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import org.activiti.bpmn.converter.BpmnXMLConverter; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.editor.constants.ModelDataJsonConstants; +import org.activiti.editor.language.json.converter.BpmnJsonConverter; +import org.activiti.engine.ActivitiException; +import org.activiti.engine.ProcessEngine; +import org.activiti.engine.repository.Deployment; +import org.activiti.engine.repository.Model; +import org.activiti.engine.repository.ProcessDefinition; +import org.apache.commons.io.IOUtils; +import org.apache.syncope.core.workflow.api.WorkflowException; + +public final class FlowableDeployUtils { + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + + public static Deployment deployDefinition( + final ProcessEngine engine, final String resourceName, final byte[] definition) { + + try { + return engine.getRepositoryService().createDeployment(). + addInputStream(resourceName, new ByteArrayInputStream(definition)).deploy(); + } catch (ActivitiException e) { + throw new WorkflowException("While importing " + resourceName, e); + } + } + + public static void deployModel(final ProcessEngine engine, final ProcessDefinition procDef) { + InputStream bpmnStream = null; + InputStreamReader isr = null; + XMLStreamReader xtr = null; + try { + bpmnStream = engine.getRepositoryService().getResourceAsStream( + procDef.getDeploymentId(), procDef.getResourceName()); + isr = new InputStreamReader(bpmnStream); + xtr = XMLInputFactory.newInstance().createXMLStreamReader(isr); + BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); + + Model model = engine.getRepositoryService().newModel(); + ObjectNode modelObjectNode = OBJECT_MAPPER.createObjectNode(); + modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, procDef.getName()); + model.setMetaInfo(modelObjectNode.toString()); + model.setName(procDef.getName()); + model.setDeploymentId(procDef.getDeploymentId()); + model.setVersion(procDef.getVersion()); + + engine.getRepositoryService().saveModel(model); + engine.getRepositoryService().addModelEditorSource( + model.getId(), + new BpmnJsonConverter().convertToJson(bpmnModel).toString().getBytes()); + } catch (Exception e) { + throw new WorkflowException("While importing " + procDef.getResourceName(), e); + } finally { + if (xtr != null) { + try { + xtr.close(); + } catch (XMLStreamException e) { + // ignore + } + } + IOUtils.closeQuietly(isr); + IOUtils.closeQuietly(bpmnStream); + } + } + + private FlowableDeployUtils() { + // private constructor for static utility class + } +}