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 2019/03/25 16:46:59 UTC

[syncope] branch 2_0_X updated: More robust user init for Flowable

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

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


The following commit(s) were added to refs/heads/2_0_X by this push:
     new 8177db1  More robust user init for Flowable
8177db1 is described below

commit 8177db1bfd7fdf3b3054bcddc65cfa63ae85a23c
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Mon Mar 25 17:46:50 2019 +0100

    More robust user init for Flowable
---
 archetype/pom.xml                                  |  7 ++++
 fit/core-reference/pom.xml                         | 35 ------------------
 .../fit/core/reference/ITImplementationLookup.java | 41 ++++++++++++++++++++++
 standalone/pom.xml                                 | 41 +++++-----------------
 4 files changed, 56 insertions(+), 68 deletions(-)

diff --git a/archetype/pom.xml b/archetype/pom.xml
index a85107f..da6e82b 100644
--- a/archetype/pom.xml
+++ b/archetype/pom.xml
@@ -183,6 +183,13 @@ under the License.
         </includes>
       </resource>      
       <resource>
+        <directory>../fit/core-reference/src/test/resources</directory>
+        <targetPath>${project.build.outputDirectory}/archetype-resources/core/src/test/resources</targetPath>
+        <includes>
+          <include>mail.properties</include>
+        </includes>
+      </resource>
+      <resource>
         <directory>../fit/core-reference/src/test/resources/scriptedsql</directory>
         <targetPath>${project.build.outputDirectory}/archetype-resources/core/src/test/resources/scriptedsql</targetPath>
       </resource>
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index f4f5e09..0663748 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -1534,41 +1534,6 @@ under the License.
       </dependencies>
       
       <build>
-        <plugins>
-          <!-- Adds Activiti test content -->
-          <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>xml-maven-plugin</artifactId>
-            <inherited>true</inherited>
-            <executions>
-              <execution>
-                <phase>prepare-package</phase>
-                <goals>
-                  <goal>transform</goal>
-                </goals>
-              </execution>
-            </executions>
-            <configuration>
-              <transformationSets>
-                <transformationSet>
-                  <dir>${project.build.directory}/classes</dir>
-                  <includes>
-                    <include>domains/MasterContent.xml</include>
-                  </includes>
-                  <outputDir>${project.build.directory}/classes</outputDir>
-                  <stylesheet>${basedir}/src/test/resources/addActivitiToContent.xsl</stylesheet>
-                  <outputProperties>
-                    <outputProperty>
-                      <name>indent</name>
-                      <value>yes</value>
-                    </outputProperty>
-                  </outputProperties>
-                </transformationSet>
-              </transformationSets>
-            </configuration>
-          </plugin>                    
-        </plugins>
-        
         <resources>
           <resource>
             <directory>src/main/resources</directory>
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
index 5e24483..bbac120 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.fit.core.reference;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -69,8 +70,10 @@ import org.apache.syncope.core.provisioning.java.pushpull.LDAPMembershipPullActi
 import org.apache.syncope.core.provisioning.java.pushpull.LDAPPasswordPullActions;
 import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.apache.syncope.core.spring.security.SyncopeJWTSSOProvider;
+import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
 import org.springframework.aop.support.AopUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
  * Static implementation providing information about the integration test environment.
@@ -206,6 +209,9 @@ public class ITImplementationLookup implements ImplementationLookup {
     };
 
     @Autowired
+    private UserWorkflowAdapter uwf;
+
+    @Autowired
     private AnySearchDAO anySearchDAO;
 
     @Autowired
