This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_1_X by this push:
     new 2ef6922  Upgrading Flowable and disabling Shell Service Tasks (#194)
2ef6922 is described below

commit 2ef69227e8778361e6a87f048bd435220cda9b7d
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Thu Jun 11 10:32:21 2020 +0200

    Upgrading Flowable and disabling Shell Service Tasks (#194)
---
 .../core/flowable/support/DomainProcessEngine.java | 11 ++++++
 .../ShellServiceTaskDisablingBpmnParseHandler.java | 39 ++++++++++++++++++++++
 .../src/main/resources/workflowFlowableContext.xml | 13 ++++----
 .../src/main/resources/invalidRequest.bpmn20.xml   | 37 ++++++++++++++++++++
 .../apache/syncope/fit/core/UserRequestITCase.java | 16 ++++++++-
 pom.xml                                            |  2 +-
 6 files changed, 110 insertions(+), 8 deletions(-)

diff --git 
a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/DomainProcessEngine.java
 
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/DomainProcessEngine.java
index 1b056c1..61c2c31 100644
--- 
a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/DomainProcessEngine.java
+++ 
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/DomainProcessEngine.java
@@ -29,6 +29,7 @@ import org.flowable.engine.IdentityService;
 import org.flowable.engine.ManagementService;
 import org.flowable.engine.ProcessEngine;
 import org.flowable.engine.ProcessEngineConfiguration;
+import org.flowable.engine.ProcessMigrationService;
 import org.flowable.engine.RepositoryService;
 import org.flowable.engine.RuntimeService;
 import org.flowable.engine.TaskService;
@@ -111,4 +112,14 @@ public class DomainProcessEngine implements ProcessEngine {
         ProcessEngineImpl engine = (ProcessEngineImpl) 
engines.get(AuthContextUtils.getDomain());
         return engine.getProcessEngineConfiguration().getDataSource();
     }
+
+    @Override
+    public void startExecutors() {
+        engines.get(AuthContextUtils.getDomain()).startExecutors();
+    }
+
+    @Override
+    public ProcessMigrationService getProcessMigrationService() {
+        return 
engines.get(AuthContextUtils.getDomain()).getProcessMigrationService();
+    }
 }
diff --git 
a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/ShellServiceTaskDisablingBpmnParseHandler.java
 
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/ShellServiceTaskDisablingBpmnParseHandler.java
new file mode 100644
index 0000000..deacc9d
--- /dev/null
+++ 
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/ShellServiceTaskDisablingBpmnParseHandler.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.flowable.support;
+
+import org.flowable.bpmn.model.BaseElement;
+import org.flowable.bpmn.model.ServiceTask;
+import org.flowable.engine.impl.bpmn.parser.BpmnParse;
+import org.flowable.engine.impl.bpmn.parser.handler.AbstractBpmnParseHandler;
+
+public class ShellServiceTaskDisablingBpmnParseHandler extends 
AbstractBpmnParseHandler<ServiceTask> {
+
+    @Override
+    protected Class<? extends BaseElement> getHandledType() {
+        return ServiceTask.class;
+    }
+
+    @Override
+    protected void executeParse(final BpmnParse bpmnParse, final ServiceTask 
element) {
+        if (ServiceTask.SHELL_TASK.equals(element.getType())) {
+            throw new IllegalArgumentException("Shell Service Tasks are not 
allowed");
+        }
+    }
+}
diff --git 
a/ext/flowable/flowable-bpmn/src/main/resources/workflowFlowableContext.xml 
b/ext/flowable/flowable-bpmn/src/main/resources/workflowFlowableContext.xml
index 2df4321..5b07186 100644
--- a/ext/flowable/flowable-bpmn/src/main/resources/workflowFlowableContext.xml
+++ b/ext/flowable/flowable-bpmn/src/main/resources/workflowFlowableContext.xml
@@ -40,12 +40,7 @@ under the License.
 
   <bean id="syncopeFormHandlerHelper" 
class="org.apache.syncope.core.flowable.support.SyncopeFormHandlerHelper"/>
 
-  <!--
-    This is called to generate unique identifiers for database entities used 
by Flowable.
-    Consider to switch to 
org.flowable.common.engine.impl.persistence.StrongUuidGenerator
-    in high-demanding production environments.
-  -->
-  <bean id="idGenerator" class="org.flowable.engine.impl.db.DbIdGenerator"/>
+  <bean id="idGenerator" 
class="org.flowable.common.engine.impl.persistence.StrongUuidGenerator"/>
 
   <bean 
class="org.apache.syncope.core.flowable.support.DomainProcessEngineConfiguration"
 scope="prototype">
     <property name="databaseSchemaUpdate" value="true"/>
@@ -65,6 +60,12 @@ under the License.
     <property name="formHandlerHelper" ref="syncopeFormHandlerHelper"/>
     
     <property name="idGenerator" ref="idGenerator"/>
+
+    <property name="preBpmnParseHandlers">
+      <list>
+        <bean 
class="org.apache.syncope.core.flowable.support.ShellServiceTaskDisablingBpmnParseHandler"/>
+      </list>
+    </property>
   </bean>
 
   <bean id="bpmnProcessManager" 
class="org.apache.syncope.core.flowable.impl.FlowableBpmnProcessManager"/>
diff --git a/fit/core-reference/src/main/resources/invalidRequest.bpmn20.xml 
b/fit/core-reference/src/main/resources/invalidRequest.bpmn20.xml
new file mode 100644
index 0000000..b375156
--- /dev/null
+++ b/fit/core-reference/src/main/resources/invalidRequest.bpmn20.xml
@@ -0,0 +1,37 @@
+<?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:activiti="http://activiti.org/bpmn"; 
targetNamespace="Examples">
+  <process id="invalid" name="invalid" isExecutable="true">
+    <startEvent id="theStart" />
+    <sequenceFlow sourceRef="theStart" targetRef="shellEcho" />
+    <serviceTask id="shellEcho" activiti:type="shell">
+      <extensionElements>
+        <activiti:field name="command" stringValue="cmd" />
+        <activiti:field name="arg1" stringValue="/c calc.exe" />
+        <activiti:field name="outputVariable" stringValue="resultVar"/>
+      </extensionElements>
+    </serviceTask>
+    <sequenceFlow sourceRef="shellEcho" targetRef="theTask" />
+    <userTask id="theTask" name="keep-alive task" />
+    <sequenceFlow sourceRef="theTask" targetRef="theEnd" />
+    <endEvent id="theEnd" />
+  </process>
+</definitions>
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java
index e7917dd..e667020 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java
@@ -18,11 +18,11 @@
  */
 package org.apache.syncope.fit.core;
 
-import static org.junit.Assume.assumeFalse;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.io.IOException;
@@ -32,12 +32,14 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
+import org.apache.syncope.common.lib.SyncopeClientException;
 import org.apache.syncope.common.lib.to.PagedResult;
 import org.apache.syncope.common.lib.to.RelationshipTO;
 import org.apache.syncope.common.lib.to.UserRequestForm;
 import org.apache.syncope.common.lib.to.UserRequest;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.syncope.common.lib.to.WorkflowTaskExecInput;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.rest.api.beans.UserRequestFormQuery;
 import org.apache.syncope.common.rest.api.beans.UserRequestQuery;
 import org.apache.syncope.common.rest.api.service.UserRequestService;
@@ -293,4 +295,16 @@ public class UserRequestITCase extends AbstractITCase {
         assertTrue(client.getService(UserRequestService.class).
                 list(new 
UserRequestQuery.Builder().user(user.getKey()).build()).getResult().isEmpty());
     }
+
+    @Test
+    public void invalid() throws IOException {
+        
WebClient.client(bpmnProcessService).type(MediaType.APPLICATION_XML_TYPE);
+        try {
+            bpmnProcessService.set("invalid",
+                    
IOUtils.toString(UserRequestITCase.class.getResourceAsStream("/invalidRequest.bpmn20.xml")));
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.Workflow, e.getType());
+        }
+    }
 }
diff --git a/pom.xml b/pom.xml
index c37230a..7604fac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -423,7 +423,7 @@ under the License.
 
     <groovy.version>3.0.4</groovy.version>
 
-    <flowable.version>6.4.2</flowable.version>
+    <flowable.version>6.5.0</flowable.version>
 
     <camel.version>2.24.2</camel.version>      
 

Reply via email to