syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] syncope git commit: [SYNCOPE-769] Better fix for SYNCOPE-735, which avoids writing useless history entries rather than cleaning them up afterwards
Date Thu, 18 Feb 2016 16:10:06 GMT
[SYNCOPE-769] Better fix for SYNCOPE-735, which avoids writing useless history entries rather
than cleaning them up afterwards


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/757608a7
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/757608a7
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/757608a7

Branch: refs/heads/master
Commit: 757608a7c7577b157aa6f2593a4f1ef782cc2ffd
Parents: 1802b3b
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Thu Feb 18 17:09:59 2016 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Thu Feb 18 17:09:59 2016 +0100

----------------------------------------------------------------------
 .../rest/api/service/UserWorkflowService.java   | 13 -----
 .../syncope/core/logic/UserWorkflowLogic.java   |  8 ---
 .../cxf/service/UserWorkflowServiceImpl.java    |  5 --
 .../activiti/ActivitiUserWorkflowAdapter.java   | 58 --------------------
 .../src/main/resources/workflow.properties      |  1 +
 .../main/resources/workflowActivitiContext.xml  |  1 +
 .../core/workflow/api/WorkflowAdapter.java      |  9 ---
 .../java/DefaultAnyObjectWorkflowAdapter.java   |  5 --
 .../java/DefaultGroupWorkflowAdapter.java       |  5 --
 .../java/DefaultUserWorkflowAdapter.java        |  5 --
 .../src/main/resources/workflow.properties      |  1 -
 .../src/main/resources/all/workflow.properties  |  1 +
 .../src/main/resources/workflow.properties      |  1 -
 .../syncope/fit/core/UserWorkflowITCase.java    | 39 ++-----------
 14 files changed, 7 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserWorkflowService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserWorkflowService.java