@@ -221,6 +227,41 @@ public class ITImplementationLookup implements ImplementationLookup {
 
     @Override
     public void load() {
+        // in case Activiti is enabled, enable modifications for test users
+        if (AopUtils.getTargetClass(uwf).getName().contains("Activiti")) {
+            for (final Map.Entry<String, DataSource> entry : domainsHolder.getDomains().entrySet()) {
+                AuthContextUtils.execWithAuthContext(entry.getKey(), new AuthContextUtils.Executable<Void>() {
+
+                    @Override
+                    public Void exec() {
+                        JdbcTemplate jdbcTemplate = new JdbcTemplate(entry.getValue());
+                        String procDef = jdbcTemplate.queryForObject(
+                                "SELECT ID_ FROM ACT_RE_PROCDEF WHERE KEY_=?", String.class, "userWorkflow");
+
+                        int counter = 0;
+                        for (String user : jdbcTemplate.queryForList("SELECT id FROM SyncopeUser", String.class)) {
+                            int value = counter++;
+                            jdbcTemplate.update("INSERT INTO "
+                                    + "ACT_RU_EXECUTION(ID_,REV_,PROC_INST_ID_,BUSINESS_KEY_,PROC_DEF_ID_,ACT_ID_,"
+                                    + "IS_ACTIVE_,IS_CONCURRENT_,IS_SCOPE_,IS_EVENT_SCOPE_,SUSPENSION_STATE_) "
+                                    + "VALUES(?,?,?,?,?,?,?,?,?,?,?)",
+                                    value, 2, value, "userWorkflow:" + user, procDef, "active",
+                                    true, false, true, false, true);
+
+                            value = counter++;
+                            jdbcTemplate.update("INSERT INTO "
+                                    + "ACT_RU_TASK(ID_,REV_,EXECUTION_ID_,PROC_INST_ID_,PROC_DEF_ID_,NAME_,"
+                                    + "TASK_DEF_KEY_,PRIORITY_,CREATE_TIME_) "
+                                    + "VALUES(?,?,?,?,?,?,?,?,?)",
+                                    value, 2, value - 1, value - 1, procDef, "Active", "active", 50, new Date());
+                        }
+
+                        return null;
+                    }
+                });
+            }
+        }
+
         // in case the Elasticsearch extension is enabled, reinit a clean index for all available domains
         if (AopUtils.getTargetClass(anySearchDAO).getName().contains("Elasticsearch")) {
             for (Map.Entry<String, DataSource> entry : domainsHolder.getDomains().entrySet()) {
diff --git a/standalone/pom.xml b/standalone/pom.xml
index 0f15a43..a567a0c 100644
--- a/standalone/pom.xml
+++ b/standalone/pom.xml
@@ -78,39 +78,6 @@ under the License.
   <build>
 
     <plugins>
-      <!-- Adds Activiti test content -->
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>xml-maven-plugin</artifactId>
-        <inherited>true</inherited>
-        <executions>
-          <execution>
-            <phase>prepare-package</phase>
-            <goals>
-              <goal>transform</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <transformationSets>
-            <transformationSet>
-              <dir>${project.build.directory}/classes/core</dir>
-              <includes>
-                <include>domains/MasterContent.xml</include>
-              </includes>
-              <outputDir>${project.build.directory}/classes/core</outputDir>
-              <stylesheet>${basedir}/../fit/core-reference/src/test/resources/addActivitiToContent.xsl</stylesheet>
-              <outputProperties>
-                <outputProperty>
-                  <name>indent</name>
-                  <value>yes</value>
-                </outputProperty>
-              </outputProperties>
-            </transformationSet>
-          </transformationSets>
-        </configuration>
-      </plugin>
-          
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
@@ -252,6 +219,14 @@ under the License.
         <filtering>true</filtering>
       </resource>
       <resource>
+        <directory>../fit/core-reference/src/test/resources</directory>
+        <includes>
+          <include>mail.properties</include>
+        </includes>
+        <targetPath>core</targetPath>
+        <filtering>true</filtering>
+      </resource>
+      <resource>
         <directory>../fit/core-reference/src/test/resources/scriptedsql</directory>
         <targetPath>core/scriptedsql</targetPath>
         <filtering>true</filtering>