Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B9CA1088A for ; Mon, 23 Jun 2014 15:27:15 +0000 (UTC) Received: (qmail 86898 invoked by uid 500); 23 Jun 2014 15:27:15 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 86863 invoked by uid 500); 23 Jun 2014 15:27:15 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 86854 invoked by uid 99); 23 Jun 2014 15:27:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2014 15:27: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, 23 Jun 2014 15:27:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4211A238896F; Mon, 23 Jun 2014 15:26:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1604839 - /syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java Date: Mon, 23 Jun 2014 15:26:53 -0000 To: commits@syncope.apache.org From: fmartelli@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140623152653.4211A238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmartelli Date: Mon Jun 23 15:26:52 2014 New Revision: 1604839 URL: http://svn.apache.org/r1604839 Log: [SYNCOPE-504] fix on the branch 1_1_X Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java?rev=1604839&r1=1604838&r2=1604839&view=diff ============================================================================== --- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java (original) +++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/sync/impl/SyncopeSyncResultHandler.java Mon Jun 23 15:26:52 2014 @@ -475,7 +475,7 @@ public class SyncopeSyncResultHandler im final List found = connector.search(objectClass, new EqualsFilter(new Name(name)), connector.getOperationOptions( - attrUtil.getMappingItems(syncTask.getResource(), MappingPurpose.SYNCHRONIZATION))); + attrUtil.getMappingItems(syncTask.getResource(), MappingPurpose.SYNCHRONIZATION))); if (found.isEmpty()) { LOG.debug("No {} found on {} with __NAME__ {}", objectClass, syncTask.getResource(), name); @@ -528,8 +528,6 @@ public class SyncopeSyncResultHandler im AbstractAttributableTO subjectTO = connObjectUtil.getAttributableTO(delta.getObject(), syncTask, attrUtil); - delta = actions.beforeCreate(this, delta, subjectTO); - // Attributable transformation (if configured) AbstractAttributableTO actual = attrTransformer.transform(subjectTO); LOG.debug("Transformed: {}", actual); @@ -543,7 +541,9 @@ public class SyncopeSyncResultHandler im result.setName(((RoleTO) actual).getName()); } } else { - Object output = null; + delta = actions.beforeCreate(this, delta, actual); + + Object output; Result resultStatus; try { @@ -599,6 +599,8 @@ public class SyncopeSyncResultHandler im resultStatus = Result.FAILURE; } + actions.after(this, delta, actual, result); + notificationManager.createTasks( AuditElements.EventCategoryType.SYNCHRONIZATION, AttributableType.USER.name().toLowerCase(), @@ -620,7 +622,6 @@ public class SyncopeSyncResultHandler im delta); } - actions.after(this, delta, actual, result); return Collections.singletonList(result); } @@ -632,8 +633,6 @@ public class SyncopeSyncResultHandler im UserMod userMod = connObjectUtil.getAttributableMod( id, delta.getObject(), before, syncTask, AttributableUtil.getInstance(AttributableType.USER)); - delta = actions.beforeUpdate(this, delta, before, userMod); - if (dryRun) { return new AbstractMap.SimpleEntry(before, before); } @@ -642,6 +641,8 @@ public class SyncopeSyncResultHandler im UserMod actual = attrTransformer.transform(userMod); LOG.debug("Transformed: {}", actual); + delta = actions.beforeUpdate(this, delta, before, userMod); + WorkflowResult> updated; try { updated = uwfAdapter.update(actual); @@ -702,8 +703,6 @@ public class SyncopeSyncResultHandler im RoleMod roleMod = connObjectUtil.getAttributableMod( id, delta.getObject(), before, syncTask, AttributableUtil.getInstance(AttributableType.ROLE)); - delta = actions.beforeUpdate(this, delta, before, roleMod); - if (dryRun) { return new AbstractMap.SimpleEntry(before, before); } @@ -712,6 +711,8 @@ public class SyncopeSyncResultHandler im RoleMod actual = attrTransformer.transform(roleMod); LOG.debug("Transformed: {}", actual); + delta = actions.beforeUpdate(this, delta, before, roleMod); + WorkflowResult updated = rwfAdapter.update(actual); String roleOwner = null; for (AttributeMod attrMod : actual.getAttributesToBeUpdated()) { @@ -753,7 +754,7 @@ public class SyncopeSyncResultHandler im for (Long id : subjects) { LOG.debug("About to update {}", id); - Object output = null; + Object output; AbstractAttributableTO before = null; Result resultStatus; @@ -837,16 +838,16 @@ public class SyncopeSyncResultHandler im List delResults = new ArrayList(); for (Long id : subjects) { - Object output = null; + Object output; Result resultStatus = Result.FAILURE; + final SyncResult result = new SyncResult(); + try { AbstractAttributableTO subjectTO = AttributableType.USER == attrUtil.getType() ? userDataBinder.getUserTO(id) : roleDataBinder.getRoleTO(id); - delta = actions.beforeDelete(this, delta, subjectTO); - final SyncResult result = new SyncResult(); result.setId(id); if (subjectTO instanceof UserTO) { result.setName(((UserTO) subjectTO).getUsername()); @@ -859,6 +860,8 @@ public class SyncopeSyncResultHandler im result.setStatus(SyncResult.Status.SUCCESS); if (!dryRun) { + delta = actions.beforeDelete(this, delta, subjectTO); + try { List tasks = Collections.emptyList(); if (AttributableType.USER == attrUtil.getType()) { @@ -887,37 +890,38 @@ public class SyncopeSyncResultHandler im LOG.error("Could not delete {} {}", attrUtil.getType(), id, e); output = e; } + + actions.after(this, delta, subjectTO, result); + + notificationManager.createTasks( + AuditElements.EventCategoryType.SYNCHRONIZATION, + attrUtil.getType().name().toLowerCase(), + syncTask.getResource().getName(), + "delete", + resultStatus, + subjectTO, + output, + delta); + + auditManager.audit( + AuditElements.EventCategoryType.SYNCHRONIZATION, + attrUtil.getType().name().toLowerCase(), + syncTask.getResource().getName(), + "delete", + resultStatus, + subjectTO, + output, + delta); } - actions.after(this, delta, subjectTO, result); delResults.add(result); } catch (NotFoundException e) { LOG.error("Could not find {} {}", attrUtil.getType(), id, e); } catch (UnauthorizedRoleException e) { LOG.error("Not allowed to read {} {}", attrUtil.getType(), id, e); - } - - if (!dryRun) { - notificationManager.createTasks( - AuditElements.EventCategoryType.SYNCHRONIZATION, - attrUtil.getType().name().toLowerCase(), - syncTask.getResource().getName(), - "delete", - resultStatus, - null, // searching for before object is too much expensive ... - output, - delta); - - auditManager.audit( - AuditElements.EventCategoryType.SYNCHRONIZATION, - attrUtil.getType().name().toLowerCase(), - syncTask.getResource().getName(), - "delete", - resultStatus, - null, // searching for before object is too much expensive ... - output, - delta); + } catch (Exception e) { + LOG.error("Could not delete {} {}", attrUtil.getType(), id, e); } }