b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserWorkflowService.java
index a8e0a05..f4166d3 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserWorkflowService.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserWorkflowService.java
@@ -47,19 +47,6 @@ public interface UserWorkflowService extends JAXRSService {
     List<WorkflowFormTO> getForms();
 
     /**
-     * Returns a list of all available workflow forms with matching name, for the given user
key.
-     *
-     * @param userKey user key
-     * @param name form name
-     * @return list of all available workflow forms with matching name, fir the given user
key.
-     */
-    @GET
-    @Path("forms/{userKey}/{name}")
-    @Produces({ JAXRSService.APPLICATION_XML, MediaType.APPLICATION_JSON })
-    List<WorkflowFormTO> getFormsByName(
-            @NotNull @PathParam("userKey") final Long userKey, @NotNull @PathParam("name")
final String name);
-
-    /**
      * Returns a list of available forms for the given user key.
      *
      * @param userKey user key

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/core/logic/src/main/java/org/apache/syncope/core/logic/UserWorkflowLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/UserWorkflowLogic.java
b/core/logic/src/main/java/org/apache/syncope/core/logic/UserWorkflowLogic.java
index 59af419..ebde234 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/UserWorkflowLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/UserWorkflowLogic.java
@@ -95,14 +95,6 @@ public class UserWorkflowLogic extends AbstractTransactionalLogic<WorkflowFormTO
         return uwfAdapter.getForms();
     }
 
-    @PreAuthorize("hasRole('" + StandardEntitlement.WORKFLOW_FORM_READ + "') and hasRole('"
-            + StandardEntitlement.USER_READ + "')")
-    @Transactional(rollbackFor = { Throwable.class })
-    public List<WorkflowFormTO> getForms(final Long key, final String formName) {
-        User user = userDAO.authFind(key);
-        return uwfAdapter.getForms(user.getWorkflowId(), formName);
-    }
-
     @PreAuthorize("hasRole('" + StandardEntitlement.WORKFLOW_FORM_SUBMIT + "')")
     @Transactional(rollbackFor = { Throwable.class })
     public UserTO submitForm(final WorkflowFormTO form) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserWorkflowServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserWorkflowServiceImpl.java
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserWorkflowServiceImpl.java
index cc70e16..b396e40 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserWorkflowServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserWorkflowServiceImpl.java
@@ -56,9 +56,4 @@ public class UserWorkflowServiceImpl implements UserWorkflowService {
     public UserTO submitForm(final WorkflowFormTO form) {
         return lofic.submitForm(form);
     }
-
-    @Override
-    public List<WorkflowFormTO> getFormsByName(final Long userKey, final String taskName)
{
-        return lofic.getForms(userKey, taskName);
-    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/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 6fcad68..4436c52 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
@@ -74,7 +74,6 @@ 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.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -190,45 +189,6 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         return result;
     }
 
-    protected void cleanupHistory(final User user) {
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(engine.getDataSource());
-
-        List<String> taskIds = jdbcTemplate.queryForList(
-                "SELECT TASK_ID_ FROM ACT_HI_VARINST WHERE NAME_='" + TASK_IS_FORM
-                + "' AND LONG_=1 AND PROC_INST_ID_='" + user.getWorkflowId() + "'", String.class);
-
-        StringBuilder update = new StringBuilder();
-
-        update.append("DELETE FROM ACT_HI_VARINST WHERE PROC_INST_ID_='").append(user.getWorkflowId()).append("'
");
-        for (String taskId : taskIds) {
-            update.append("AND TASK_ID_<>'").append(taskId).append("' ");
-        }
-        jdbcTemplate.execute(update.toString());
-
-        update.setLength(0);
-        update.append("DELETE FROM ACT_HI_TASKINST WHERE PROC_INST_ID_='").append(user.getWorkflowId()).append("'
");
-        for (String taskId : taskIds) {
-            update.append("AND ID_<>'").append(taskId).append("' ");
-        }
-        jdbcTemplate.execute(update.toString());
-
-        update.setLength(0);
-        update.append("DELETE FROM ACT_HI_ACTINST WHERE PROC_INST_ID_='").append(user.getWorkflowId()).append("'
");
-        for (String taskId : taskIds) {
-            update.append("AND TASK_ID_<>'").append(taskId).append("' ");
-        }
-        jdbcTemplate.execute(update.toString());
-
-        List<String> byteArrayIds = jdbcTemplate.queryForList(
-                "SELECT BYTEARRAY_ID_ FROM ACT_HI_VARINST WHERE BYTEARRAY_ID_ IS NOT NULL",
String.class);
-        update.setLength(0);
-        update.append("DELETE FROM ACT_GE_BYTEARRAY WHERE NAME_ LIKE 'hist.%' ");
-        for (String byteArrayId : byteArrayIds) {
-            update.append("AND ID_<>'").append(byteArrayId).append("' ");
-        }
-        jdbcTemplate.execute(update.toString());
-    }
-
     /**
      * Saves resources to be propagated and password for later - after form submission -
propagation.
      *
@@ -310,8 +270,6 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
 
         Set<String> tasks = getPerformedTasks(user);
 
-        cleanupHistory(user);
-
         return new WorkflowResult<Pair<Long, Boolean>>(
                 new ImmutablePair<>(user.getKey(), propagateEnable), propByRes, tasks);
     }
@@ -351,8 +309,6 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         postTasks.removeAll(preTasks);
         postTasks.add(task);
 
-        cleanupHistory(user);
-
         return postTasks;
     }
 
@@ -745,18 +701,6 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         return forms;
     }
 
-    @Override
-    public List<WorkflowFormTO> getForms(final String workflowId, final String name)
{
-        List<WorkflowFormTO> forms = getForms(
-                engine.getTaskService().createTaskQuery().processInstanceId(workflowId).taskName(name).
-                taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE));
-
-        forms.addAll(getForms(engine.getHistoryService().createHistoricTaskInstanceQuery().taskName(name).
-                taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE)));
-
-        return forms;
-    }
-
     protected <T extends Query<?, ?>, U extends Object> List<WorkflowFormTO>
getForms(final Query<T, U> query) {
         List<WorkflowFormTO> forms = new ArrayList<>();
 
@@ -911,8 +855,6 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
             }
         }
 
-        cleanupHistory(user);
-
         return new WorkflowResult<>(userPatch, propByRes, postTasks);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/core/workflow-activiti/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/resources/workflow.properties b/core/workflow-activiti/src/main/resources/workflow.properties
index 61f1a3e..771b11c 100644
--- a/core/workflow-activiti/src/main/resources/workflow.properties
+++ b/core/workflow-activiti/src/main/resources/workflow.properties
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 wf.directory=${conf.directory}
+historyLevel=activity
 jobExecutorActivate=true
 uwfAdapter=org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter
 gwfAdapter=org.apache.syncope.core.workflow.java.DefaultGroupWorkflowAdapter

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml b/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml
index 81058e1..8070ac2 100644
--- a/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml
+++ b/core/workflow-activiti/src/main/resources/workflowActivitiContext.xml
@@ -42,6 +42,7 @@ under the License.
     <property name="jpaHandleTransaction" value="true"/>
     <property name="jpaCloseEntityManager" value="false"/>
 
+    <property name="history" value="${historyLevel}"/>
     <property name="jobExecutorActivate" value="${jobExecutorActivate}"/>
 
     <property name="customSessionFactories">

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/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 d16245c..318a162 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
@@ -62,15 +62,6 @@ public interface WorkflowAdapter {
     List<WorkflowFormTO> getForms();
 
     /**
-     * Gets all forms with the given name for the given workflowId(include historical forms).
-     *
-     * @param workflowId workflow id.
-     * @param name form name.
-     * @return forms (if present), otherwise an empty list.
-     */
-    List<WorkflowFormTO> getForms(String workflowId, String name);
-
-    /**
      * Get form for given workflowId (if present).
      *
      * @param workflowId workflow id

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/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 36b2d65..5f4c198 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
@@ -90,11 +90,6 @@ public class DefaultAnyObjectWorkflowAdapter extends AbstractAnyObjectWorkflowAd
     }
 
     @Override
-    public List<WorkflowFormTO> getForms(final String workflowId, final String name)
{
-        return Collections.emptyList();
-    }
-
-    @Override
     public WorkflowFormTO getForm(final String workflowId) {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/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 12173c1..e14b9a1 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
@@ -90,11 +90,6 @@ public class DefaultGroupWorkflowAdapter extends AbstractGroupWorkflowAdapter
{
     }
 
     @Override
-    public List<WorkflowFormTO> getForms(final String workflowId, final String name)
{
-        return Collections.emptyList();
-    }
-
-    @Override
     public WorkflowFormTO getForm(final String workflowId) {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/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 5592eef..6523474 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
@@ -187,11 +187,6 @@ public class DefaultUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
     }
 
     @Override
-    public List<WorkflowFormTO> getForms(final String workflowId, final String name)
{
-        return Collections.emptyList();
-    }
-
-    @Override
     public WorkflowFormTO getForm(final String workflowId) {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/core/workflow-java/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/core/workflow-java/src/main/resources/workflow.properties b/core/workflow-java/src/main/resources/workflow.properties
index f05a464..8e5f662 100644
--- a/core/workflow-java/src/main/resources/workflow.properties
+++ b/core/workflow-java/src/main/resources/workflow.properties
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 wf.directory=${conf.directory}
-jobExecutorActivate=false
 uwfAdapter=org.apache.syncope.core.workflow.java.DefaultUserWorkflowAdapter
 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/757608a7/fit/core-reference/src/main/resources/all/workflow.properties
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/all/workflow.properties b/fit/core-reference/src/main/resources/all/workflow.properties
index 61f1a3e..771b11c 100644
--- a/fit/core-reference/src/main/resources/all/workflow.properties
+++ b/fit/core-reference/src/main/resources/all/workflow.properties
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 wf.directory=${conf.directory}
+historyLevel=activity
 jobExecutorActivate=true
 uwfAdapter=org.apache.syncope.core.workflow.activiti.ActivitiUserWorkflowAdapter
 gwfAdapter=org.apache.syncope.core.workflow.java.DefaultGroupWorkflowAdapter

http://git-wip-us.apache.org/repos/asf/syncope/blob/757608a7/fit/core-reference/src/main/resources/workflow.properties
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/resources/workflow.properties b/fit/core-reference/src/main/resources/workflow.properties
index f05a464..8e5f662 100644
--- a/fit/core-reference/src/main/resources/workflow.properties
+++ b/fit/core-reference/src/main/resources/workflow.properties
@@ -15,7 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 wf.directory=${conf.directory}
-jobExecutorActivate=false
 uwfAdapter=org.apache.syncope.core.workflow.java.DefaultUserWorkflowAdapter
 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/757608a7/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
index 18b3cbf..ecb83d0 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
@@ -21,7 +21,6 @@ package org.apache.syncope.fit.core;
 import org.apache.syncope.fit.ActivitiDetector;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -247,7 +246,7 @@ public class UserWorkflowITCase extends AbstractITCase {
         WorkflowFormTO form = userWorkflowService.getFormForUser(userTO.getKey());
         assertNotNull(form);
 
-        // 3. first claim ny bellini ....
+        // 3. first claim by bellini ....
         UserWorkflowService userService3 = clientFactory.create("bellini", ADMIN_PWD).
                 getService(UserWorkflowService.class);
         form = userService3.claimForm(form.getTaskId());
@@ -271,39 +270,9 @@ public class UserWorkflowITCase extends AbstractITCase {
         assertEquals(preForms, userWorkflowService.getForms().size());
         assertNull(userWorkflowService.getFormForUser(userTO.getKey()));
 
-        // 7. search approval into the history as well
-        forms = userWorkflowService.getFormsByName(userTO.getKey(), "Create approval");
-        assertFalse(forms.isEmpty());
-
-        int count = 0;
-        for (WorkflowFormTO hform : forms) {
-            if (form.getTaskId().equals(hform.getTaskId())) {
-                count++;
-
-                assertEquals("createApproval", hform.getKey());
-                assertNotNull(hform.getCreateTime());
-                assertNotNull(hform.getDueDate());
-                assertTrue(Boolean.parseBoolean(hform.getPropertyMap().get("approve").getValue()));
-                assertNull(hform.getPropertyMap().get("rejectReason").getValue());
-            }
-        }
-        assertEquals(1, count);
-
-        userService.delete(userTO.getKey());
-
-        try {
-            userService.read(userTO.getKey());
-            fail();
-        } catch (Exception ignore) {
-            assertNotNull(ignore);
-        }
-
-        try {
-            userWorkflowService.getFormsByName(userTO.getKey(), "Create approval");
-            fail();
-        } catch (Exception ignore) {
-            assertNotNull(ignore);
-        }
+        // 7.check that no more forms are still to be processed
+        forms = userWorkflowService.getForms();
+        assertEquals(preForms, forms.size());
     }
 
 }


Mime
View raw message