[2/4] syncope git commit: Always conditionally handling notification and audit events in a Quartz job

2017-06-13 Thread ilgrosso
Always conditionally handling notification and audit events in a Quartz job


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

Branch: refs/heads/master
Commit: d310af8337e3fbc410d70e21f62e6bd40ffd753e
Parents: c626205
Author: Francesco Chicchiriccò 
Authored: Tue Jun 13 11:14:02 2017 +0200
Committer: Francesco Chicchiriccò 
Committed: Tue Jun 13 13:23:14 2017 +0200

--
 .../pushpull/AbstractPushResultHandler.java | 55 +++-
 .../pushpull/RealmPushResultHandlerImpl.java| 41 ++-
 2 files changed, 68 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/syncope/blob/d310af83/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
--
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
index 542009b..d84fa25 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
@@ -46,9 +46,11 @@ import 
org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+import org.apache.syncope.core.provisioning.api.AuditManager;
 import org.apache.syncope.core.provisioning.api.MappingManager;
 import org.apache.syncope.core.provisioning.api.TimeoutException;
 import org.apache.syncope.core.provisioning.api.event.AfterHandlingEvent;
+import 
org.apache.syncope.core.provisioning.api.notification.NotificationManager;
 import 
org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
 import 
org.apache.syncope.core.provisioning.api.pushpull.SyncopePushResultHandler;
 import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
@@ -66,6 +68,18 @@ import 
org.springframework.transaction.annotation.Transactional;
 public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHandler
 implements SyncopePushResultHandler {
 
+/**
+ * Notification Manager.
+ */
+@Autowired
+protected NotificationManager notificationManager;
+
+/**
+ * Audit Manager.
+ */
+@Autowired
+protected AuditManager auditManager;
+
 @Autowired
 protected MappingManager mappingManager;
 
@@ -196,7 +210,6 @@ public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHan
 
 Object output = null;
 Result resultStatus = null;
-String operation = null;
 
 // Try to read remote object BEFORE any actual operation
 Provision provision = 
profile.getTask().getResource().getProvision(any.getType());
@@ -214,9 +227,22 @@ public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHan
 }
 result.setStatus(ProvisioningReport.Status.SUCCESS);
 } else {
+String operation = beforeObj == null
+? 
UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule())
+: 
MatchingRule.toEventName(profile.getTask().getMatchingRule());
+
+boolean notificationsAvailable = 
notificationManager.notificationsAvailable(
+AuditElements.EventCategoryType.PUSH,
+any.getType().getKind().name().toLowerCase(),
+profile.getTask().getResource().getKey(),
+operation);
+boolean auditRequested = auditManager.auditRequested(
+AuditElements.EventCategoryType.PUSH,
+any.getType().getKind().name().toLowerCase(),
+profile.getTask().getResource().getKey(),
+operation);
 try {
 if (beforeObj == null) {
-operation = 
UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule());
 
result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule()));
 
 switch (profile.getTask().getUnmatchingRule()) {
@@ -266,7 +292,6 @@ public abstract class 

[2/4] syncope git commit: Always conditionally handling notification and audit events in a Quartz job

2017-06-13 Thread ilgrosso
Always conditionally handling notification and audit events in a Quartz job


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

Branch: refs/heads/2_0_X
Commit: ae947c721cb65fcef39aa405f028894b933800e2
Parents: ddf2d5e
Author: Francesco Chicchiriccò 
Authored: Tue Jun 13 11:14:02 2017 +0200
Committer: Francesco Chicchiriccò 
Committed: Tue Jun 13 11:14:02 2017 +0200

--
 .../pushpull/AbstractPushResultHandler.java | 55 +++-
 .../pushpull/RealmPushResultHandlerImpl.java| 41 ++-
 2 files changed, 68 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/syncope/blob/ae947c72/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
--
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
index 542009b..d84fa25 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
@@ -46,9 +46,11 @@ import 
org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+import org.apache.syncope.core.provisioning.api.AuditManager;
 import org.apache.syncope.core.provisioning.api.MappingManager;
 import org.apache.syncope.core.provisioning.api.TimeoutException;
 import org.apache.syncope.core.provisioning.api.event.AfterHandlingEvent;
+import 
org.apache.syncope.core.provisioning.api.notification.NotificationManager;
 import 
org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
 import 
org.apache.syncope.core.provisioning.api.pushpull.SyncopePushResultHandler;
 import org.apache.syncope.core.provisioning.api.utils.EntityUtils;
@@ -66,6 +68,18 @@ import 
org.springframework.transaction.annotation.Transactional;
 public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHandler
 implements SyncopePushResultHandler {
 
+/**
+ * Notification Manager.
+ */
+@Autowired
+protected NotificationManager notificationManager;
+
+/**
+ * Audit Manager.
+ */
+@Autowired
+protected AuditManager auditManager;
+
 @Autowired
 protected MappingManager mappingManager;
 
@@ -196,7 +210,6 @@ public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHan
 
 Object output = null;
 Result resultStatus = null;
-String operation = null;
 
 // Try to read remote object BEFORE any actual operation
 Provision provision = 
profile.getTask().getResource().getProvision(any.getType());
@@ -214,9 +227,22 @@ public abstract class AbstractPushResultHandler extends 
AbstractSyncopeResultHan
 }
 result.setStatus(ProvisioningReport.Status.SUCCESS);
 } else {
+String operation = beforeObj == null
+? 
UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule())
+: 
MatchingRule.toEventName(profile.getTask().getMatchingRule());
+
+boolean notificationsAvailable = 
notificationManager.notificationsAvailable(
+AuditElements.EventCategoryType.PUSH,
+any.getType().getKind().name().toLowerCase(),
+profile.getTask().getResource().getKey(),
+operation);
+boolean auditRequested = auditManager.auditRequested(
+AuditElements.EventCategoryType.PUSH,
+any.getType().getKind().name().toLowerCase(),
+profile.getTask().getResource().getKey(),
+operation);
 try {
 if (beforeObj == null) {
-operation = 
UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule());
 
result.setOperation(getResourceOperation(profile.getTask().getUnmatchingRule()));
 
 switch (profile.getTask().getUnmatchingRule()) {
@@ -266,7 +292,6 @@ public abstract class