Return-Path: X-Original-To: apmail-incubator-syncope-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-syncope-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9795D6CA for ; Mon, 22 Oct 2012 08:42:19 +0000 (UTC) Received: (qmail 90634 invoked by uid 500); 22 Oct 2012 08:42:17 -0000 Delivered-To: apmail-incubator-syncope-commits-archive@incubator.apache.org Received: (qmail 90571 invoked by uid 500); 22 Oct 2012 08:42:16 -0000 Mailing-List: contact syncope-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: syncope-dev@incubator.apache.org Delivered-To: mailing list syncope-commits@incubator.apache.org Received: (qmail 90547 invoked by uid 99); 22 Oct 2012 08:42:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 08:42:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 08:42:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8206F23888EA; Mon, 22 Oct 2012 08:41:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: syncope-commits@incubator.apache.org From: ilgrosso@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121022084125.8206F23888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 wfResult) + public void createTasks(final Long userId, final Set 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 events = new HashSet(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(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(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 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(userId, null, "delete")); + notificationManager.createTasks(userId, Collections.singleton("delete")); List 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(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(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(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 results = new ArrayList(); LOG.debug("Process '{}' for '{}'", delta.getDeltaType(), delta.getUid().getUidValue()); - + final List 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. - - + - -