syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1400797 - in /incubator/syncope/trunk/core/src: main/java/org/apache/syncope/core/notification/ main/java/org/apache/syncope/core/persistence/beans/ main/java/org/apache/syncope/core/rest/controller/ main/java/org/apache/syncope/core/rest/...
Date Mon, 22 Oct 2012 08:41:25 GMT
Author: ilgrosso
Date: Mon Oct 22 08:41:24 2012
New Revision: 1400797

URL: http://svn.apache.org/viewvc?rev=1400797&view=rev
Log:
[SYNCOPE-144] Now name is mandatory for SchedTask and SyncTask

Modified:
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchedTask.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
    incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/TaskTest.java
    incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    incubator/syncope/trunk/core/src/test/resources/content.xml

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
Mon Oct 22 08:41:24 2012
@@ -36,7 +36,6 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.dao.EntitlementDAO;
 import org.apache.syncope.core.persistence.dao.NotificationDAO;
 import org.apache.syncope.core.persistence.dao.TaskDAO;
-import org.apache.syncope.core.persistence.dao.TaskExecDAO;
 import org.apache.syncope.core.persistence.dao.UserDAO;
 import org.apache.syncope.core.persistence.dao.UserSearchDAO;
 import org.apache.syncope.core.rest.data.UserDataBinder;
@@ -44,7 +43,6 @@ import org.apache.syncope.core.schedulin
 import org.apache.syncope.core.util.ConnObjectUtil;
 import org.apache.syncope.core.util.EntitlementUtil;
 import org.apache.syncope.core.util.NotFoundException;
-import org.apache.syncope.core.workflow.WorkflowResult;
 import org.apache.syncope.types.IntMappingType;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.exception.VelocityException;
