You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/04/05 14:39:25 UTC
[1/3] syncope git commit: [SYNCOPE-1055] Provide
core/workflow-flowable,
based on core/workflow-activiti + support for Flowable Modeler in Admin
Console
Repository: syncope
Updated Branches:
refs/heads/2_0_X 911009b9e -> 85ddca5ba
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Notify.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Notify.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Notify.java
new file mode 100644
index 0000000..687424e
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Notify.java
@@ -0,0 +1,65 @@
+/*
+ * 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.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.flowable.FlowableUserWorkflowAdapter;
+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 AbstractFlowableServiceTask {
+
+ @Autowired
+ private NotificationManager notificationManager;
+
+ @Override
+ protected void doExecute(final String executionId) {
+ User user = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
+ UserTO userTO = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, UserTO.class);
+ String event = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.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/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/PasswordReset.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/PasswordReset.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/PasswordReset.java
new file mode 100644
index 0000000..61d9d17
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/PasswordReset.java
@@ -0,0 +1,73 @@
+/*
+ * 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.task;
+
+import org.apache.commons.collections4.CollectionUtils;
+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.provisioning.api.utils.EntityUtils;
+import org.apache.syncope.core.workflow.api.WorkflowException;
+import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class PasswordReset extends AbstractFlowableServiceTask {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private UserDataBinder dataBinder;
+
+ @Override
+ protected void doExecute(final String executionId) {
+ User user = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
+ String token = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.TOKEN, String.class);
+ String password = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.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(CollectionUtils.collect(userDAO.findAllResources(user), EntityUtils.keyTransformer())).
+ value(password).build());
+
+ PropagationByResource propByRes = dataBinder.update(user, userPatch);
+
+ // report updated user and propagation by resource as result
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Reactivate.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Reactivate.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Reactivate.java
new file mode 100644
index 0000000..0052b5a
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Reactivate.java
@@ -0,0 +1,29 @@
+/*
+ * 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.task;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class Reactivate extends AbstractFlowableServiceTask {
+
+ @Override
+ protected void doExecute(final String executionId) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Recertify.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Recertify.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Recertify.java
new file mode 100644
index 0000000..6099e0c
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Recertify.java
@@ -0,0 +1,58 @@
+/*
+ * 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.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.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Recertify extends AbstractFlowableServiceTask {
+
+ @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, FlowableUserWorkflowAdapter.USER, User.class);
+ String submitter = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.FORM_SUBMITTER, String.class);
+
+ LOG.debug("Saving Recertification information for user {}", user.getUsername());
+
+ user.setLastRecertificator(submitter);
+ user.setLastRecertification(new Date(System.currentTimeMillis()));
+
+ userDAO.save(user);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Suspend.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Suspend.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Suspend.java
new file mode 100644
index 0000000..189d619
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Suspend.java
@@ -0,0 +1,29 @@
+/*
+ * 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.task;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class Suspend extends AbstractFlowableServiceTask {
+
+ @Override
+ protected void doExecute(final String executionId) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Update.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Update.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Update.java
new file mode 100644
index 0000000..7f5d9d2
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Update.java
@@ -0,0 +1,49 @@
+/*
+ * 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.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.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Update extends AbstractFlowableServiceTask {
+
+ @Autowired
+ private UserDataBinder dataBinder;
+
+ @Override
+ protected void doExecute(final String executionId) {
+ User user = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
+ UserPatch userPatch = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, UserPatch.class);
+
+ PropagationByResource propByRes = dataBinder.update(user, userPatch);
+
+ // report updated user and propagation by resource as result
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/resources/userWorkflow.bpmn20.xml
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/resources/userWorkflow.bpmn20.xml b/core/workflow-flowable/src/main/resources/userWorkflow.bpmn20.xml
new file mode 100644
index 0000000..20690f3
--- /dev/null
+++ b/core/workflow-flowable/src/main/resources/userWorkflow.bpmn20.xml
@@ -0,0 +1,287 @@
+<?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:flowable="http://flowable.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://www.flowable.org/processdef">
+
+ <process id="userWorkflow" name="User Workflow" isExecutable="true">
+ <startEvent id="theStart"/>
+ <sequenceFlow id="flow1" sourceRef="theStart" targetRef="create"/>
+ <serviceTask id="create" name="Create" flowable:expression="#{create.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="flow2" sourceRef="create" targetRef="activate"/>
+ <scriptTask id="activate" name="Activate" scriptFormat="groovy" flowable: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" flowable:expression="#{update.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="sid-EA22026A-25F0-4ED0-AB6E-9CE9CE74623C" sourceRef="update" targetRef="active"/>
+ <serviceTask id="suspend" name="Suspend" flowable: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" flowable:expression="#{reactivate.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="flow12" sourceRef="reactivate" targetRef="active"/>
+
+ <serviceTask id="generateToken4PasswordReset" name="Generate Token" flowable:expression="#{generateToken.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="sid-7F78CE07-A7A1-467F-BB4B-40FB234AEFF7" sourceRef="generateToken4PasswordReset" targetRef="notify4RequestPasswordReset"/>
+ <serviceTask id="notify4RequestPasswordReset" name="Notification" flowable: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" flowable:expression="#{passwordReset.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="sid-3E9FE01D-CC60-4A95-B356-CA0DC000FAD6" sourceRef="checkToken4ConfirmPasswordReset" targetRef="notify4ConfirmPasswordReset"/>
+ <serviceTask id="notify4ConfirmPasswordReset" name="Notification" flowable:expression="#{notify.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="sid-A37806A7-6B7B-48A2-BB37-DAE640231144" sourceRef="notify4ConfirmPasswordReset" targetRef="active"/>
+
+ <serviceTask id="delete" name="Delete" flowable:expression="#{delete.execute(execution.processInstanceId)}"/>
+ <sequenceFlow id="flow99" sourceRef="delete" targetRef="theEnd"/>
+ <!-- Recertification tasks -->
+ <userTask id="recertificationRequest" name="Recertification Request" flowable:formKey="recertify">
+ <extensionElements>
+ <flowable:formProperty id="username" name="Username" type="string" expression="${user.username}" writable="false"/>
+ <flowable:formProperty id="approve" name="Recertify?" type="boolean" required="true"/>
+ <flowable:formProperty id="rejectReason" name="Reason for not recertifying" type="string" variable="rejectReason"/>
+ </extensionElements>
+ </userTask>
+ <serviceTask id="recertify-task" name="Recertify" flowable: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/85ddca5b/core/workflow-flowable/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/resources/workflow.properties b/core/workflow-flowable/src/main/resources/workflow.properties
new file mode 100644
index 0000000..50c42fc
--- /dev/null
+++ b/core/workflow-flowable/src/main/resources/workflow.properties
@@ -0,0 +1,22 @@
+# 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.flowable.FlowableUserWorkflowAdapter
+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/85ddca5b/core/workflow-flowable/src/main/resources/workflowFlowableContext.xml
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/resources/workflowFlowableContext.xml b/core/workflow-flowable/src/main/resources/workflowFlowableContext.xml
new file mode 100644
index 0000000..517b8d7
--- /dev/null
+++ b/core/workflow-flowable/src/main/resources/workflowFlowableContext.xml
@@ -0,0 +1,69 @@
+<?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="flowableUtils" class="org.apache.syncope.core.workflow.flowable.FlowableUtils"/>
+
+ <bean id="syncopeFlowableUserManager" class="org.apache.syncope.core.workflow.flowable.SyncopeUserManager"/>
+ <bean id="syncopeFlowableGroupManager" class="org.apache.syncope.core.workflow.flowable.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.flowable.SyncopeSessionFactory">
+ <property name="syncopeSession" ref="syncopeFlowableUserManager"/>
+ </bean>
+ <bean class="org.apache.syncope.core.workflow.flowable.SyncopeSessionFactory">
+ <property name="syncopeSession" ref="syncopeFlowableGroupManager"/>
+ </bean>
+ </list>
+ </property>
+ <property name="customPreVariableTypes">
+ <list>
+ <bean class="org.apache.syncope.core.workflow.flowable.SyncopeEntitiesVariableType"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean class="org.apache.syncope.core.workflow.flowable.spring.DomainProcessEngineFactoryBean"/>
+
+ <context:component-scan base-package="org.apache.syncope.core.workflow.flowable"/>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultAnyObjectWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultAnyObjectWorkflowAdapter.java b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultAnyObjectWorkflowAdapter.java
index 3994923..90bf7e0 100644
--- a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultAnyObjectWorkflowAdapter.java
+++ b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultAnyObjectWorkflowAdapter.java
@@ -37,6 +37,11 @@ import org.apache.syncope.core.workflow.api.WorkflowException;
public class DefaultAnyObjectWorkflowAdapter extends AbstractAnyObjectWorkflowAdapter {
@Override
+ public boolean supportsDefinitionEdit() {
+ return false;
+ }
+
+ @Override
public WorkflowResult<String> create(final AnyObjectTO anyObjectTO) {
AnyObject anyObject = entityFactory.newEntity(AnyObject.class);
dataBinder.create(anyObject, anyObjectTO);
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultGroupWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultGroupWorkflowAdapter.java b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultGroupWorkflowAdapter.java
index 6b557d6..6036700 100644
--- a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultGroupWorkflowAdapter.java
+++ b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultGroupWorkflowAdapter.java
@@ -37,6 +37,11 @@ import org.apache.syncope.core.workflow.api.WorkflowException;
public class DefaultGroupWorkflowAdapter extends AbstractGroupWorkflowAdapter {
@Override
+ public boolean supportsDefinitionEdit() {
+ return false;
+ }
+
+ @Override
public WorkflowResult<String> create(final GroupTO groupTO) {
Group group = entityFactory.newEntity(Group.class);
dataBinder.create(group, groupTO);
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultUserWorkflowAdapter.java b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultUserWorkflowAdapter.java
index ff8bc45..f4fd4ca 100644
--- a/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultUserWorkflowAdapter.java
+++ b/core/workflow-java/src/main/java/org/apache/syncope/core/workflow/java/DefaultUserWorkflowAdapter.java
@@ -47,6 +47,11 @@ public class DefaultUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
private ConfDAO confDAO;
@Override
+ public boolean supportsDefinitionEdit() {
+ return false;
+ }
+
+ @Override
public WorkflowResult<Pair<String, Boolean>> create(final UserTO userTO, final boolean storePassword) {
return create(userTO, false, true);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/fit/console-reference/src/main/resources/console.properties
----------------------------------------------------------------------
diff --git a/fit/console-reference/src/main/resources/console.properties b/fit/console-reference/src/main/resources/console.properties
index 00834e6..3dbfac7 100644
--- a/fit/console-reference/src/main/resources/console.properties
+++ b/fit/console-reference/src/main/resources/console.properties
@@ -29,6 +29,7 @@ rootPath=/syncope/rest/
useGZIPCompression=true
activitiModelerDirectory=${activiti-modeler.directory}
+flowableModelerDirectory=${flowable-modeler.directory}
reconciliationReportKey=c3520ad9-179f-49e7-b315-d684d216dd97
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/fit/core-reference/src/test/resources/console.properties
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/resources/console.properties b/fit/core-reference/src/test/resources/console.properties
index 00834e6..3dbfac7 100644
--- a/fit/core-reference/src/test/resources/console.properties
+++ b/fit/core-reference/src/test/resources/console.properties
@@ -29,6 +29,7 @@ rootPath=/syncope/rest/
useGZIPCompression=true
activitiModelerDirectory=${activiti-modeler.directory}
+flowableModelerDirectory=${flowable-modeler.directory}
reconciliationReportKey=c3520ad9-179f-49e7-b315-d684d216dd97
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 805be1c..557faa0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -377,6 +377,7 @@ under the License.
<groovy.version>2.4.10</groovy.version>
<activiti.version>5.22.0</activiti.version>
+ <flowable.version>5.23.0</flowable.version>
<camel.version>2.17.6</camel.version>
@@ -403,6 +404,7 @@ under the License.
<connid.location>file:${bundles.directory}/</connid.location>
<log.directory>${project.build.directory}/log</log.directory>
<activiti-modeler.directory>${project.build.directory}/activiti-modeler</activiti-modeler.directory>
+ <flowable-modeler.directory>${project.build.directory}/flowable-modeler</flowable-modeler.directory>
<swagger-core.version>1.5.12</swagger-core.version>
<swagger-ui.version>2.2.10</swagger-ui.version>
@@ -572,10 +574,10 @@ under the License.
<version>${cxf.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-security-sso-saml</artifactId>
- <version>${cxf.version}</version>
- <exclusions>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-security-sso-saml</artifactId>
+ <version>${cxf.version}</version>
+ <exclusions>
<exclusion>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-xacml-impl</artifactId>
@@ -584,26 +586,26 @@ under the License.
<groupId>org.opensaml</groupId>
<artifactId>opensaml-xacml-saml-impl</artifactId>
</exclusion>
- <exclusion>
+ <exclusion>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-dom</artifactId>
- </exclusion>
- </exclusions>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
- <groupId>org.apache.wss4j</groupId>
+ <groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-dom</artifactId>
- <version>2.1.9</version>
- <exclusions>
- <exclusion>
- <groupId>org.jasypt</groupId>
- <artifactId>jasypt</artifactId>
- </exclusion>
+ <version>2.1.9</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
</exclusion>
- </exclusions>
+ </exclusions>
</dependency>
<!-- /CXF -->
@@ -1047,6 +1049,54 @@ under the License.
</dependency>
<!-- /Activiti -->
+ <!-- Flowable -->
+ <dependency>
+ <groupId>org.flowable</groupId>
+ <artifactId>flowable-engine</artifactId>
+ <version>${flowable.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.flowable</groupId>
+ <artifactId>flowable-spring</artifactId>
+ <version>${flowable.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.flowable</groupId>
+ <artifactId>flowable-json-converter</artifactId>
+ <version>${flowable.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.flowable</groupId>
+ <artifactId>flowable-webapp-explorer2</artifactId>
+ <version>${flowable.version}</version>
+ <type>war</type>
+ </dependency>
+ <!-- /Flowable -->
+
<!-- Wicket -->
<dependency>
<groupId>org.apache.wicket</groupId>
[3/3] syncope git commit: [SYNCOPE-1055] Provide
core/workflow-flowable,
based on core/workflow-activiti + support for Flowable Modeler in Admin
Console
Posted by il...@apache.org.
[SYNCOPE-1055] Provide core/workflow-flowable, based on core/workflow-activiti + support for Flowable Modeler in Admin Console
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/85ddca5b
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/85ddca5b
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/85ddca5b
Branch: refs/heads/2_0_X
Commit: 85ddca5baee06a8a47154f32179ca921177d0f6a
Parents: 911009b
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Tue Apr 4 08:41:51 2017 +0200
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Wed Apr 5 16:36:36 2017 +0200
----------------------------------------------------------------------
archetype/pom.xml | 1 +
.../archetype-resources/console/pom.xml | 151 ++--
.../console/SyncopeConsoleApplication.java | 42 +-
.../client/console/commons/Constants.java | 6 +
.../console/pages/ActivitiModelerPopupPage.java | 27 -
.../syncope/client/console/pages/BasePage.java | 3 +-
.../client/console/pages/ModelerPopupPage.java | 41 +
.../syncope/client/console/pages/Workflow.java | 16 +-
.../console/panels/WorkflowTogglePanel.java | 39 +-
.../resources/WorkflowDefGETResource.java | 2 +-
.../resources/WorkflowDefPUTResource.java | 2 +-
.../src/main/resources/console.properties | 1 +
.../console/pages/ActivitiModelerPopupPage.html | 28 -
.../client/console/pages/ModelerPopupPage.html | 28 +
.../syncope/client/console/pages/Workflow.html | 2 +-
.../client/console/pages/Workflow.properties | 2 +-
.../client/console/pages/Workflow_it.properties | 2 +-
.../console/pages/Workflow_pt_BR.properties | 2 +-
.../client/console/pages/Workflow_ru.properties | 6 +-
.../console/panels/WorkflowTogglePanel.html | 4 +-
.../client/enduser/resources/BaseResource.java | 2 +-
.../syncope/common/lib/info/PlatformInfo.java | 30 +
.../apache/syncope/core/logic/SyncopeLogic.java | 3 +
core/pom.xml | 1 +
.../activiti/ActivitiUserWorkflowAdapter.java | 5 +
.../core/workflow/api/WorkflowAdapter.java | 5 +
core/workflow-flowable/pom.xml | 92 ++
.../flowable/FlowableDefinitionLoader.java | 108 +++
.../workflow/flowable/FlowableImportUtils.java | 93 ++
.../flowable/FlowableUserWorkflowAdapter.java | 887 +++++++++++++++++++
.../core/workflow/flowable/FlowableUtils.java | 39 +
.../flowable/SyncopeEntitiesVariableType.java | 35 +
.../workflow/flowable/SyncopeGroupManager.java | 122 +++
.../flowable/SyncopeGroupQueryImpl.java | 163 ++++
.../core/workflow/flowable/SyncopeSession.java | 26 +
.../flowable/SyncopeSessionFactory.java | 45 +
.../workflow/flowable/SyncopeUserManager.java | 166 ++++
.../workflow/flowable/SyncopeUserQueryImpl.java | 211 +++++
.../flowable/spring/DomainProcessEngine.java | 114 +++
.../spring/DomainProcessEngineFactoryBean.java | 104 +++
.../task/AbstractFlowableServiceTask.java | 45 +
.../workflow/flowable/task/AutoActivate.java | 31 +
.../core/workflow/flowable/task/Create.java | 52 ++
.../core/workflow/flowable/task/Delete.java | 41 +
.../workflow/flowable/task/GenerateToken.java | 44 +
.../core/workflow/flowable/task/Notify.java | 65 ++
.../workflow/flowable/task/PasswordReset.java | 73 ++
.../core/workflow/flowable/task/Reactivate.java | 29 +
.../core/workflow/flowable/task/Recertify.java | 58 ++
.../core/workflow/flowable/task/Suspend.java | 29 +
.../core/workflow/flowable/task/Update.java | 49 +
.../src/main/resources/userWorkflow.bpmn20.xml | 287 ++++++
.../src/main/resources/workflow.properties | 22 +
.../main/resources/workflowFlowableContext.xml | 69 ++
.../java/DefaultAnyObjectWorkflowAdapter.java | 5 +
.../java/DefaultGroupWorkflowAdapter.java | 5 +
.../java/DefaultUserWorkflowAdapter.java | 5 +
.../src/main/resources/console.properties | 1 +
.../src/test/resources/console.properties | 1 +
pom.xml | 80 +-
60 files changed, 3458 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/archetype/pom.xml
----------------------------------------------------------------------
diff --git a/archetype/pom.xml b/archetype/pom.xml
index d90e125..49e8ef7 100644
--- a/archetype/pom.xml
+++ b/archetype/pom.xml
@@ -184,6 +184,7 @@ under the License.
<targetPath>${project.build.outputDirectory}/archetype-resources/core/src/test/resources</targetPath>
<includes>
<include>connid.properties</include>
+ <include>userWorkflow.bpmn20.xml</include>
</includes>
</resource>
<resource>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/archetype/src/main/resources/archetype-resources/console/pom.xml
----------------------------------------------------------------------
diff --git a/archetype/src/main/resources/archetype-resources/console/pom.xml b/archetype/src/main/resources/archetype-resources/console/pom.xml
index 111e262..de7130e 100644
--- a/archetype/src/main/resources/archetype-resources/console/pom.xml
+++ b/archetype/src/main/resources/archetype-resources/console/pom.xml
@@ -103,80 +103,11 @@ under the License.
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.activiti</groupId>
- <artifactId>activiti-webapp-explorer2</artifactId>
- <type>war</type>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<finalName>syncope-console</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <inherited>true</inherited>
- <executions>
- <execution>
- <id>setupActivitiModeler</id>
- <phase>process-resources</phase>
- <configuration>
- <target>
- <unzip src="${settings.localRepository}/org/activiti/activiti-webapp-explorer2/${activiti.version}/activiti-webapp-explorer2-${activiti.version}.war"
- dest="${project.build.directory}/activiti-webapp-explorer2" />
-
- <mkdir dir="${activiti-modeler.directory}" />
- <copy file="${project.build.directory}/activiti-webapp-explorer2/modeler.html"
- todir="${activiti-modeler.directory}" />
- <replace file="${activiti-modeler.directory}/modeler.html"
- token="</head>"
- value="<script type="text/javascript">window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); }</script></head>"/>
- <copy file="${project.build.directory}/activiti-webapp-explorer2/WEB-INF/classes/stencilset.json"
- todir="${activiti-modeler.directory}" />
-
- <mkdir dir="${activiti-modeler.directory}/editor-app" />
- <copy todir="${activiti-modeler.directory}/editor-app">
- <fileset dir="${project.build.directory}/activiti-webapp-explorer2/editor-app" />
- </copy>
- <replaceregexp file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
- match="ORYX.CONFIG.ROOT_PATH =.*"editor/"; //TODO: Remove last slash!!"
- replace="BASE_PATH = window.location.toString().substr(0, window.location.toString().indexOf('/wicket'));
-ORYX.CONFIG.ROOT_PATH = BASE_PATH + "/activiti-modeler/editor-app/editor/";"
- byline="true"/>
- <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
- token="new Ajax.Request(ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now(), {"
- value="new Ajax.Request(window.location.toString().substr(0, window.location.toString().indexOf('/activiti-modeler')) + "/activiti-modeler/stencilset.json", {"/>
- <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
- token="ORYX.Editor.createByUrl(modelUrl);"
- value="modelUrl = BASE_PATH + "/workflowDefGET";
-ORYX.Editor.createByUrl(modelUrl);"/>
- <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
- token="ORYX.Editor.createByUrl = function(modelUrl){"
- value="modelUrl = BASE_PATH + "/workflowDefGET";
-ORYX.Editor.createByUrl = function(modelUrl){"/>
- <replace file="${activiti-modeler.directory}/editor-app/configuration/toolbar-default-actions.js"
- token="window.location.href = "./";"
- value="window.close();"/>
-
- <copy file="${basedir}/src/main/resources/url-config.js"
- todir="${activiti-modeler.directory}/editor-app/configuration"
- overwrite="true" />
- <copy file="${basedir}/src/main/resources/save-model.html"
- todir="${activiti-modeler.directory}/editor-app/popups"
- overwrite="true" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -192,7 +123,7 @@ ORYX.Editor.createByUrl = function(modelUrl){"/>
</testResources>
</build>
- <profiles>
+ <profiles>
<profile>
<id>all</id>
@@ -203,14 +134,84 @@ ORYX.Editor.createByUrl = function(modelUrl){"/>
<version>${syncope.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.syncope.ext.saml2sp</groupId>
- <artifactId>syncope-ext-saml2sp-client-console</artifactId>
- <version>${syncope.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.syncope.ext.saml2sp</groupId>
+ <artifactId>syncope-ext-saml2sp-client-console</artifactId>
+ <version>${syncope.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.activiti</groupId>
+ <artifactId>activiti-webapp-explorer2</artifactId>
+ <type>war</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>setupActivitiModeler</id>
+ <phase>process-resources</phase>
+ <configuration>
+ <target>
+ <unzip src="${settings.localRepository}/org/activiti/activiti-webapp-explorer2/${activiti.version}/activiti-webapp-explorer2-${activiti.version}.war"
+ dest="${project.build.directory}/activiti-webapp-explorer2" />
+
+ <mkdir dir="${activiti-modeler.directory}" />
+ <copy file="${project.build.directory}/activiti-webapp-explorer2/modeler.html"
+ todir="${activiti-modeler.directory}" />
+ <replace file="${activiti-modeler.directory}/modeler.html"
+ token="</head>"
+ value="<script type="text/javascript">window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); }</script></head>"/>
+ <copy file="${project.build.directory}/activiti-webapp-explorer2/WEB-INF/classes/stencilset.json"
+ todir="${activiti-modeler.directory}" />
+
+ <mkdir dir="${activiti-modeler.directory}/editor-app" />
+ <copy todir="${activiti-modeler.directory}/editor-app">
+ <fileset dir="${project.build.directory}/activiti-webapp-explorer2/editor-app" />
+ </copy>
+ <replaceregexp file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
+ match="ORYX.CONFIG.ROOT_PATH =.*"editor/"; //TODO: Remove last slash!!"
+ replace="BASE_PATH = window.location.toString().substr(0, window.location.toString().indexOf('/wicket'));
+ORYX.CONFIG.ROOT_PATH = BASE_PATH + "/activiti-modeler/editor-app/editor/";"
+ byline="true"/>
+ <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
+ token="new Ajax.Request(ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now(), {"
+ value="new Ajax.Request(window.location.toString().substr(0, window.location.toString().indexOf('/activiti-modeler')) + "/activiti-modeler/stencilset.json", {"/>
+ <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
+ token="ORYX.Editor.createByUrl(modelUrl);"
+ value="modelUrl = BASE_PATH + "/workflowDefGET";
+ORYX.Editor.createByUrl(modelUrl);"/>
+ <replace file="${activiti-modeler.directory}/editor-app/editor/oryx.debug.js"
+ token="ORYX.Editor.createByUrl = function(modelUrl){"
+ value="modelUrl = BASE_PATH + "/workflowDefGET";
+ORYX.Editor.createByUrl = function(modelUrl){"/>
+ <replace file="${activiti-modeler.directory}/editor-app/configuration/toolbar-default-actions.js"
+ token="window.location.href = "./";"
+ value="window.close();"/>
+
+ <copy file="${basedir}/src/main/resources/url-config.js"
+ todir="${activiti-modeler.directory}/editor-app/configuration"
+ overwrite="true" />
+ <copy file="${basedir}/src/main/resources/save-model.html"
+ todir="${activiti-modeler.directory}/editor-app/popups"
+ overwrite="true" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
<resources>
<resource>
<directory>src/main/resources</directory>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
index 88a6965..92c421c 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java
@@ -39,6 +39,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.init.ClassPathScanImplementationLookup;
import org.apache.syncope.client.console.init.ConsoleInitializer;
import org.apache.syncope.client.console.pages.BasePage;
@@ -82,8 +83,6 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication {
Locale.ENGLISH, Locale.ITALIAN, new Locale("pt", "BR"), new Locale("ru")
}));
- private static final String ACTIVITI_MODELER_CONTEXT = "activiti-modeler";
-
public static SyncopeConsoleApplication get() {
return (SyncopeConsoleApplication) WebApplication.get();
}
@@ -98,6 +97,8 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication {
private String activitiModelerDirectory;
+ private String flowableModelerDirectory;
+
private String reconciliationReportKey;
private String scheme;
@@ -210,7 +211,8 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication {
mountPage("/login", getSignInPageClass());
activitiModelerDirectory = props.getProperty("activitiModelerDirectory");
- Args.notNull(activitiModelerDirectory, "<activitiModelerDirectory>");
+
+ flowableModelerDirectory = props.getProperty("flowableModelerDirectory");
try {
reconciliationReportKey = props.getProperty("reconciliationReportKey");
@@ -219,16 +221,32 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication {
}
Args.notNull(reconciliationReportKey, "<reconciliationReportKey>");
- mountResource("/" + ACTIVITI_MODELER_CONTEXT, new ResourceReference(ACTIVITI_MODELER_CONTEXT) {
+ if (activitiModelerDirectory != null) {
+ mountResource("/" + Constants.ACTIVITI_MODELER_CONTEXT,
+ new ResourceReference(Constants.ACTIVITI_MODELER_CONTEXT) {
- private static final long serialVersionUID = -128426276529456602L;
+ private static final long serialVersionUID = -128426276529456602L;
- @Override
- public IResource getResource() {
- return new FilesystemResource(ACTIVITI_MODELER_CONTEXT, activitiModelerDirectory);
- }
+ @Override
+ public IResource getResource() {
+ return new FilesystemResource(Constants.ACTIVITI_MODELER_CONTEXT, activitiModelerDirectory);
+ }
- });
+ });
+ }
+ if (flowableModelerDirectory != null) {
+ mountResource("/" + Constants.FLOWABLE_MODELER_CONTEXT,
+ new ResourceReference(Constants.FLOWABLE_MODELER_CONTEXT) {
+
+ private static final long serialVersionUID = -128426276529456602L;
+
+ @Override
+ public IResource getResource() {
+ return new FilesystemResource(Constants.FLOWABLE_MODELER_CONTEXT, flowableModelerDirectory);
+ }
+
+ });
+ }
mountResource("/workflowDefGET", new ResourceReference("workflowDefGET") {
private static final long serialVersionUID = -128426276529456602L;
@@ -296,6 +314,10 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication {
return activitiModelerDirectory;
}
+ public String getFlowableModelerDirectory() {
+ return flowableModelerDirectory;
+ }
+
public String getReconciliationReportKey() {
return reconciliationReportKey;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
index baf4653..8b47bed 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/Constants.java
@@ -29,6 +29,12 @@ public final class Constants {
public static final String SYNCOPE = "syncope";
+ public static final String ACTIVITI_MODELER_CONTEXT = "activiti-modeler";
+
+ public static final String FLOWABLE_MODELER_CONTEXT = "flowable-modeler";
+
+ public static final String MODELER_CONTEXT = "modelerContext";
+
public static final String ON_CLICK = "click";
public static final String ON_CHANGE = "change";
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.java
deleted file mode 100644
index 05658fc..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.java
+++ /dev/null
@@ -1,27 +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.client.console.pages;
-
-import org.apache.wicket.markup.html.WebPage;
-
-public class ActivitiModelerPopupPage extends WebPage {
-
- private static final long serialVersionUID = -7031206743629422898L;
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java
index 4b62c8b..3b6737d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/BasePage.java
@@ -169,8 +169,7 @@ public class BasePage extends WebPage implements IAjaxIndicatorAware {
liContainer = new WebMarkupContainer(getLIContainerId("workflow"));
liContainer.setOutputMarkupPlaceholderTag(true);
- liContainer.setVisible(
- SyncopeConsoleSession.get().getPlatformInfo().getUserWorkflowAdapter().contains("Activiti"));
+ liContainer.setVisible(SyncopeConsoleSession.get().getPlatformInfo().isUserWorkflowAdapterSupportEdit());
confULContainer.add(liContainer);
link = BookmarkablePageLinkBuilder.build("workflow", Workflow.class);
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.ENABLE, StandardEntitlement.WORKFLOW_DEF_READ);
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/pages/ModelerPopupPage.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/ModelerPopupPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/ModelerPopupPage.java
new file mode 100644
index 0000000..275c311
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/ModelerPopupPage.java
@@ -0,0 +1,41 @@
+/*
+ * 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.client.console.pages;
+
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+public class ModelerPopupPage extends WebPage {
+
+ private static final long serialVersionUID = -7031206743629422898L;
+
+ public ModelerPopupPage(final PageParameters parameters) {
+ super(parameters);
+
+ WebMarkupContainer refresh = new WebMarkupContainer("refresh");
+ // properly parameterize ?modelId=5 with SYNCOPE-1020
+ refresh.add(new AttributeModifier(
+ "content", "0; url=../../" + parameters.get(Constants.MODELER_CONTEXT) + "/modeler.html?modelId=5"));
+ add(refresh);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/pages/Workflow.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Workflow.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Workflow.java
index a9e0b14..456e845 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Workflow.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/Workflow.java
@@ -39,12 +39,12 @@ public class Workflow extends BasePage {
public Workflow(final PageParameters parameters) {
super(parameters);
- final boolean isActivitiEnabledForUsers =
- SyncopeConsoleSession.get().getPlatformInfo().getUserWorkflowAdapter().contains("Activiti");
+ final boolean userWFASupportsEdit =
+ SyncopeConsoleSession.get().getPlatformInfo().isUserWorkflowAdapterSupportEdit();
- WebMarkupContainer noActivitiEnabledForUsers = new WebMarkupContainer("noActivitiEnabledForUsers");
- noActivitiEnabledForUsers.setOutputMarkupPlaceholderTag(true);
- body.add(noActivitiEnabledForUsers);
+ WebMarkupContainer disabled = new WebMarkupContainer("disabled");
+ disabled.setOutputMarkupPlaceholderTag(true);
+ body.add(disabled);
WebMarkupContainer workflowDef = new WebMarkupContainer("workflowDefContainer");
workflowDef.setOutputMarkupPlaceholderTag(true);
@@ -61,7 +61,7 @@ public class Workflow extends BasePage {
@Override
protected byte[] getImageData(final IResource.Attributes attributes) {
- return isActivitiEnabledForUsers
+ return userWFASupportsEdit
? wfRestClient.getDiagram()
: new byte[0];
}
@@ -76,8 +76,8 @@ public class Workflow extends BasePage {
togglePanel.setOutputMarkupId(true);
workflowDef.add(togglePanel);
- if (isActivitiEnabledForUsers) {
- noActivitiEnabledForUsers.setVisible(false);
+ if (userWFASupportsEdit) {
+ disabled.setVisible(false);
} else {
workflowDef.setVisible(false);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/panels/WorkflowTogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/WorkflowTogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/WorkflowTogglePanel.java
index be1553e..7caf950 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/WorkflowTogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/WorkflowTogglePanel.java
@@ -26,7 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleApplication;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.pages.ActivitiModelerPopupPage;
+import org.apache.syncope.client.console.pages.ModelerPopupPage;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.rest.WorkflowRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
@@ -47,6 +47,7 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.io.IOUtils;
public class WorkflowTogglePanel extends TogglePanel<String> {
@@ -67,20 +68,34 @@ public class WorkflowTogglePanel extends TogglePanel<String> {
container.setOutputMarkupPlaceholderTag(true);
addInnerObject(container);
- BookmarkablePageLink<Void> activitiModeler = new BookmarkablePageLink<>("activitiModeler",
- ActivitiModelerPopupPage.class);
- activitiModeler.setPopupSettings(new VeilPopupSettings().setHeight(600).setWidth(800));
- MetaDataRoleAuthorizationStrategy.authorize(activitiModeler, ENABLE, StandardEntitlement.WORKFLOW_DEF_READ);
- container.add(activitiModeler);
- // Check if Activiti Modeler directory is found
- boolean activitiModelerEnabled = false;
+ // Check if Activiti or Flowable Modeler directory is found
+ String modelerContext = null;
try {
- File baseDir = new File(SyncopeConsoleApplication.get().getActivitiModelerDirectory());
- activitiModelerEnabled = baseDir.exists() && baseDir.canRead() && baseDir.isDirectory();
+ if (SyncopeConsoleApplication.get().getActivitiModelerDirectory() != null) {
+ File baseDir = new File(SyncopeConsoleApplication.get().getActivitiModelerDirectory());
+ if (baseDir.exists() && baseDir.canRead() && baseDir.isDirectory()) {
+ modelerContext = Constants.ACTIVITI_MODELER_CONTEXT;
+ }
+ }
+
+ if (SyncopeConsoleApplication.get().getFlowableModelerDirectory() != null) {
+ File baseDir = new File(SyncopeConsoleApplication.get().getFlowableModelerDirectory());
+ if (baseDir.exists() && baseDir.canRead() && baseDir.isDirectory()) {
+ modelerContext = Constants.FLOWABLE_MODELER_CONTEXT;
+ }
+ }
} catch (Exception e) {
- LOG.error("Could not check for Activiti Modeler directory", e);
+ LOG.error("Could not check for Modeler directory", e);
}
- activitiModeler.setEnabled(activitiModelerEnabled);
+
+ PageParameters parameters = new PageParameters();
+ parameters.add(Constants.MODELER_CONTEXT, modelerContext);
+ BookmarkablePageLink<Void> workflowModeler =
+ new BookmarkablePageLink<>("workflowModeler", ModelerPopupPage.class, parameters);
+ workflowModeler.setPopupSettings(new VeilPopupSettings().setHeight(600).setWidth(800));
+ MetaDataRoleAuthorizationStrategy.authorize(workflowModeler, ENABLE, StandardEntitlement.WORKFLOW_DEF_READ);
+ container.add(workflowModeler);
+ workflowModeler.setEnabled(modelerContext != null);
AjaxSubmitLink xmlEditorSubmit = modal.addSubmitButton();
MetaDataRoleAuthorizationStrategy.authorize(xmlEditorSubmit, RENDER, StandardEntitlement.WORKFLOW_DEF_UPDATE);
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java
index 8735f4a..ab89c0a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefGETResource.java
@@ -26,7 +26,7 @@ import org.apache.wicket.request.resource.AbstractResource;
import org.apache.wicket.util.io.IOUtils;
/**
- * Mirror REST resource for obtaining user workflow definition in JSON (used by Activiti Modeler).
+ * Mirror REST resource for obtaining user workflow definition in JSON (used by Activiti / Flowable Modeler).
*
* @see org.apache.syncope.common.rest.api.service.WorkflowService#exportDefinition
*/
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
index 9eeab54..eb6b982 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
@@ -30,7 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Mirror REST resource for putting user workflow definition in JSON (used by Activiti Modeler).
+ * Mirror REST resource for putting user workflow definition in JSON (used by Activiti / Flowable Modeler).
*
* @see org.apache.syncope.common.rest.api.service.WorkflowService#importDefinition
*/
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/console.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/console.properties b/client/console/src/main/resources/console.properties
index 03326ff..0c086d4 100644
--- a/client/console/src/main/resources/console.properties
+++ b/client/console/src/main/resources/console.properties
@@ -29,6 +29,7 @@ rootPath=/syncope/rest/
useGZIPCompression=true
activitiModelerDirectory=${activiti-modeler.directory}
+flowableModelerDirectory=${flowable-modeler.directory}
reconciliationReportKey=c3520ad9-179f-49e7-b315-d684d216dd97
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.html b/client/console/src/main/resources/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.html
deleted file mode 100644
index 416df19..0000000
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/ActivitiModelerPopupPage.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<!--
-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.
--->
-<html>
- <head>
- <title>Apache Syncope / Activiti Modeler</title>
-
- <meta http-equiv="refresh" content="0; url=../../activiti-modeler/modeler.html"/>
- </head>
- <body>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/ModelerPopupPage.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/ModelerPopupPage.html b/client/console/src/main/resources/org/apache/syncope/client/console/pages/ModelerPopupPage.html
new file mode 100644
index 0000000..f266c81
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/ModelerPopupPage.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<!--
+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.
+-->
+<html>
+ <head>
+ <title>Apache Syncope / Workflow Modeler</title>
+
+ <meta wicket:id="refresh" http-equiv="refresh"/>
+ </head>
+ <body>
+ </body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.html b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.html
index b0ed063..656bb9a 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.html
@@ -24,7 +24,7 @@ under the License.
<section class="content">
<div>
- <span wicket:id="noActivitiEnabledForUsers"><i><wicket:message key="noActivitiEnabledForUsers"/></i></span>
+ <span wicket:id="disabled"><i><wicket:message key="disabled"/></i></span>
<span wicket:id="workflowDefContainer">
<img wicket:id="workflowDefDiagram" style="width: 100%;"/>
<span wicket:id="togglePanel"/>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.properties
index d22205c..9ad5cd1 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow.properties
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-noActivitiEnabledForUsers=Activiti not enabled for users
+disabled=Edit the workflow definition is not supported by the configured Workflow Adapter.
xmlEditorTitle=Workflow XML Editor
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_it.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_it.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_it.properties
index faf7d0d..c4e373b 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_it.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_it.properties
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-noActivitiEnabledForUsers=Activiti non configurato per gli utenti
+disabled=Il Workflow Adapter corrent non consente la modifica della definizione del workflow.
xmlEditorTitle=Workflow XML Editor
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_pt_BR.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_pt_BR.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_pt_BR.properties
index c814c56..9ad5cd1 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_pt_BR.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_pt_BR.properties
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-noActivitiEnabledForUsers=Activiti n\u00e3o habilitado para usu\u00e1rios
+disabled=Edit the workflow definition is not supported by the configured Workflow Adapter.
xmlEditorTitle=Workflow XML Editor
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_ru.properties
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_ru.properties b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_ru.properties
index dfa590a..2994bef 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_ru.properties
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/pages/Workflow_ru.properties
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
#
-# noActivitiEnabledForUsers=Activiti \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439
-noActivitiEnabledForUsers=Activiti \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439
-# xmlEditorTitle=XML \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f
+# noActivitiEnabledForUsers=Activiti \u00d0\u00be\u00d1\u0082\u00d0\u00ba\u00d0\u00bb\u00d1\u008e\u00d1\u0087\u00d0\u00b5\u00d0\u00bd \u00d0\u00b4\u00d0\u00bb\u00d1\u008f \u00d0\u00bf\u00d0\u00be\u00d0\u00bb\u00d1\u008c\u00d0\u00b7\u00d0\u00be\u00d0\u00b2\u00d0\u00b0\u00d1\u0082\u00d0\u00b5\u00d0\u00bb\u00d0\u00b5\u00d0\u00b9
+disabled=Edit the workflow definition is not supported by the configured Workflow Adapter.
+# xmlEditorTitle=XML \u00d1\u0080\u00d0\u00b5\u00d0\u00b4\u00d0\u00b0\u00d0\u00ba\u00d1\u0082\u00d0\u00be\u00d1\u0080 \u00d0\u00bf\u00d1\u0080\u00d0\u00be\u00d1\u0086\u00d0\u00b5\u00d1\u0081\u00d1\u0081\u00d0\u00b0 \u00d1\u0081\u00d0\u00be\u00d0\u00b3\u00d0\u00bb\u00d0\u00b0\u00d1\u0081\u00d0\u00be\u00d0\u00b2\u00d0\u00b0\u00d0\u00bd\u00d0\u00b8\u00d1\u008f
xmlEditorTitle=XML \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/console/src/main/resources/org/apache/syncope/client/console/panels/WorkflowTogglePanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/panels/WorkflowTogglePanel.html b/client/console/src/main/resources/org/apache/syncope/client/console/panels/WorkflowTogglePanel.html
index ee93861..0ca7f70 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/panels/WorkflowTogglePanel.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/panels/WorkflowTogglePanel.html
@@ -38,8 +38,8 @@ under the License.
<wicket:extend>
<div wicket:id="container">
<ul class="menu">
- <wicket:enclosure child="activitiModeler">
- <li><a href="#" wicket:id="activitiModeler"><i class="fa fa-file-image-o"></i>Activiti Modeler</a></li>
+ <wicket:enclosure child="workflowModeler">
+ <li><a href="#" wicket:id="workflowModeler"><i class="fa fa-file-image-o"></i>Workflow Modeler</a></li>
</wicket:enclosure>
<wicket:enclosure child="xmlEditor">
<li><a href="#" wicket:id="xmlEditor"><i class="fa fa-file-text-o"></i>XML editor</a></li>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/BaseResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/BaseResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/BaseResource.java
index 2540f5d..5b7384c 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/BaseResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/BaseResource.java
@@ -47,7 +47,7 @@ public abstract class BaseResource extends AbstractResource {
protected final boolean captchaCheck(final String enteredCaptcha, final Object currentCaptcha) {
return SyncopeEnduserApplication.get().isCaptchaEnabled()
- ? StringUtils.isBlank(currentCaptcha.toString()) || enteredCaptcha == null
+ ? currentCaptcha == null || enteredCaptcha == null || StringUtils.isBlank(currentCaptcha.toString())
? false
: enteredCaptcha.equals(currentCaptcha.toString())
: true;
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java b/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java
index 3d21d69..1f3cbd1 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java
@@ -45,10 +45,16 @@ public class PlatformInfo extends AbstractBaseBean {
private String anyObjectWorkflowAdapter;
+ private boolean anyObjectWorkflowAdapterSupportEdit;
+
private String userWorkflowAdapter;
+ private boolean userWorkflowAdapterSupportEdit;
+
private String groupWorkflowAdapter;
+ private boolean groupWorkflowAdapterSupportEdit;
+
private String anyObjectProvisioningManager;
private String userProvisioningManager;
@@ -120,14 +126,26 @@ public class PlatformInfo extends AbstractBaseBean {
return userWorkflowAdapter;
}
+ public boolean isUserWorkflowAdapterSupportEdit() {
+ return userWorkflowAdapterSupportEdit;
+ }
+
public String getGroupWorkflowAdapter() {
return groupWorkflowAdapter;
}
+ public boolean isGroupWorkflowAdapterSupportEdit() {
+ return groupWorkflowAdapterSupportEdit;
+ }
+
public String getAnyObjectProvisioningManager() {
return anyObjectProvisioningManager;
}
+ public boolean isAnyObjectWorkflowAdapterSupportEdit() {
+ return anyObjectWorkflowAdapterSupportEdit;
+ }
+
public String getUserProvisioningManager() {
return userProvisioningManager;
}
@@ -273,14 +291,26 @@ public class PlatformInfo extends AbstractBaseBean {
this.anyObjectWorkflowAdapter = anyObjectWorkflowAdapter;
}
+ public void setAnyObjectWorkflowAdapterSupportEdit(final boolean anyObjectWorkflowAdapterSupportEdit) {
+ this.anyObjectWorkflowAdapterSupportEdit = anyObjectWorkflowAdapterSupportEdit;
+ }
+
public void setUserWorkflowAdapter(final String userWorkflowAdapter) {
this.userWorkflowAdapter = userWorkflowAdapter;
}
+ public void setUserWorkflowAdapterSupportEdit(final boolean userWorkflowAdapterSupportEdit) {
+ this.userWorkflowAdapterSupportEdit = userWorkflowAdapterSupportEdit;
+ }
+
public void setGroupWorkflowAdapter(final String groupWorkflowAdapter) {
this.groupWorkflowAdapter = groupWorkflowAdapter;
}
+ public void setGroupWorkflowAdapterSupportEdit(final boolean groupWorkflowAdapterSupportEdit) {
+ this.groupWorkflowAdapterSupportEdit = groupWorkflowAdapterSupportEdit;
+ }
+
public void setAnyObjectProvisioningManager(final String anyObjectProvisioningManager) {
this.anyObjectProvisioningManager = anyObjectProvisioningManager;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
index 0caa8ab..2d0d920 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
@@ -167,8 +167,11 @@ public class SyncopeLogic extends AbstractLogic<AbstractBaseBean> {
}
PLATFORM_INFO.setAnyObjectWorkflowAdapter(AopUtils.getTargetClass(awfAdapter).getName());
+ PLATFORM_INFO.setAnyObjectWorkflowAdapterSupportEdit(awfAdapter.supportsDefinitionEdit());
PLATFORM_INFO.setUserWorkflowAdapter(AopUtils.getTargetClass(uwfAdapter).getName());
+ PLATFORM_INFO.setUserWorkflowAdapterSupportEdit(uwfAdapter.supportsDefinitionEdit());
PLATFORM_INFO.setGroupWorkflowAdapter(AopUtils.getTargetClass(gwfAdapter).getName());
+ PLATFORM_INFO.setGroupWorkflowAdapterSupportEdit(gwfAdapter.supportsDefinitionEdit());
PLATFORM_INFO.setAnyObjectProvisioningManager(aProvisioningManager.getClass().getName());
PLATFORM_INFO.setUserProvisioningManager(uProvisioningManager.getClass().getName());
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 0584720..4de422a 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -85,6 +85,7 @@ under the License.
<module>workflow-api</module>
<module>workflow-java</module>
<module>workflow-activiti</module>
+ <module>workflow-flowable</module>
<module>logic</module>
<module>rest-cxf</module>
<module>migration</module>
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
index d524831..8f4fe93 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
@@ -132,6 +132,11 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
protected DomainProcessEngine engine;
@Override
+ public boolean supportsDefinitionEdit() {
+ return true;
+ }
+
+ @Override
public String getPrefix() {
return "ACT_";
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
index 318a162..b6fab8f 100644
--- a/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
+++ b/core/workflow-api/src/main/java/org/apache/syncope/core/workflow/api/WorkflowAdapter.java
@@ -27,6 +27,11 @@ import org.apache.syncope.core.provisioning.api.WorkflowResult;
public interface WorkflowAdapter {
/**
+ * @return if this adapter can support runtime editing of the workflow definition
+ */
+ boolean supportsDefinitionEdit();
+
+ /**
* @return any string that might be interpreted as 'prefix' (say table prefix in SQL environments)
*/
String getPrefix();
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/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..a68b8c2
--- /dev/null
+++ b/core/workflow-flowable/pom.xml
@@ -0,0 +1,92 @@
+<?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.0.3-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>
+ <dependency>
+ <groupId>org.apache.syncope.core</groupId>
+ <artifactId>syncope-core-spring</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/85ddca5b/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..18f4b37
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableDefinitionLoader.java
@@ -0,0 +1,108 @@
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Resource;
+import org.activiti.editor.constants.ModelDataJsonConstants;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.repository.Model;
+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 " + FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, 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(
+ FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, new ByteArrayInputStream(wfDef)).deploy();
+
+ ProcessDefinition procDef = entry.getValue().getRepositoryService().createProcessDefinitionQuery().
+ processDefinitionKey(FlowableUserWorkflowAdapter.WF_PROCESS_ID).latestVersion().
+ singleResult();
+
+ Model model = entry.getValue().getRepositoryService().newModel();
+ ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
+ modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, procDef.getName());
+ modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
+ modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, procDef.getDescription());
+ model.setMetaInfo(modelObjectNode.toString());
+ model.setName(procDef.getName());
+ model.setDeploymentId(procDef.getDeploymentId());
+ FlowableImportUtils.fromJSON(entry.getValue(), procDef, model);
+
+ 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/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableImportUtils.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableImportUtils.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableImportUtils.java
new file mode 100644
index 0000000..6d0aae5
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableImportUtils.java
@@ -0,0 +1,93 @@
+/*
+ * 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.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.language.json.converter.BpmnJsonConverter;
+import org.activiti.engine.ActivitiException;
+import org.activiti.engine.ProcessEngine;
+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 FlowableImportUtils {
+
+ public static void fromXML(final ProcessEngine engine, final byte[] definition) {
+ try {
+ engine.getRepositoryService().createDeployment().
+ addInputStream(FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE,
+ new ByteArrayInputStream(definition)).deploy();
+ } catch (ActivitiException e) {
+ throw new WorkflowException("While updating process " + FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, e);
+ }
+ }
+
+ public static void fromJSON(
+ final ProcessEngine engine, final byte[] definition, final ProcessDefinition procDef, final Model model) {
+
+ try {
+ model.setVersion(procDef.getVersion());
+ model.setDeploymentId(procDef.getDeploymentId());
+ engine.getRepositoryService().saveModel(model);
+
+ engine.getRepositoryService().addModelEditorSource(model.getId(), definition);
+ } catch (Exception e) {
+ throw new WorkflowException("While updating process " + FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, e);
+ }
+ }
+
+ public static void fromJSON(final ProcessEngine engine, final ProcessDefinition procDef, final Model model) {
+ 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);
+
+ fromJSON(engine, new BpmnJsonConverter().convertToJson(bpmnModel).toString().getBytes(), procDef, model);
+ } catch (Exception e) {
+ throw new WorkflowException("While updating process " + FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, e);
+ } finally {
+ if (xtr != null) {
+ try {
+ xtr.close();
+ } catch (XMLStreamException e) {
+ // ignore
+ }
+ }
+ IOUtils.closeQuietly(isr);
+ IOUtils.closeQuietly(bpmnStream);
+ }
+ }
+
+ private FlowableImportUtils() {
+ // private constructor for static utility class
+ }
+}
[2/3] syncope git commit: [SYNCOPE-1055] Provide
core/workflow-flowable,
based on core/workflow-activiti + support for Flowable Modeler in Admin
Console
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
new file mode 100644
index 0000000..3b82340
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
@@ -0,0 +1,887 @@
+/*
+ * 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.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Resource;
+import javax.ws.rs.NotFoundException;
+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.form.FormProperty;
+import org.activiti.engine.form.FormType;
+import org.activiti.engine.form.TaskFormData;
+import org.activiti.engine.history.HistoricActivityInstance;
+import org.activiti.engine.history.HistoricDetail;
+import org.activiti.engine.history.HistoricTaskInstance;
+import org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntity;
+import org.activiti.engine.query.Query;
+import org.activiti.engine.repository.Model;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.patch.PasswordPatch;
+import org.apache.syncope.common.lib.patch.UserPatch;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO;
+import org.apache.syncope.common.lib.to.WorkflowFormTO;
+import org.apache.syncope.core.provisioning.api.PropagationByResource;
+import org.apache.syncope.common.lib.types.ResourceOperation;
+import org.apache.syncope.common.lib.types.WorkflowFormPropertyType;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
+import org.apache.syncope.core.spring.BeanUtils;
+import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
+import org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.WorkflowResult;
+import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
+import org.apache.syncope.core.workflow.flowable.spring.DomainProcessEngine;
+import org.apache.syncope.core.workflow.api.WorkflowDefinitionFormat;
+import org.apache.syncope.core.workflow.api.WorkflowException;
+import org.apache.syncope.core.workflow.java.AbstractUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * <a href="http://www.flowable.org/">Flowable</a> based implementation.
+ */
+public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
+
+ protected static final String[] PROPERTY_IGNORE_PROPS = { "type" };
+
+ public static final String WF_PROCESS_ID = "userWorkflow";
+
+ public static final String WF_PROCESS_RESOURCE = "userWorkflow.bpmn20.xml";
+
+ public static final String WF_DGRM_RESOURCE = "userWorkflow.userWorkflow.png";
+
+ public static final String USER = "user";
+
+ public static final String WF_EXECUTOR = "wfExecutor";
+
+ public static final String FORM_SUBMITTER = "formSubmitter";
+
+ public static final String USER_TO = "userTO";
+
+ public static final String ENABLED = "enabled";
+
+ public static final String USER_PATCH = "userPatch";
+
+ public static final String EMAIL_KIND = "emailKind";
+
+ public static final String TASK = "task";
+
+ public static final String TOKEN = "token";
+
+ public static final String PASSWORD = "password";
+
+ public static final String PROP_BY_RESOURCE = "propByResource";
+
+ public static final String PROPAGATE_ENABLE = "propagateEnable";
+
+ public static final String ENCRYPTED_PWD = "encryptedPwd";
+
+ public static final String TASK_IS_FORM = "taskIsForm";
+
+ public static final String MODEL_DATA_JSON_MODEL = "model";
+
+ public static final String STORE_PASSWORD = "storePassword";
+
+ public static final String EVENT = "event";
+
+ @Resource(name = "adminUser")
+ protected String adminUser;
+
+ @Override
+ public boolean supportsDefinitionEdit() {
+ return true;
+ }
+
+ @Autowired
+ protected DomainProcessEngine engine;
+
+ @Override
+ public String getPrefix() {
+ return "ACT_";
+ }
+
+ protected void throwException(final ActivitiException e, final String defaultMessage) {
+ if (e.getCause() != null) {
+ if (e.getCause().getCause() instanceof SyncopeClientException) {
+ throw (SyncopeClientException) e.getCause().getCause();
+ } else if (e.getCause().getCause() instanceof ParsingValidationException) {
+ throw (ParsingValidationException) e.getCause().getCause();
+ } else if (e.getCause().getCause() instanceof InvalidEntityException) {
+ throw (InvalidEntityException) e.getCause().getCause();
+ }
+ }
+
+ throw new WorkflowException(defaultMessage, e);
+ }
+
+ protected void updateStatus(final User user) {
+ List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
+ if (tasks.isEmpty() || tasks.size() > 1) {
+ LOG.warn("While setting user status: unexpected task number ({})", tasks.size());
+ } else {
+ user.setStatus(tasks.get(0).getTaskDefinitionKey());
+ }
+ }
+
+ protected String getFormTask(final User user) {
+ String result = null;
+
+ List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
+ if (tasks.isEmpty() || tasks.size() > 1) {
+ LOG.debug("While checking if form task: unexpected task number ({})", tasks.size());
+ } else {
+ try {
+ TaskFormData formData = engine.getFormService().getTaskFormData(tasks.get(0).getId());
+ if (formData != null && !formData.getFormProperties().isEmpty()) {
+ result = tasks.get(0).getId();
+ }
+ } catch (ActivitiException e) {
+ LOG.warn("Could not get task form data", e);
+ }
+ }
+
+ return result;
+ }
+
+ protected Set<String> getPerformedTasks(final User user) {
+ final Set<String> result = new HashSet<>();
+
+ for (HistoricActivityInstance task : engine.getHistoryService().createHistoricActivityInstanceQuery().
+ executionId(user.getWorkflowId()).list()) {
+
+ result.add(task.getActivityId());
+ }
+
+ return result;
+ }
+
+ /**
+ * Saves resources to be propagated and password for later - after form submission - propagation.
+ *
+ * @param user user
+ * @param password password
+ * @param propByRes current propagation actions against resources
+ */
+ protected void saveForFormSubmit(final User user, final String password, final PropagationByResource propByRes) {
+ String formTaskId = getFormTask(user);
+ if (formTaskId != null) {
+ // SYNCOPE-238: This is needed to simplify the task query in this.getForms()
+ engine.getTaskService().setVariableLocal(formTaskId, TASK_IS_FORM, Boolean.TRUE);
+ engine.getRuntimeService().setVariable(user.getWorkflowId(), PROP_BY_RESOURCE, propByRes);
+ if (propByRes != null) {
+ propByRes.clear();
+ }
+
+ if (StringUtils.isNotBlank(password)) {
+ engine.getRuntimeService().setVariable(user.getWorkflowId(), ENCRYPTED_PWD, encrypt(password));
+ }
+ }
+ }
+
+ @Override
+ public WorkflowResult<Pair<String, Boolean>> create(final UserTO userTO, final boolean disablePwdPolicyCheck,
+ final boolean storePassword) {
+
+ return create(userTO, disablePwdPolicyCheck, null, storePassword);
+ }
+
+ @Override
+ public WorkflowResult<Pair<String, Boolean>> create(final UserTO userTO, final boolean storePassword) {
+ return create(userTO, false, storePassword);
+ }
+
+ @Override
+ public WorkflowResult<Pair<String, Boolean>> create(final UserTO userTO, final boolean disablePwdPolicyCheck,
+ final Boolean enabled, final boolean storePassword) {
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
+ variables.put(USER_TO, userTO);
+ variables.put(ENABLED, enabled);
+ variables.put(STORE_PASSWORD, storePassword);
+
+ ProcessInstance processInstance = null;
+ try {
+ processInstance = engine.getRuntimeService().startProcessInstanceByKey(WF_PROCESS_ID, variables);
+ } catch (ActivitiException e) {
+ throwException(e, "While starting " + WF_PROCESS_ID + " instance");
+ }
+
+ User user = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), USER, User.class);
+
+ Boolean updatedEnabled =
+ engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), ENABLED, Boolean.class);
+ if (updatedEnabled != null) {
+ user.setSuspended(!updatedEnabled);
+ }
+
+ // this will make UserValidator not to consider password policies at all
+ if (disablePwdPolicyCheck) {
+ user.removeClearPassword();
+ }
+
+ updateStatus(user);
+ user = userDAO.save(user);
+
+ Boolean propagateEnable = engine.getRuntimeService().getVariable(
+ processInstance.getProcessInstanceId(), PROPAGATE_ENABLE, Boolean.class);
+ if (propagateEnable == null) {
+ propagateEnable = enabled;
+ }
+
+ PropagationByResource propByRes = new PropagationByResource();
+ propByRes.set(
+ ResourceOperation.CREATE,
+ CollectionUtils.collect(userDAO.findAllResources(user), EntityUtils.keyTransformer()));
+
+ saveForFormSubmit(user, userTO.getPassword(), propByRes);
+
+ Set<String> tasks = getPerformedTasks(user);
+
+ return new WorkflowResult<Pair<String, Boolean>>(
+ new ImmutablePair<>(user.getKey(), propagateEnable), propByRes, tasks);
+ }
+
+ protected Set<String> doExecuteTask(final User user, final String task, final Map<String, Object> moreVariables) {
+ Set<String> preTasks = getPerformedTasks(user);
+
+ Map<String, Object> variables = new HashMap<>();
+ variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
+ variables.put(TASK, task);
+
+ // using BeanUtils to access all user's properties and trigger lazy loading - we are about to
+ // serialize a User instance for availability within workflow tasks, and this breaks transactions
+ BeanUtils.copyProperties(user, entityFactory.newEntity(User.class));
+ variables.put(USER, user);
+
+ if (moreVariables != null && !moreVariables.isEmpty()) {
+ variables.putAll(moreVariables);
+ }
+
+ if (StringUtils.isBlank(user.getWorkflowId())) {
+ throw new WorkflowException(new NotFoundException("Empty workflow id for " + user));
+ }
+
+ List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(user.getWorkflowId()).list();
+ if (tasks.size() == 1) {
+ try {
+ engine.getTaskService().complete(tasks.get(0).getId(), variables);
+ } catch (ActivitiException e) {
+ throwException(e, "While completing task '" + tasks.get(0).getName() + "' for " + user);
+ }
+ } else {
+ LOG.warn("Expected a single task, found {}", tasks.size());
+ }
+
+ Set<String> postTasks = getPerformedTasks(user);
+ postTasks.removeAll(preTasks);
+ postTasks.add(task);
+
+ return postTasks;
+ }
+
+ @Override
+ protected WorkflowResult<String> doActivate(final User user, final String token) {
+ Set<String> tasks = doExecuteTask(user, "activate", Collections.singletonMap(TOKEN, (Object) token));
+
+ updateStatus(user);
+ User updated = userDAO.save(user);
+
+ return new WorkflowResult<>(updated.getKey(), null, tasks);
+ }
+
+ @Override
+ protected WorkflowResult<Pair<UserPatch, Boolean>> doUpdate(final User user, final UserPatch userPatch) {
+ Set<String> tasks = doExecuteTask(user, "update", Collections.singletonMap(USER_PATCH, (Object) userPatch));
+
+ updateStatus(user);
+ User updated = userDAO.save(user);
+
+ PropagationByResource propByRes = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
+ UserPatch updatedPatch = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), USER_PATCH, UserPatch.class);
+
+ saveForFormSubmit(
+ updated, updatedPatch.getPassword() == null ? null : updatedPatch.getPassword().getValue(), propByRes);
+
+ Boolean propagateEnable = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
+
+ return new WorkflowResult<Pair<UserPatch, Boolean>>(
+ new ImmutablePair<>(updatedPatch, propagateEnable), propByRes, tasks);
+ }
+
+ @Override
+ public WorkflowResult<String> requestCertify(final User user) {
+ String authUser = AuthContextUtils.getUsername();
+ engine.getRuntimeService().setVariable(user.getWorkflowId(), FORM_SUBMITTER, authUser);
+
+ LOG.debug("Executing request-certify");
+ Set<String> performedTasks = doExecuteTask(user, "request-certify", null);
+
+ PropagationByResource propByRes = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
+
+ saveForFormSubmit(user, null, propByRes);
+
+ return new WorkflowResult<>(user.getKey(), null, performedTasks);
+ }
+
+ @Override
+ protected WorkflowResult<String> doSuspend(final User user) {
+ Set<String> performedTasks = doExecuteTask(user, "suspend", null);
+ updateStatus(user);
+ User updated = userDAO.save(user);
+
+ return new WorkflowResult<>(updated.getKey(), null, performedTasks);
+ }
+
+ @Override
+ protected WorkflowResult<String> doReactivate(final User user) {
+ Set<String> performedTasks = doExecuteTask(user, "reactivate", null);
+ updateStatus(user);
+
+ User updated = userDAO.save(user);
+
+ return new WorkflowResult<>(updated.getKey(), null, performedTasks);
+ }
+
+ @Override
+ protected void doRequestPasswordReset(final User user) {
+ Map<String, Object> variables = new HashMap<>(2);
+ variables.put(USER_TO, dataBinder.getUserTO(user, true));
+ variables.put(EVENT, "requestPasswordReset");
+
+ doExecuteTask(user, "requestPasswordReset", variables);
+ userDAO.save(user);
+ }
+
+ @Override
+ protected WorkflowResult<Pair<UserPatch, Boolean>> doConfirmPasswordReset(
+ final User user, final String token, final String password) {
+
+ Map<String, Object> variables = new HashMap<>(4);
+ variables.put(TOKEN, token);
+ variables.put(PASSWORD, password);
+ variables.put(USER_TO, dataBinder.getUserTO(user, true));
+ variables.put(EVENT, "confirmPasswordReset");
+
+ Set<String> tasks = doExecuteTask(user, "confirmPasswordReset", variables);
+
+ userDAO.save(user);
+
+ PropagationByResource propByRes = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
+ UserPatch updatedPatch = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), USER_PATCH, UserPatch.class);
+ Boolean propagateEnable = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
+
+ return new WorkflowResult<Pair<UserPatch, Boolean>>(
+ new ImmutablePair<>(updatedPatch, propagateEnable), propByRes, tasks);
+ }
+
+ @Override
+ protected void doDelete(final User user) {
+ doExecuteTask(user, "delete", null);
+
+ PropagationByResource propByRes = new PropagationByResource();
+ propByRes.set(
+ ResourceOperation.DELETE,
+ CollectionUtils.collect(userDAO.findAllResources(user), EntityUtils.keyTransformer()));
+
+ saveForFormSubmit(user, null, propByRes);
+
+ if (engine.getRuntimeService().createProcessInstanceQuery().
+ processInstanceId(user.getWorkflowId()).active().list().isEmpty()) {
+
+ userDAO.delete(user.getKey());
+
+ if (!engine.getHistoryService().createHistoricProcessInstanceQuery().
+ processInstanceId(user.getWorkflowId()).list().isEmpty()) {
+
+ engine.getHistoryService().deleteHistoricProcessInstance(user.getWorkflowId());
+ }
+ } else {
+ updateStatus(user);
+ userDAO.save(user);
+ }
+ }
+
+ @Override
+ public WorkflowResult<String> execute(final UserTO userTO, final String taskId) {
+ User user = userDAO.authFind(userTO.getKey());
+
+ final Map<String, Object> variables = new HashMap<>();
+ variables.put(USER_TO, userTO);
+
+ Set<String> performedTasks = doExecuteTask(user, taskId, variables);
+ updateStatus(user);
+ User updated = userDAO.save(user);
+
+ return new WorkflowResult<>(updated.getKey(), null, performedTasks);
+ }
+
+ protected ProcessDefinition getProcessDefinition() {
+ try {
+ return engine.getRepositoryService().createProcessDefinitionQuery().
+ processDefinitionKey(FlowableUserWorkflowAdapter.WF_PROCESS_ID).latestVersion().singleResult();
+ } catch (ActivitiException e) {
+ throw new WorkflowException("While accessing process " + FlowableUserWorkflowAdapter.WF_PROCESS_ID, e);
+ }
+
+ }
+
+ protected Model getModel(final ProcessDefinition procDef) {
+ try {
+ Model model = engine.getRepositoryService().createModelQuery().
+ deploymentId(procDef.getDeploymentId()).singleResult();
+ if (model == null) {
+ throw new NotFoundException("Could not find Model for deployment " + procDef.getDeploymentId());
+ }
+ return model;
+ } catch (Exception e) {
+ throw new WorkflowException("While accessing process " + FlowableUserWorkflowAdapter.WF_PROCESS_ID, e);
+ }
+ }
+
+ protected void exportProcessResource(final String resourceName, final OutputStream os) {
+ ProcessDefinition procDef = getProcessDefinition();
+
+ InputStream procDefIS = engine.getRepositoryService().getResourceAsStream(procDef.getDeploymentId(),
+ resourceName);
+ try {
+ IOUtils.copy(procDefIS, os);
+ } catch (IOException e) {
+ LOG.error("While exporting workflow definition {}", procDef.getKey(), e);
+ } finally {
+ IOUtils.closeQuietly(procDefIS);
+ }
+ }
+
+ protected void exportProcessModel(final OutputStream os) {
+ Model model = getModel(getProcessDefinition());
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ ObjectNode modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
+ modelNode.put(ModelDataJsonConstants.MODEL_ID, model.getId());
+ modelNode.replace(MODEL_DATA_JSON_MODEL,
+ objectMapper.readTree(engine.getRepositoryService().getModelEditorSource(model.getId())));
+
+ os.write(modelNode.toString().getBytes());
+ } catch (IOException e) {
+ LOG.error("While exporting workflow definition {}", model.getId(), e);
+ }
+ }
+
+ @Override
+ public void exportDefinition(final WorkflowDefinitionFormat format, final OutputStream os) {
+ switch (format) {
+ case JSON:
+ exportProcessModel(os);
+ break;
+
+ case XML:
+ default:
+ exportProcessResource(WF_PROCESS_RESOURCE, os);
+ }
+ }
+
+ @Override
+ public void exportDiagram(final OutputStream os) {
+ exportProcessResource(WF_DGRM_RESOURCE, os);
+ }
+
+ @Override
+ public void importDefinition(final WorkflowDefinitionFormat format, final String definition) {
+ Model model = getModel(getProcessDefinition());
+ switch (format) {
+ case JSON:
+ JsonNode definitionNode;
+ try {
+ definitionNode = new ObjectMapper().readTree(definition);
+ if (definitionNode.has(MODEL_DATA_JSON_MODEL)) {
+ definitionNode = definitionNode.get(MODEL_DATA_JSON_MODEL);
+ }
+ if (!definitionNode.has(BpmnJsonConverter.EDITOR_CHILD_SHAPES)) {
+ throw new IllegalArgumentException(
+ "Could not find JSON node " + BpmnJsonConverter.EDITOR_CHILD_SHAPES);
+ }
+
+ BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(definitionNode);
+ FlowableImportUtils.fromXML(engine, new BpmnXMLConverter().convertToXML(bpmnModel));
+ } catch (Exception e) {
+ throw new WorkflowException("While updating process "
+ + FlowableUserWorkflowAdapter.WF_PROCESS_RESOURCE, e);
+ }
+
+ FlowableImportUtils.fromJSON(
+ engine, definitionNode.toString().getBytes(), getProcessDefinition(), model);
+ break;
+
+ case XML:
+ default:
+ FlowableImportUtils.fromXML(engine, definition.getBytes());
+
+ FlowableImportUtils.fromJSON(engine, getProcessDefinition(), model);
+ }
+ }
+
+ protected WorkflowFormPropertyType fromFlowableFormType(final FormType flowableFormType) {
+ WorkflowFormPropertyType result = WorkflowFormPropertyType.String;
+
+ if ("string".equals(flowableFormType.getName())) {
+ result = WorkflowFormPropertyType.String;
+ }
+ if ("long".equals(flowableFormType.getName())) {
+ result = WorkflowFormPropertyType.Long;
+ }
+ if ("enum".equals(flowableFormType.getName())) {
+ result = WorkflowFormPropertyType.Enum;
+ }
+ if ("date".equals(flowableFormType.getName())) {
+ result = WorkflowFormPropertyType.Date;
+ }
+ if ("boolean".equals(flowableFormType.getName())) {
+ result = WorkflowFormPropertyType.Boolean;
+ }
+
+ return result;
+ }
+
+ protected WorkflowFormTO getFormTO(final Task task) {
+ return getFormTO(task, engine.getFormService().getTaskFormData(task.getId()));
+ }
+
+ protected WorkflowFormTO getFormTO(final Task task, final TaskFormData fd) {
+ final WorkflowFormTO formTO =
+ getFormTO(task.getProcessInstanceId(), task.getId(), fd.getFormKey(), fd.getFormProperties());
+
+ BeanUtils.copyProperties(task, formTO);
+ return formTO;
+ }
+
+ protected WorkflowFormTO getFormTO(final HistoricTaskInstance task) {
+ final List<HistoricFormPropertyEntity> props = new ArrayList<>();
+
+ for (HistoricDetail historicDetail
+ : engine.getHistoryService().createHistoricDetailQuery().taskId(task.getId()).list()) {
+
+ if (historicDetail instanceof HistoricFormPropertyEntity) {
+ props.add((HistoricFormPropertyEntity) historicDetail);
+ }
+ }
+
+ final WorkflowFormTO formTO = getHistoricFormTO(
+ task.getProcessInstanceId(), task.getId(), task.getFormKey(), props);
+ BeanUtils.copyProperties(task, formTO);
+
+ final HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
+ createHistoricActivityInstanceQuery().
+ executionId(task.getExecutionId()).activityType("userTask").activityName(task.getName()).singleResult();
+
+ if (historicActivityInstance != null) {
+ formTO.setCreateTime(historicActivityInstance.getStartTime());
+ formTO.setDueDate(historicActivityInstance.getEndTime());
+ }
+
+ return formTO;
+ }
+
+ protected WorkflowFormTO getHistoricFormTO(
+ final String processInstanceId,
+ final String taskId,
+ final String formKey,
+ final List<HistoricFormPropertyEntity> props) {
+
+ WorkflowFormTO formTO = new WorkflowFormTO();
+
+ User user = userDAO.findByWorkflowId(processInstanceId);
+ if (user == null) {
+ throw new NotFoundException("User with workflow id " + processInstanceId);
+ }
+ formTO.setUsername(user.getUsername());
+
+ formTO.setTaskId(taskId);
+ formTO.setKey(formKey);
+
+ for (HistoricFormPropertyEntity prop : props) {
+ WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
+ propertyTO.setId(prop.getPropertyId());
+ propertyTO.setName(prop.getPropertyId());
+ propertyTO.setValue(prop.getPropertyValue());
+ formTO.addProperty(propertyTO);
+ }
+
+ return formTO;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected WorkflowFormTO getFormTO(
+ final String processInstanceId,
+ final String taskId,
+ final String formKey,
+ final List<FormProperty> properties) {
+
+ WorkflowFormTO formTO = new WorkflowFormTO();
+
+ User user = userDAO.findByWorkflowId(processInstanceId);
+ if (user == null) {
+ throw new NotFoundException("User with workflow id " + processInstanceId);
+ }
+ formTO.setUsername(user.getUsername());
+
+ formTO.setTaskId(taskId);
+ formTO.setKey(formKey);
+
+ for (FormProperty fProp : properties) {
+ WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
+ BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);
+ propertyTO.setType(fromFlowableFormType(fProp.getType()));
+
+ if (propertyTO.getType() == WorkflowFormPropertyType.Date) {
+ propertyTO.setDatePattern((String) fProp.getType().getInformation("datePattern"));
+ }
+ if (propertyTO.getType() == WorkflowFormPropertyType.Enum) {
+ propertyTO.getEnumValues().putAll((Map<String, String>) fProp.getType().getInformation("values"));
+ }
+
+ formTO.addProperty(propertyTO);
+ }
+
+ return formTO;
+ }
+
+ @Transactional(readOnly = true)
+ @Override
+ public List<WorkflowFormTO> getForms() {
+ List<WorkflowFormTO> forms = new ArrayList<>();
+
+ String authUser = AuthContextUtils.getUsername();
+ if (adminUser.equals(authUser)) {
+ forms.addAll(getForms(engine.getTaskService().createTaskQuery().
+ taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE)));
+ } else {
+ User user = userDAO.findByUsername(authUser);
+ if (user == null) {
+ throw new NotFoundException("Syncope User " + authUser);
+ }
+
+ forms.addAll(getForms(engine.getTaskService().createTaskQuery().
+ taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
+ taskCandidateOrAssigned(user.getKey())));
+
+ List<String> candidateGroups = new ArrayList<>();
+ for (String groupName : userDAO.findAllGroupNames(user)) {
+ candidateGroups.add(groupName);
+ }
+ if (!candidateGroups.isEmpty()) {
+ forms.addAll(getForms(engine.getTaskService().createTaskQuery().
+ taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
+ taskCandidateGroupIn(candidateGroups)));
+ }
+ }
+
+ return forms;
+ }
+
+ protected <T extends Query<?, ?>, U extends Object> List<WorkflowFormTO> getForms(final Query<T, U> query) {
+ List<WorkflowFormTO> forms = new ArrayList<>();
+
+ for (U obj : query.list()) {
+ try {
+ if (obj instanceof HistoricTaskInstance) {
+ forms.add(getFormTO((HistoricTaskInstance) obj));
+ } else if (obj instanceof Task) {
+ forms.add(getFormTO((Task) obj));
+ } else {
+ throw new ActivitiException(
+ "Failure retrieving form", new IllegalArgumentException("Invalid task type"));
+ }
+ } catch (ActivitiException e) {
+ LOG.debug("No form found for task {}", obj, e);
+ }
+ }
+
+ return forms;
+ }
+
+ @Override
+ public WorkflowFormTO getForm(final String workflowId) {
+ Task task;
+ try {
+ task = engine.getTaskService().createTaskQuery().processInstanceId(workflowId).singleResult();
+ } catch (ActivitiException e) {
+ throw new WorkflowException("While reading form for workflow instance " + workflowId, e);
+ }
+
+ TaskFormData formData;
+ try {
+ formData = engine.getFormService().getTaskFormData(task.getId());
+ } catch (ActivitiException e) {
+ LOG.debug("No form found for task {}", task.getId(), e);
+ formData = null;
+ }
+
+ WorkflowFormTO result = null;
+ if (formData != null && !formData.getFormProperties().isEmpty()) {
+ result = getFormTO(task);
+ }
+
+ return result;
+ }
+
+ protected Pair<Task, TaskFormData> checkTask(final String taskId, final String authUser) {
+ Task task;
+ try {
+ task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
+ if (task == null) {
+ throw new ActivitiException("NULL result");
+ }
+ } catch (ActivitiException e) {
+ throw new NotFoundException("Flowable Task " + taskId, e);
+ }
+
+ TaskFormData formData;
+ try {
+ formData = engine.getFormService().getTaskFormData(task.getId());
+ } catch (ActivitiException e) {
+ throw new NotFoundException("Form for Flowable Task " + taskId, e);
+ }
+
+ if (!adminUser.equals(authUser)) {
+ User user = userDAO.findByUsername(authUser);
+ if (user == null) {
+ throw new NotFoundException("Syncope User " + authUser);
+ }
+ }
+
+ return new ImmutablePair<>(task, formData);
+ }
+
+ @Override
+ public WorkflowFormTO claimForm(final String taskId) {
+ String authUser = AuthContextUtils.getUsername();
+ Pair<Task, TaskFormData> checked = checkTask(taskId, authUser);
+
+ if (!adminUser.equals(authUser)) {
+ List<Task> tasksForUser = engine.getTaskService().createTaskQuery().taskId(taskId).taskCandidateUser(
+ authUser).list();
+ if (tasksForUser.isEmpty()) {
+ throw new WorkflowException(
+ new IllegalArgumentException(authUser + " is not candidate for task " + taskId));
+ }
+ }
+
+ Task task;
+ try {
+ engine.getTaskService().setOwner(taskId, authUser);
+ task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
+ } catch (ActivitiException e) {
+ throw new WorkflowException("While reading task " + taskId, e);
+ }
+
+ return getFormTO(task, checked.getValue());
+ }
+
+ @Override
+ public WorkflowResult<UserPatch> submitForm(final WorkflowFormTO form) {
+ String authUser = AuthContextUtils.getUsername();
+ Pair<Task, TaskFormData> checked = checkTask(form.getTaskId(), authUser);
+
+ if (!checked.getKey().getOwner().equals(authUser)) {
+ throw new WorkflowException(new IllegalArgumentException("Task " + form.getTaskId() + " assigned to "
+ + checked.getKey().getOwner() + " but submitted by " + authUser));
+ }
+
+ User user = userDAO.findByWorkflowId(checked.getKey().getProcessInstanceId());
+ if (user == null) {
+ throw new NotFoundException("User with workflow id " + checked.getKey().getProcessInstanceId());
+ }
+
+ Set<String> preTasks = getPerformedTasks(user);
+ try {
+ engine.getFormService().submitTaskFormData(form.getTaskId(), form.getPropertiesForSubmit());
+ engine.getRuntimeService().setVariable(user.getWorkflowId(), FORM_SUBMITTER, authUser);
+ } catch (ActivitiException e) {
+ throwException(e, "While submitting form for task " + form.getTaskId());
+ }
+
+ Set<String> postTasks = getPerformedTasks(user);
+ postTasks.removeAll(preTasks);
+ postTasks.add(form.getTaskId());
+
+ updateStatus(user);
+ User updated = userDAO.save(user);
+
+ // see if there is any propagation to be done
+ PropagationByResource propByRes = engine.getRuntimeService().getVariable(
+ user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
+
+ // fetch - if available - the encrypted password
+ String clearPassword = null;
+ String encryptedPwd = engine.getRuntimeService().getVariable(user.getWorkflowId(), ENCRYPTED_PWD, String.class);
+ if (StringUtils.isNotBlank(encryptedPwd)) {
+ clearPassword = decrypt(encryptedPwd);
+ }
+
+ // supports approval chains
+ saveForFormSubmit(user, clearPassword, propByRes);
+
+ UserPatch userPatch = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_PATCH, UserPatch.class);
+ if (userPatch == null) {
+ userPatch = new UserPatch();
+ userPatch.setKey(updated.getKey());
+ userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).value(clearPassword).build());
+
+ if (propByRes != null) {
+ userPatch.getPassword().getResources().addAll(propByRes.get(ResourceOperation.CREATE));
+ }
+ }
+
+ return new WorkflowResult<>(userPatch, propByRes, postTasks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
new file mode 100644
index 0000000..e107345
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUtils.java
@@ -0,0 +1,39 @@
+/*
+ * 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 org.apache.commons.collections4.IterableUtils;
+import org.apache.commons.collections4.Predicate;
+import org.apache.syncope.core.persistence.api.entity.user.UMembership;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.springframework.transaction.annotation.Transactional;
+
+public class FlowableUtils {
+
+ @Transactional(readOnly = true)
+ public boolean isUserIngroup(final User user, final String groupName) {
+ return IterableUtils.matchesAny(user.getMemberships(), new Predicate<UMembership>() {
+
+ @Override
+ public boolean evaluate(final UMembership membership) {
+ return groupName != null && groupName.equals(membership.getRightEnd().getName());
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
new file mode 100644
index 0000000..88b43ac
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeEntitiesVariableType.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.activiti.engine.impl.variable.SerializableType;
+import org.apache.syncope.core.persistence.api.entity.Entity;
+
+/**
+ * Flowable variable type for handling Syncope entities as Flowable variables.
+ * Main purpose: avoid Flowable to handle Syncope entities as JPA entities,
+ * since this can cause troubles with transactions.
+ */
+public class SyncopeEntitiesVariableType extends SerializableType {
+
+ @Override
+ public boolean isAbleToStore(final Object value) {
+ return value instanceof Entity;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupManager.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupManager.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupManager.java
new file mode 100644
index 0000000..f73e45d
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupManager.java
@@ -0,0 +1,122 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.activiti.engine.identity.Group;
+import org.activiti.engine.identity.GroupQuery;
+import org.activiti.engine.impl.GroupQueryImpl;
+import org.activiti.engine.impl.Page;
+import org.activiti.engine.impl.persistence.entity.GroupEntity;
+import org.activiti.engine.impl.persistence.entity.GroupIdentityManager;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class SyncopeGroupManager implements GroupIdentityManager, SyncopeSession {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private GroupDAO groupDAO;
+
+ @Override
+ public Class<?> getType() {
+ return GroupIdentityManager.class;
+ }
+
+ @Override
+ public Group createNewGroup(final String groupId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public GroupQuery createNewGroupQuery() {
+ return new SyncopeGroupQueryImpl(groupDAO);
+ }
+
+ @Override
+ public void deleteGroup(final String groupId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<Group> findGroupsByUser(final String userId) {
+ List<Group> result = Collections.emptyList();
+ User user = userDAO.findByUsername(userId);
+ if (user != null) {
+ result = new ArrayList<>();
+ for (String groupName : userDAO.findAllGroupNames(user)) {
+ result.add(new GroupEntity(groupName));
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public List<Group> findGroupByQueryCriteria(final GroupQueryImpl query, final Page page) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long findGroupCountByQueryCriteria(final GroupQueryImpl query) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<Group> findGroupsByNativeQuery(final Map<String, Object> parameterMap, final int firstResult,
+ final int maxResults) {
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long findGroupCountByNativeQuery(final Map<String, Object> parameterMap) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void insertGroup(final Group group) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void updateGroup(final Group updatedGroup) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isNewGroup(final Group group) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
new file mode 100644
index 0000000..b3b32cd
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeGroupQueryImpl.java
@@ -0,0 +1,163 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.activiti.engine.ActivitiException;
+import org.activiti.engine.identity.Group;
+import org.activiti.engine.identity.GroupQuery;
+import org.activiti.engine.impl.persistence.entity.GroupEntity;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+
+public class SyncopeGroupQueryImpl implements GroupQuery {
+
+ private final GroupDAO groupDAO;
+
+ private String groupId;
+
+ private List<Group> result;
+
+ public SyncopeGroupQueryImpl(final GroupDAO groupDAO) {
+ this.groupDAO = groupDAO;
+ }
+
+ @Override
+ public GroupQuery groupId(final String groupId) {
+ try {
+ this.groupId = groupId;
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+
+ return this;
+ }
+
+ @Override
+ public GroupQuery groupName(final String groupName) {
+ return this;
+ }
+
+ @Override
+ public GroupQuery groupNameLike(final String groupNameLike) {
+ return this;
+ }
+
+ @Override
+ public GroupQuery groupType(final String groupType) {
+ return this;
+ }
+
+ @Override
+ public GroupQuery groupMember(final String groupMemberUserId) {
+ return this;
+ }
+
+ @Override
+ public GroupQuery orderByGroupId() {
+ return this;
+ }
+
+ @Override
+ public GroupQuery orderByGroupName() {
+ return this;
+ }
+
+ @Override
+ public GroupQuery orderByGroupType() {
+ return this;
+ }
+
+ @Override
+ public GroupQuery asc() {
+ return this;
+ }
+
+ @Override
+ public GroupQuery desc() {
+ return this;
+ }
+
+ private Group fromSyncopeGroup(final org.apache.syncope.core.persistence.api.entity.group.Group group) {
+ return new GroupEntity(group.getKey());
+ }
+
+ private void execute() {
+ if (groupId != null) {
+ org.apache.syncope.core.persistence.api.entity.group.Group syncopeGroup = groupDAO.findByName(groupId);
+ if (syncopeGroup == null) {
+ result = Collections.emptyList();
+ } else {
+ result = Collections.singletonList(fromSyncopeGroup(syncopeGroup));
+ }
+ }
+ if (result == null) {
+ result = CollectionUtils.collect(groupDAO.findAll(),
+ new Transformer<org.apache.syncope.core.persistence.api.entity.group.Group, Group>() {
+
+ @Override
+ public Group transform(final org.apache.syncope.core.persistence.api.entity.group.Group user) {
+ return fromSyncopeGroup(user);
+ }
+
+ }, new ArrayList<Group>());
+ }
+ }
+
+ @Override
+ public long count() {
+ if (result == null) {
+ execute();
+ }
+ return result.size();
+ }
+
+ @Override
+ public Group singleResult() {
+ if (result == null) {
+ execute();
+ }
+ if (result.isEmpty()) {
+ throw new ActivitiException("Empty result");
+ }
+
+ return result.get(0);
+ }
+
+ @Override
+ public List<Group> list() {
+ if (result == null) {
+ execute();
+ }
+ return result;
+ }
+
+ @Override
+ public List<Group> listPage(final int firstResult, final int maxResults) {
+ return list();
+ }
+
+ @Override
+ public GroupQuery potentialStarter(final String procDefId) {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
new file mode 100644
index 0000000..f15d18d
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSession.java
@@ -0,0 +1,26 @@
+/*
+ * 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 org.activiti.engine.impl.interceptor.Session;
+
+public interface SyncopeSession extends Session {
+
+ Class<?> getType();
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
new file mode 100644
index 0000000..4758d4e
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeSessionFactory.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.activiti.engine.impl.interceptor.Session;
+import org.activiti.engine.impl.interceptor.SessionFactory;
+
+public class SyncopeSessionFactory implements SessionFactory {
+
+ private SyncopeSession syncopeSession;
+
+ @Override
+ public Class<?> getSessionType() {
+ return syncopeSession.getType();
+ }
+
+ @Override
+ public Session openSession() {
+ return syncopeSession;
+ }
+
+ public SyncopeSession getSyncopeSession() {
+ return syncopeSession;
+ }
+
+ public void setSyncopeSession(final SyncopeSession syncopeSession) {
+ this.syncopeSession = syncopeSession;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserManager.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserManager.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserManager.java
new file mode 100644
index 0000000..a6cc201
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserManager.java
@@ -0,0 +1,166 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.activiti.engine.identity.Group;
+import org.activiti.engine.identity.Picture;
+import org.activiti.engine.identity.User;
+import org.activiti.engine.identity.UserQuery;
+import org.activiti.engine.impl.Page;
+import org.activiti.engine.impl.UserQueryImpl;
+import org.activiti.engine.impl.persistence.entity.GroupEntity;
+import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
+import org.activiti.engine.impl.persistence.entity.UserEntity;
+import org.activiti.engine.impl.persistence.entity.UserIdentityManager;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class SyncopeUserManager implements UserIdentityManager, SyncopeSession {
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Autowired
+ private GroupDAO groupDAO;
+
+ @Override
+ public Class<?> getType() {
+ return UserIdentityManager.class;
+ }
+
+ @Override
+ public Boolean checkPassword(final String userKey, final String password) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public User createNewUser(final String userKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public UserQuery createNewUserQuery() {
+ return new SyncopeUserQueryImpl(userDAO, groupDAO);
+ }
+
+ @Override
+ public void deleteUser(final String userKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<Group> findGroupsByUser(final String username) {
+ List<Group> result = Collections.emptyList();
+ org.apache.syncope.core.persistence.api.entity.user.User user = userDAO.findByUsername(username);
+ if (user != null) {
+ result = new ArrayList<>();
+ for (String groupName : userDAO.findAllGroupNames(user)) {
+ result.add(new GroupEntity(groupName));
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public UserEntity findUserById(final String username) {
+ UserEntity result = null;
+ org.apache.syncope.core.persistence.api.entity.user.User user = userDAO.findByUsername(username);
+ if (user != null) {
+ result = new UserEntity(username);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void insertUser(final User user) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isNewUser(final User user) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void updateUser(final User updatedUser) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Picture getUserPicture(final String string) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setUserPicture(final String string, final Picture pctr) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<User> findUserByQueryCriteria(final UserQueryImpl query, final Page page) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long findUserCountByQueryCriteria(final UserQueryImpl query) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IdentityInfoEntity findUserInfoByUserIdAndKey(final String userKey, final String key) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<String> findUserInfoKeysByUserIdAndType(final String userKey, final String type) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<User> findPotentialStarterUsers(final String proceDefId) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<User> findUsersByNativeQuery(final Map<String, Object> parameterMap,
+ final int firstResult, final int maxResults) {
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public long findUserCountByNativeQuery(final Map<String, Object> parameterMap) {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
new file mode 100644
index 0000000..9231a4f
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/SyncopeUserQueryImpl.java
@@ -0,0 +1,211 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.activiti.engine.ActivitiException;
+import org.activiti.engine.identity.User;
+import org.activiti.engine.identity.UserQuery;
+import org.activiti.engine.impl.persistence.entity.UserEntity;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.user.UMembership;
+
+public class SyncopeUserQueryImpl implements UserQuery {
+
+ private final UserDAO userDAO;
+
+ private final GroupDAO groupDAO;
+
+ private String username;
+
+ private String memberOf;
+
+ private List<User> result;
+
+ public SyncopeUserQueryImpl(final UserDAO userDAO, final GroupDAO groupDAO) {
+ this.userDAO = userDAO;
+ this.groupDAO = groupDAO;
+ }
+
+ @Override
+ public UserQuery userId(final String id) {
+ this.username = id;
+ return this;
+ }
+
+ @Override
+ public UserQuery userFirstName(final String firstName) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userFirstNameLike(final String firstNameLike) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userLastName(final String lastName) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userLastNameLike(final String lastNameLike) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userFullNameLike(final String fullNameLike) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userEmail(final String email) {
+ return this;
+ }
+
+ @Override
+ public UserQuery userEmailLike(final String emailLike) {
+ return this;
+ }
+
+ @Override
+ public UserQuery memberOfGroup(final String groupId) {
+ memberOf = groupId;
+ return this;
+ }
+
+ @Override
+ public UserQuery orderByUserId() {
+ return this;
+ }
+
+ @Override
+ public UserQuery orderByUserFirstName() {
+ return this;
+ }
+
+ @Override
+ public UserQuery orderByUserLastName() {
+ return this;
+ }
+
+ @Override
+ public UserQuery orderByUserEmail() {
+ return this;
+ }
+
+ @Override
+ public UserQuery asc() {
+ return this;
+ }
+
+ @Override
+ public UserQuery desc() {
+ return this;
+ }
+
+ private User fromSyncopeUser(final org.apache.syncope.core.persistence.api.entity.user.User user) {
+ return new UserEntity(user.getUsername());
+ }
+
+ private void execute() {
+ if (username != null) {
+ org.apache.syncope.core.persistence.api.entity.user.User user = userDAO.findByUsername(username);
+ if (user == null) {
+ result = Collections.<User>emptyList();
+ } else if (memberOf == null || userDAO.findAllGroupNames(user).contains(memberOf)) {
+ result = Collections.singletonList(fromSyncopeUser(user));
+ }
+ }
+ if (memberOf != null) {
+ Group group = groupDAO.findByName(memberOf);
+ if (group == null) {
+ result = Collections.<User>emptyList();
+ } else {
+ result = new ArrayList<>();
+ List<UMembership> memberships = groupDAO.findUMemberships(group);
+ for (UMembership membership : memberships) {
+ User user = fromSyncopeUser(membership.getLeftEnd());
+ if (!result.contains(user)) {
+ result.add(user);
+ }
+ }
+ }
+ }
+ // THIS CAN BE *VERY* DANGEROUS
+ if (result == null) {
+ result = CollectionUtils.collect(userDAO.findAll(),
+ new Transformer<org.apache.syncope.core.persistence.api.entity.user.User, User>() {
+
+ @Override
+ public User transform(final org.apache.syncope.core.persistence.api.entity.user.User user) {
+ return fromSyncopeUser(user);
+ }
+
+ }, new ArrayList<User>());
+ }
+ }
+
+ @Override
+ public long count() {
+ if (result == null) {
+ execute();
+ }
+ return result.size();
+ }
+
+ @Override
+ public User singleResult() {
+ if (result == null) {
+ execute();
+ }
+ if (result.isEmpty()) {
+ throw new ActivitiException("Empty result");
+ }
+
+ return result.get(0);
+ }
+
+ @Override
+ public List<User> list() {
+ if (result == null) {
+ execute();
+ }
+ return result;
+ }
+
+ @Override
+ public List<User> listPage(final int firstResult, final int maxResults) {
+ if (result == null) {
+ execute();
+ }
+ return result.subList(firstResult, firstResult + maxResults - 1);
+ }
+
+ @Override
+ public UserQuery potentialStarter(final String string) {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
new file mode 100644
index 0000000..c8e9141
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngine.java
@@ -0,0 +1,114 @@
+/*
+ * 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.spring;
+
+import java.util.Collections;
+import java.util.Map;
+import javax.sql.DataSource;
+import org.activiti.engine.DynamicBpmnService;
+import org.activiti.engine.FormService;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.ManagementService;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.ProcessEngineConfiguration;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.impl.ProcessEngineImpl;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
+
+/**
+ * {@link ProcessEngine} delegating actual method invocation to the inner map of {@link ProcessEngine} instances,
+ * one for each Syncope domain.
+ */
+public class DomainProcessEngine implements ProcessEngine {
+
+ private final Map<String, ProcessEngine> engines;
+
+ public DomainProcessEngine(final Map<String, ProcessEngine> engines) {
+ this.engines = Collections.synchronizedMap(engines);
+ }
+
+ public Map<String, ProcessEngine> getEngines() {
+ return engines;
+ }
+
+ @Override
+ public String getName() {
+ return engines.get(AuthContextUtils.getDomain()).getName();
+ }
+
+ @Override
+ public void close() {
+ for (ProcessEngine engine : engines.values()) {
+ engine.close();
+ }
+ }
+
+ @Override
+ public RepositoryService getRepositoryService() {
+ return engines.get(AuthContextUtils.getDomain()).getRepositoryService();
+ }
+
+ @Override
+ public RuntimeService getRuntimeService() {
+ return engines.get(AuthContextUtils.getDomain()).getRuntimeService();
+ }
+
+ @Override
+ public FormService getFormService() {
+ return engines.get(AuthContextUtils.getDomain()).getFormService();
+ }
+
+ @Override
+ public TaskService getTaskService() {
+ return engines.get(AuthContextUtils.getDomain()).getTaskService();
+ }
+
+ @Override
+ public HistoryService getHistoryService() {
+ return engines.get(AuthContextUtils.getDomain()).getHistoryService();
+ }
+
+ @Override
+ public IdentityService getIdentityService() {
+ return engines.get(AuthContextUtils.getDomain()).getIdentityService();
+ }
+
+ @Override
+ public ManagementService getManagementService() {
+ return engines.get(AuthContextUtils.getDomain()).getManagementService();
+ }
+
+ @Override
+ public ProcessEngineConfiguration getProcessEngineConfiguration() {
+ return engines.get(AuthContextUtils.getDomain()).getProcessEngineConfiguration();
+ }
+
+ @Override
+ public DynamicBpmnService getDynamicBpmnService() {
+ return engines.get(AuthContextUtils.getDomain()).getDynamicBpmnService();
+ }
+
+ public DataSource getDataSource() {
+ ProcessEngineImpl engine = (ProcessEngineImpl) engines.get(AuthContextUtils.getDomain());
+ return engine.getProcessEngineConfiguration().getDataSource();
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
new file mode 100644
index 0000000..620d6b9
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java
@@ -0,0 +1,104 @@
+/*
+ * 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.spring;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.sql.DataSource;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.impl.cfg.SpringBeanFactoryProxyMap;
+import org.activiti.spring.SpringExpressionManager;
+import org.activiti.spring.SpringProcessEngineConfiguration;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.transaction.PlatformTransactionManager;
+
+/**
+ * Spring factory for {@link DomainProcessEngine} which takes the provided {@link SpringProcessEngineConfiguration} as
+ * template for each of the configured Syncope domains.
+ */
+public class DomainProcessEngineFactoryBean
+ implements FactoryBean<DomainProcessEngine>, DisposableBean, ApplicationContextAware {
+
+ private ApplicationContext ctx;
+
+ private DomainProcessEngine engine;
+
+ @Override
+ public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+ this.ctx = ctx;
+ }
+
+ @Override
+ public DomainProcessEngine getObject() throws Exception {
+ if (engine == null) {
+ Map<String, ProcessEngine> engines = new HashMap<>();
+
+ for (Map.Entry<String, DataSource> entry : ctx.getBeansOfType(DataSource.class).entrySet()) {
+ if (!entry.getKey().startsWith("local")) {
+ String domain = StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName());
+ DataSource dataSource = entry.getValue();
+ PlatformTransactionManager transactionManager = ctx.getBean(
+ domain + "TransactionManager", PlatformTransactionManager.class);
+ Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");
+
+ SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
+ conf.setDataSource(dataSource);
+ conf.setTransactionManager(transactionManager);
+ conf.setTransactionsExternallyManaged(true);
+ conf.setJpaEntityManagerFactory(entityManagerFactory);
+ if (conf.getBeans() == null) {
+ conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
+ }
+ if (conf.getExpressionManager() == null) {
+ conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
+ }
+
+ engines.put(domain, conf.buildProcessEngine());
+ }
+ }
+
+ engine = new DomainProcessEngine(engines);
+ }
+
+ return engine;
+ }
+
+ @Override
+ public Class<DomainProcessEngine> getObjectType() {
+ return DomainProcessEngine.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ if (engine != null) {
+ engine.close();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
new file mode 100644
index 0000000..c3a5ba1
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AbstractFlowableServiceTask.java
@@ -0,0 +1,45 @@
+/*
+ * 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.task;
+
+import org.activiti.engine.ProcessEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Abstract base class for Flowable's service tasks in Syncope, with Spring support.
+ */
+@Component
+public abstract class AbstractFlowableServiceTask {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractFlowableServiceTask.class);
+
+ @Autowired
+ protected ProcessEngine engine;
+
+ @Transactional(rollbackFor = { Throwable.class })
+ public void execute(final String executionId) {
+ doExecute(executionId);
+ }
+
+ protected abstract void doExecute(final String executionId);
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
new file mode 100644
index 0000000..8aeb9f9
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/AutoActivate.java
@@ -0,0 +1,31 @@
+/*
+ * 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.task;
+
+import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AutoActivate extends AbstractFlowableServiceTask {
+
+ @Override
+ protected void doExecute(final String executionId) {
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROPAGATE_ENABLE, Boolean.TRUE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
new file mode 100644
index 0000000..be9bfec
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Create.java
@@ -0,0 +1,52 @@
+/*
+ * 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.task;
+
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+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.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Create extends AbstractFlowableServiceTask {
+
+ @Autowired
+ private UserDataBinder dataBinder;
+
+ @Autowired
+ private EntityFactory entityFactory;
+
+ @Override
+ protected void doExecute(final String executionId) {
+ UserTO userTO = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, UserTO.class);
+ Boolean storePassword = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.STORE_PASSWORD, Boolean.class);
+ // create and set workflow id
+ User user = entityFactory.newEntity(User.class);
+ dataBinder.create(user, userTO, storePassword == null ? true : storePassword);
+ user.setWorkflowId(executionId);
+
+ // report user as result
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
new file mode 100644
index 0000000..d4efe09
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/Delete.java
@@ -0,0 +1,41 @@
+/*
+ * 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.task;
+
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.workflow.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Delete extends AbstractFlowableServiceTask {
+
+ @Override
+ protected void doExecute(final String executionId) {
+ User user = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
+
+ // Do something with user...
+ if (user != null) {
+ user.checkToken("");
+ }
+
+ // remove user variable
+ engine.getRuntimeService().removeVariable(executionId, FlowableUserWorkflowAdapter.USER);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/85ddca5b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
new file mode 100644
index 0000000..adbd31a
--- /dev/null
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/task/GenerateToken.java
@@ -0,0 +1,44 @@
+/*
+ * 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.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.flowable.FlowableUserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GenerateToken extends AbstractFlowableServiceTask {
+
+ @Autowired
+ private ConfDAO confDAO;
+
+ @Override
+ protected void doExecute(final String executionId) {
+ User user = engine.getRuntimeService().
+ getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
+
+ user.generateToken(
+ confDAO.find("token.length", "256").getValues().get(0).getLongValue().intValue(),
+ confDAO.find("token.expireTime", "60").getValues().get(0).getLongValue().intValue());
+
+ engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
+ }
+}