@@ -101,12 +99,6 @@ public class NotificationManager {
     private TaskDAO taskDAO;
 
     /**
-     * TaskExec DAO.
-     */
-    @Autowired
-    private TaskExecDAO taskExecDAO;
-
-    /**
      * Velocity template engine.
      */
     @Autowired
@@ -190,23 +182,24 @@ public class NotificationManager {
     }
 
     /**
-     * Create notification tasks for each notification matching the passed workflow result.
+     * Create notification tasks for each notification matching the given user id and (some
of) tasks performed.
      *
-     * @param wfResult workflow result
+     * @param userId user id
+     * @param performedTasks set of actions performed on given user id
      * @throws NotFoundException if user contained in the workflow result cannot be found
      */
-    public void createTasks(final WorkflowResult<Long> wfResult)
+    public void createTasks(final Long userId, final Set<String> performedTasks)
             throws NotFoundException {
 
-        SyncopeUser user = userDAO.find(wfResult.getResult());
+        SyncopeUser user = userDAO.find(userId);
         if (user == null) {
-            throw new NotFoundException("User " + wfResult.getResult());
+            throw new NotFoundException("User " + userId);
         }
 
         for (Notification notification : notificationDAO.findAll()) {
             if (searchDAO.matches(user, notification.getAbout())) {
                 Set<String> events = new HashSet<String>(notification.getEvents());
-                events.retainAll(wfResult.getPerformedTasks());
+                events.retainAll(performedTasks);
 
                 if (!events.isEmpty()) {
                     LOG.debug("Creating notification task for events {} about {}", events,
user);
@@ -267,7 +260,7 @@ public class NotificationManager {
 
     /**
      * Mark NotificationTask with provided id as executed.
-     * 
+     *
      * @param taskId task to be updated
      */
     public void setTaskExecuted(final Long taskId) {

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchedTask.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchedTask.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchedTask.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/SchedTask.java
Mon Oct 22 08:41:24 2012
@@ -33,6 +33,7 @@ public class SchedTask extends Task {
     @NotNull
     protected String jobClassName;
 
+    @NotNull
     protected String name;
 
     protected String description;

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
Mon Oct 22 08:41:24 2012
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.rest.controller;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -313,8 +314,7 @@ public class UserController {
             }
         });
 
-        notificationManager.createTasks(new WorkflowResult<Long>(created.getResult().getKey(),
created.getPropByRes(),
-                created.getPerformedTasks()));
+        notificationManager.createTasks(created.getResult().getKey(), created.getPerformedTasks());
 
         final UserTO savedTO = userDataBinder.getUserTO(created.getResult().getKey());
         savedTO.setPropagationTOs(propagations);
@@ -364,8 +364,7 @@ public class UserController {
             }
         });
 
-        notificationManager.createTasks(new WorkflowResult<Long>(updated.getResult().getKey(),
updated.getPropByRes(),
-                updated.getPerformedTasks()));
+        notificationManager.createTasks(updated.getResult().getKey(), updated.getPerformedTasks());
 
         final UserTO updatedTO = userDataBinder.getUserTO(updated.getResult().getKey());
         updatedTO.setPropagationTOs(propagations);
@@ -532,7 +531,7 @@ public class UserController {
 
         propagationManager.execute(tasks);
 
-        notificationManager.createTasks(updated);
+        notificationManager.createTasks(updated.getResult(), updated.getPerformedTasks());
 
         final UserTO savedTO = userDataBinder.getUserTO(updated.getResult());
 
@@ -645,7 +644,7 @@ public class UserController {
         List<PropagationTask> tasks = propagationManager.getUpdateTaskIds(user, status,
resources);
 
         propagationManager.execute(tasks);
-        notificationManager.createTasks(updated);
+        notificationManager.createTasks(updated.getResult(), updated.getPerformedTasks());
 
         final UserTO savedTO = userDataBinder.getUserTO(updated.getResult());
 
@@ -664,7 +663,7 @@ public class UserController {
         // information could only be available after wfAdapter.delete(), which
         // will also effectively remove user from db, thus making virtually
         // impossible by NotificationManager to fetch required user information
-        notificationManager.createTasks(new WorkflowResult<Long>(userId, null, "delete"));
+        notificationManager.createTasks(userId, Collections.singleton("delete"));
 
         List<PropagationTask> tasks = propagationManager.getDeleteTaskIds(userId);
 

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
Mon Oct 22 08:41:24 2012
@@ -173,8 +173,12 @@ public class TaskDataBinder {
 
     public void updateSchedTask(final SchedTask task, final SchedTaskTO taskTO, final TaskUtil
taskUtil) {
         task.setCronExpression(taskTO.getCronExpression());
-        task.setName(taskTO.getName());
-        task.setDescription(taskTO.getDescription());
+        if (StringUtils.isNotBlank(taskTO.getName())) {
+            task.setName(taskTO.getName());
+        }
+        if (StringUtils.isNotBlank(taskTO.getDescription())) {
+            task.setDescription(taskTO.getDescription());
+        }
 
         if (taskUtil == TaskUtil.SYNC) {
             if (!(task instanceof SyncTask)) {

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
(original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/SyncJob.java
Mon Oct 22 08:41:24 2012
@@ -290,11 +290,11 @@ public class SyncJob extends AbstractTas
 
     /**
      * Creates user and stores the result in parameter delta (!)
-     * 
+     *
      * @param delta
      * @param dryRun
      * @return
-     * @throws JobExecutionException 
+     * @throws JobExecutionException
      */
     private SyncResult createUser(SyncDelta delta, final boolean dryRun) throws JobExecutionException
{
 
@@ -335,8 +335,7 @@ public class SyncJob extends AbstractTas
 
                 propagationManager.execute(tasks);
 
-                notificationManager.createTasks(new WorkflowResult<Long>(created.getResult().getKey(),
-                        created.getPropByRes(), created.getPerformedTasks()));
+                notificationManager.createTasks(created.getResult().getKey(), created.getPerformedTasks());
 
                 userTO = userDataBinder.getUserTO(created.getResult().getKey());
 
@@ -392,8 +391,7 @@ public class SyncJob extends AbstractTas
 
                         propagationManager.execute(tasks);
 
-                        notificationManager.createTasks(new WorkflowResult<Long>(updated.getResult().getKey(),
-                                updated.getPropByRes(), updated.getPerformedTasks()));
+                        notificationManager.createTasks(updated.getResult().getKey(), updated.getPerformedTasks());
 
                         userTO = userDataBinder.getUserTO(updated.getResult().getKey());
                     }
@@ -442,7 +440,7 @@ public class SyncJob extends AbstractTas
                                 ((SyncTask) this.task).getResource().getName());
                         propagationManager.execute(tasks);
 
-                        notificationManager.createTasks(new WorkflowResult<Long>(userId,
null, "delete"));
+                        notificationManager.createTasks(userId, Collections.singleton("delete"));
 
                     } catch (Exception e) {
                         LOG.error("Could not propagate user " + userId, e);
@@ -541,7 +539,7 @@ public class SyncJob extends AbstractTas
         // anyway.
         report.append("Users [created/failures]: ").append(created.size()).append('/').append(createdFailed.size())
                 .append(' ').append("[updated/failures]: ").append(updated.size()).append('/').append(
-                        updatedFailed.size()).append(' ').append("[deleted/ failures]: ").append(deleted.size())
+                updatedFailed.size()).append(' ').append("[deleted/ failures]: ").append(deleted.size())
                 .append('/').append(deletedFailed.size());
 
         // Failures
@@ -706,12 +704,12 @@ public class SyncJob extends AbstractTas
         final List<SyncResult> results = new ArrayList<SyncResult>();
 
         LOG.debug("Process '{}' for '{}'", delta.getDeltaType(), delta.getUid().getUidValue());
-        
+
         final List<Long> users = findExistingUsers(delta);
-        
+
         switch (delta.getDeltaType()) {
             case CREATE_OR_UPDATE:
-                if (users.isEmpty()) { 
+                if (users.isEmpty()) {
                     if (syncTask.isPerformCreate()) {
                         results.add(createUser(delta, dryRun));
                     } else {

Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/TaskTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/TaskTest.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/TaskTest.java
(original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/TaskTest.java
Mon Oct 22 08:41:24 2012
@@ -113,6 +113,8 @@ public class TaskTest extends AbstractTe
         assertNotNull(resource);
 
         SyncTask task = new SyncTask();
+        task.setName("saveSyncTask");
+        task.setDescription("SyncTask description");
         task.setUserTemplate(new UserTO());
         task.setCronExpression("BLA BLA");
 

Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
(original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
Mon Oct 22 08:41:24 2012
@@ -64,6 +64,7 @@ public class TaskTestITCase extends Abst
     @Test
     public void create() {
         SyncTaskTO task = new SyncTaskTO();
+        task.setName("Test create Sync");
         task.setResource("ws-target-resource-2");
 
         UserTO template = new UserTO();

Modified: incubator/syncope/trunk/core/src/test/resources/content.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/resources/content.xml?rev=1400797&r1=1400796&r2=1400797&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/resources/content.xml (original)
+++ incubator/syncope/trunk/core/src/test/resources/content.xml Mon Oct 22 08:41:24 2012
@@ -569,19 +569,19 @@ under the License.
   <Task DTYPE="PropagationTask" id="3" propagationMode="TWO_PHASES" propagationOperation="DELETE"
         resource_name="ws-target-resource-2" syncopeUser_id="1"
         xmlAttributes="%3Cset%3E%0A++%3Corg.identityconnectors.framework.common.objects.Name%3E%0A++++%3Cname%3E__NAME__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3EuserId%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Name%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3E__PASSWORD__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Corg.identityconnectors.common.security.GuardedString%3E%0A++++++++++%3C__readOnly%3Efalse%3C%2F__readOnly%3E%0A++++++++++%3C__disposed%3Efalse%3C%2F__disposed%3E%0A+++++++++
 +%3C__encryptedBytes%3EQTOgwEhIHqtAI%2FYlgDhYc37esEF8VLDMU2IY1ciltrg%3D%3C%2F__encryptedBytes%3E%0A++++++++++%3C__base64SHA1Hash%3EW5%2FrwtdCnI8gAnIUhKcahMEnMMc%3D%3C%2F__base64SHA1Hash%3E%0A++++++++%3C%2Forg.identityconnectors.common.security.GuardedString%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3Etype%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3Etype%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A%3C%2Fset%3E"/>
-  <Task DTYPE="SyncTask" id="4" resource_name="resource-csv"
+  <Task DTYPE="SyncTask" id="4" name="CSV Task" resource_name="resource-csv"
         performCreate="1" performUpdate="1" performDelete="1" syncStatus="1" fullReconciliation="0"
         jobClassName="org.apache.syncope.core.scheduling.SyncJob"/>
-  <Task DTYPE="SchedTask" id="5" jobClassName="org.apache.syncope.core.scheduling.SampleJob"
cronExpression="0 0 0 1 * ?"/>
+  <Task DTYPE="SchedTask" id="5" name="SampleJob Task" jobClassName="org.apache.syncope.core.scheduling.SampleJob"
cronExpression="0 0 0 1 * ?"/>
   <Task DTYPE="PropagationTask" id="6" propagationMode="TWO_PHASES" propagationOperation="UPDATE"
         resource_name="ws-target-resource-nopropagation" syncopeUser_id="1"
         xmlAttributes="%3Cset%3E%0A++%3Corg.identityconnectors.framework.common.objects.Name%3E%0A++++%3Cname%3E__NAME__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3EuserId%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Name%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3E__PASSWORD__%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Corg.identityconnectors.common.security.GuardedString%3E%0A++++++++++%3C__readOnly%3Efalse%3C%2F__readOnly%3E%0A++++++++++%3C__disposed%3Efalse%3C%2F__disposed%3E%0A+++++++++
 +%3C__encryptedBytes%3EQTOgwEhIHqtAI%2FYlgDhYc37esEF8VLDMU2IY1ciltrg%3D%3C%2F__encryptedBytes%3E%0A++++++++++%3C__base64SHA1Hash%3EW5%2FrwtdCnI8gAnIUhKcahMEnMMc%3D%3C%2F__base64SHA1Hash%3E%0A++++++++%3C%2Forg.identityconnectors.common.security.GuardedString%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3Etype%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3Etype%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A++%3Corg.identityconnectors.framework.common.objects.Attribute%3E%0A++++%3Cname%3Eful
 lname%3C%2Fname%3E%0A++++%3Cvalue+class%3D%22java.util.Collections%24UnmodifiableRandomAccessList%22+resolves-to%3D%22java.util.Collections%24UnmodifiableList%22%3E%0A++++++%3Cc+class%3D%22list%22%3E%0A++++++++%3Cstring%3Efullname%3C%2Fstring%3E%0A++++++%3C%2Fc%3E%0A++++++%3Clist+reference%3D%22..%2Fc%22%2F%3E%0A++++%3C%2Fvalue%3E%0A++%3C%2Forg.identityconnectors.framework.common.objects.Attribute%3E%0A%3C%2Fset%3E%0A"/>
-  <Task DTYPE="SyncTask" id="7" resource_name="resource-testdb"
+  <Task DTYPE="SyncTask" id="7" name="TestDB Task" resource_name="resource-testdb"
         performCreate="1" performUpdate="1" performDelete="0" syncStatus="1" fullReconciliation="1"
         jobClassName="org.apache.syncope.core.scheduling.SyncJob"/>
   <Task DTYPE="NotificationTask" id="8" sender="admin@prova.org" subject="Notification
for SYNCOPE-81" 
         textBody="NOTIFICATION-81" htmlBody="NOTIFICATION-81" traceLevel="ALL"/>
-  <Task DTYPE="SyncTask" id="9" resource_name="resource-testdb2"
+  <Task DTYPE="SyncTask" id="9" name="TestDB2 Task" resource_name="resource-testdb2"
         performCreate="1" performUpdate="1" performDelete="0" syncStatus="1" fullReconciliation="1"
         jobClassName="org.apache.syncope.core.scheduling.SyncJob"/>
         



Mime
View raw message