syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject svn commit: r1543782 [3/4] - in /syncope/trunk: ./ common/src/main/java/org/apache/syncope/common/services/ common/src/main/java/org/apache/syncope/common/to/ common/src/main/java/org/apache/syncope/common/types/ common/src/main/java/org/apache/syncope...
Date Wed, 20 Nov 2013 11:37:36 GMT
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ReportController.java Wed Nov 20 11:37:34 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.core.rest.con
 
 import java.io.ByteArrayInputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -28,7 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.zip.ZipInputStream;
-import javax.ws.rs.core.Response;
 import org.apache.cocoon.optional.pipeline.components.sax.fop.FopSerializer;
 import org.apache.cocoon.pipeline.NonCachingPipeline;
 import org.apache.cocoon.pipeline.Pipeline;
@@ -37,19 +37,14 @@ import org.apache.cocoon.sax.component.X
 import org.apache.cocoon.sax.component.XMLSerializer;
 import org.apache.cocoon.sax.component.XSLTTransformer;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.syncope.common.report.ReportletConf;
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.ReportTO;
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.ReportSubCategory;
-import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.ReportExecExportFormat;
-import static org.apache.syncope.common.types.ReportExecExportFormat.RTF;
 import org.apache.syncope.common.types.ReportExecStatus;
 import org.apache.syncope.common.types.ClientExceptionType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.init.JobInstanceLoader;
 import org.apache.syncope.core.persistence.beans.Report;
 import org.apache.syncope.core.persistence.beans.ReportExec;
@@ -69,10 +64,7 @@ import org.springframework.stereotype.Co
 import org.springframework.transaction.annotation.Transactional;
 
 @Component
-public class ReportController extends AbstractController {
-
-    @Autowired
-    private AuditManager auditManager;
+public class ReportController extends AbstractTransactionalController<ReportTO> {
 
     @Autowired
     private ReportDAO reportDAO;
@@ -107,9 +99,6 @@ public class ReportController extends Ab
             throw sce;
         }
 
-        auditManager.audit(Category.report, ReportSubCategory.create, Result.success,
-                "Successfully created report: " + report.getId());
-
         return binder.getReportTO(report);
     }
 
@@ -135,9 +124,6 @@ public class ReportController extends Ab
             throw sce;
         }
 
-        auditManager.audit(Category.report, ReportSubCategory.update, Result.success,
-                "Successfully updated report: " + report.getId());
-
         return binder.getReportTO(report);
     }
 
@@ -153,10 +139,6 @@ public class ReportController extends Ab
         for (Report report : reports) {
             result.add(binder.getReportTO(report));
         }
-
-        auditManager.audit(Category.report, ReportSubCategory.list, Result.success,
-                "Successfully listed all reports: " + result.size());
-
         return result;
     }
 
@@ -167,10 +149,6 @@ public class ReportController extends Ab
         for (Report report : reports) {
             result.add(binder.getReportTO(report));
         }
-
-        auditManager.audit(Category.report, ReportSubCategory.list, Result.success,
-                "Successfully listed reports (page=" + page + ", size=" + size + "): " + result.size());
-
         return result;
     }
 
@@ -186,9 +164,6 @@ public class ReportController extends Ab
             }
         }
 
-        auditManager.audit(Category.report, ReportSubCategory.getReportletConfClasses, Result.success,
-                "Successfully listed all ReportletConf classes: " + reportletConfClasses.size());
-
         return reportletConfClasses;
     }
 
@@ -198,10 +173,6 @@ public class ReportController extends Ab
         if (report == null) {
             throw new NotFoundException("Report " + reportId);
         }
-
-        auditManager.audit(Category.report, ReportSubCategory.read, Result.success,
-                "Successfully read report: " + report.getId());
-
         return binder.getReportTO(report);
     }
 
@@ -212,10 +183,6 @@ public class ReportController extends Ab
         if (reportExec == null) {
             throw new NotFoundException("Report execution " + executionId);
         }
-
-        auditManager.audit(Category.report, ReportSubCategory.readExecution, Result.success,
-                "Successfully read report execution: " + reportExec.getId());
-
         return binder.getReportExecTO(reportExec);
     }
 
@@ -234,7 +201,7 @@ public class ReportController extends Ab
 
             Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
             pipeline.addComponent(new XMLGenerator(zis));
-            
+
             Map<String, Object> parameters = new HashMap<String, Object>();
             parameters.put("status", reportExec.getStatus());
             parameters.put("message", reportExec.getMessage());
@@ -285,9 +252,6 @@ public class ReportController extends Ab
             IOUtils.closeQuietly(zis);
             IOUtils.closeQuietly(bais);
         }
-
-        auditManager.audit(Category.report, ReportSubCategory.exportExecutionResult, Result.success,
-                "Successfully exported report execution: " + reportExec.getId());
     }
 
     @PreAuthorize("hasRole('REPORT_READ')")
@@ -322,15 +286,9 @@ public class ReportController extends Ab
 
             scheduler.getScheduler().triggerJob(
                     new JobKey(JobInstanceLoader.getJobName(report), Scheduler.DEFAULT_GROUP));
-
-            auditManager.audit(Category.report, ReportSubCategory.execute, Result.success,
-                    "Successfully started execution for report: " + report.getId());
         } catch (Exception e) {
             LOG.error("While executing report {}", report, e);
 
-            auditManager.audit(Category.report, ReportSubCategory.execute, Result.failure,
-                    "Could not start execution for report: " + report.getId(), e);
-
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
             sce.getElements().add(e.getMessage());
             throw sce;
@@ -353,14 +311,8 @@ public class ReportController extends Ab
         }
 
         ReportTO deletedReport = binder.getReportTO(report);
-
         jobInstanceLoader.unregisterJob(report);
-
         reportDAO.delete(report);
-
-        auditManager.audit(Category.report, ReportSubCategory.delete, Result.success,
-                "Successfully deleted report: " + report.getId());
-
         return deletedReport;
     }
 
@@ -372,12 +324,39 @@ public class ReportController extends Ab
         }
 
         ReportExecTO reportExecToDelete = binder.getReportExecTO(reportExec);
-
         reportExecDAO.delete(reportExec);
+        return reportExecToDelete;
+    }
 
-        auditManager.audit(Category.report, ReportSubCategory.deleteExecution, Result.success,
-                "Successfully deleted report execution: " + reportExec.getId());
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected ReportTO resolveReference(final Method method, final Object... args) throws
+            UnresolvedReferenceException {
+        Long id = null;
+
+        if (ArrayUtils.isNotEmpty(args) && ("create".equals(method.getName())
+                || "update".equals(method.getName())
+                || "delete".equals(method.getName()))) {
+            for (int i = 0; id == null && i < args.length; i++) {
+                if (args[i] instanceof Long) {
+                    id = (Long) args[i];
+                } else if (args[i] instanceof ReportTO) {
+                    id = ((ReportTO) args[i]).getId();
+                }
+            }
+        }
 
-        return reportExecToDelete;
+        if (id != null) {
+            try {
+                return binder.getReportTO(reportDAO.find(id));
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
+
+        throw new UnresolvedReferenceException();
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java Wed Nov 20 11:37:34 2013
@@ -18,23 +18,20 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Set;
 import javax.persistence.EntityExistsException;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.syncope.common.to.BulkAction;
 import org.apache.syncope.common.to.BulkActionRes;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.AuditElements;
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.ResourceSubCategory;
-import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.init.ImplementationClassNamesLoader;
 import org.apache.syncope.core.persistence.beans.AbstractAttributable;
@@ -63,10 +60,7 @@ import org.springframework.stereotype.Co
 import org.springframework.transaction.annotation.Transactional;
 
 @Component
-public class ResourceController extends AbstractController {
-
-    @Autowired
-    private AuditManager auditManager;
+public class ResourceController extends AbstractTransactionalController<ResourceTO> {
 
     @Autowired
     private ResourceDAO resourceDAO;
@@ -111,9 +105,6 @@ public class ResourceController extends 
 
         ExternalResource resource = resourceDAO.save(binder.create(resourceTO));
 
-        auditManager.audit(Category.resource, ResourceSubCategory.create, Result.success,
-                "Successfully created resource: " + resource.getName());
-
         return binder.getResourceTO(resource);
     }
 
@@ -129,9 +120,6 @@ public class ResourceController extends 
         resource = binder.update(resource, resourceTO);
         resource = resourceDAO.save(resource);
 
-        auditManager.audit(Category.resource, ResourceSubCategory.update, Result.success,
-                "Successfully updated resource: " + resource.getName());
-
         return binder.getResourceTO(resource);
     }
 
@@ -144,9 +132,6 @@ public class ResourceController extends 
 
         ResourceTO resourceToDelete = binder.getResourceTO(resource);
 
-        auditManager.audit(Category.resource, ResourceSubCategory.delete, Result.success,
-                "Successfully deleted resource: " + resource.getName());
-
         resourceDAO.delete(resourceName);
 
         return resourceToDelete;
@@ -160,9 +145,6 @@ public class ResourceController extends 
             throw new NotFoundException("Resource '" + resourceName + "'");
         }
 
-        auditManager.audit(Category.resource, ResourceSubCategory.read, Result.success,
-                "Successfully read resource: " + resource.getName());
-
         return binder.getResourceTO(resource);
     }
 
@@ -171,9 +153,6 @@ public class ResourceController extends 
         Set<String> actionsClasses = classNamesLoader.getClassNames(
                 ImplementationClassNamesLoader.Type.PROPAGATION_ACTIONS);
 
-        auditManager.audit(Category.resource, AuditElements.ResourceSubCategory.getPropagationActionsClasses,
-                Result.success, "Successfully listed all PropagationActions classes: " + actionsClasses.size());
-
         return actionsClasses;
     }
 
@@ -191,11 +170,6 @@ public class ResourceController extends 
 
         List<ResourceTO> result = binder.getResourceTOs(resources);
 
-        auditManager.audit(Category.resource, ResourceSubCategory.list, Result.success,
-                connInstanceId == null
-                ? "Successfully listed all resources: " + result.size()
-                : "Successfully listed resources for connector " + connInstanceId + ": " + result.size());
-
         return result;
     }
 
@@ -253,10 +227,6 @@ public class ResourceController extends 
             attributes.add(connectorObject.getName());
         }
 
-        auditManager.audit(Category.resource, ResourceSubCategory.getObject, Result.success,
-                "Successfully read object " + accountIdValue + " with class " + objectClass
-                + " from resource " + resourceName);
-
         return connObjectUtil.getConnObjectTO(connectorObject);
     }
 
@@ -271,13 +241,7 @@ public class ResourceController extends 
         try {
             connector.test();
             result = true;
-
-            auditManager.audit(Category.connector, AuditElements.ConnectorSubCategory.check, Result.success,
-                    "Successfully checked connector: " + resourceTO);
         } catch (Exception e) {
-            auditManager.audit(Category.connector, AuditElements.ConnectorSubCategory.check, Result.failure,
-                    "Unsuccessful check for connector: " + resourceTO, e);
-
             LOG.error("Test connection failure {}", e);
             result = false;
         }
@@ -304,4 +268,34 @@ public class ResourceController extends 
 
         return res;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected ResourceTO resolveReference(final Method method, final Object... args) throws
+            UnresolvedReferenceException {
+        String name = null;
+
+        if (ArrayUtils.isNotEmpty(args)) {
+            for (int i = 0; name == null && i < args.length; i++) {
+                if (args[i] instanceof String) {
+                    name = (String) args[i];
+                } else if (args[i] instanceof ResourceTO) {
+                    name = ((ResourceTO) args[i]).getName();
+                }
+            }
+        }
+
+        if (name != null) {
+            try {
+                return binder.getResourceTO(resourceDAO.find(name));
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
+
+        throw new UnresolvedReferenceException();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java Wed Nov 20 11:37:34 2013
@@ -18,24 +18,21 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import javax.annotation.Resource;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.syncope.common.mod.RoleMod;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.services.InvalidSearchConditionException;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.AuditElements;
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.Result;
-import org.apache.syncope.common.types.AuditElements.RoleSubCategory;
 import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
@@ -71,9 +68,6 @@ public class RoleController extends Abst
     protected static final Logger LOG = LoggerFactory.getLogger(RoleController.class);
 
     @Autowired
-    protected AuditManager auditManager;
-
-    @Autowired
     protected RoleDAO roleDAO;
 
     @Autowired
@@ -115,9 +109,6 @@ public class RoleController extends Abst
             throw new NotFoundException("Role " + roleId);
         }
 
-        auditManager.audit(Category.role, RoleSubCategory.read, Result.success,
-                "Successfully read role: " + role.getId());
-
         return binder.getRoleTO(role);
     }
 
@@ -145,9 +136,6 @@ public class RoleController extends Abst
             throw new UnauthorizedRoleException(role.getId());
         }
 
-        auditManager.audit(Category.role, RoleSubCategory.selfRead, Result.success,
-                "Successfully read own role: " + role.getId());
-
         return binder.getRoleTO(role);
     }
 
@@ -165,11 +153,6 @@ public class RoleController extends Abst
                 ? null
                 : binder.getRoleTO(role.getParent());
 
-        auditManager.audit(Category.role, RoleSubCategory.parent, Result.success,
-                result == null
-                ? "Role " + role.getId() + " is a root role"
-                : "Found parent for role " + role.getId() + ": " + result.getId());
-
         return result;
     }
 
@@ -188,14 +171,11 @@ public class RoleController extends Abst
             }
         }
 
-        auditManager.audit(Category.role, RoleSubCategory.children, Result.success,
-                "Found " + childrenTOs.size() + " children of role " + roleId);
-
         return childrenTOs;
     }
 
     @PreAuthorize("hasRole('ROLE_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<RoleTO> search(final NodeCond searchCondition)
             throws InvalidSearchConditionException {
 
@@ -203,7 +183,7 @@ public class RoleController extends Abst
     }
 
     @PreAuthorize("hasRole('ROLE_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<RoleTO> search(final NodeCond searchCondition, final int page, final int size)
             throws InvalidSearchConditionException {
 
@@ -223,14 +203,11 @@ public class RoleController extends Abst
             result.add(binder.getRoleTO(role));
         }
 
-        auditManager.audit(Category.role, AuditElements.RoleSubCategory.read, Result.success,
-                "Successfully searched for roles (page=" + page + ", size=" + size + "): " + result.size());
-
         return result;
     }
 
     @PreAuthorize("hasRole('ROLE_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public int searchCount(final NodeCond searchCondition)
             throws InvalidSearchConditionException {
 
@@ -253,9 +230,6 @@ public class RoleController extends Abst
             roleTOs.add(binder.getRoleTO(role));
         }
 
-        auditManager.audit(Category.role, RoleSubCategory.list, Result.success,
-                "Successfully listed all roles: " + roleTOs.size());
-
         return roleTOs;
     }
 
@@ -295,9 +269,6 @@ public class RoleController extends Abst
 
         LOG.debug("About to return created role\n{}", savedTO);
 
-        auditManager.audit(Category.role, RoleSubCategory.create, Result.success,
-                "Successfully created role: " + savedTO.getId());
-
         return savedTO;
     }
 
@@ -330,9 +301,6 @@ public class RoleController extends Abst
         final RoleTO updatedTO = binder.getRoleTO(updated.getResult());
         updatedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
-        auditManager.audit(Category.role, RoleSubCategory.update, Result.success,
-                "Successfully updated role: " + role.getId());
-
         LOG.debug("About to return updated role\n{}", updatedTO);
 
         return updatedTO;
@@ -349,9 +317,6 @@ public class RoleController extends Abst
                 owned.add(role.getId() + " " + role.getName());
             }
 
-            auditManager.audit(Category.role, AuditElements.UserSubCategory.delete, Result.failure,
-                    "Could not delete role: " + roleId + " because of role(s) ownership " + owned);
-
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RoleOwnership);
             sce.getElements().addAll(owned);
             throw sce;
@@ -382,16 +347,13 @@ public class RoleController extends Abst
 
         rwfAdapter.delete(roleId);
 
-        auditManager.audit(Category.role, RoleSubCategory.delete, Result.success,
-                "Successfully deleted role: " + roleId);
-
         LOG.debug("Role successfully deleted: {}", roleId);
 
         return roleTO;
     }
 
     @PreAuthorize("hasRole('ROLE_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public RoleTO unlink(final Long roleId, final Collection<String> resources) {
         LOG.debug("About to unlink role({}) and resources {}", roleId, resources);
@@ -405,16 +367,13 @@ public class RoleController extends Abst
 
         final RoleTO updatedTO = binder.getRoleTO(updated.getResult());
 
-        auditManager.audit(Category.user, AuditElements.RoleSubCategory.update, Result.success,
-                "Successfully updated role: " + updatedTO.getName());
-
         LOG.debug("About to return updated role\n{}", updatedTO);
 
         return updatedTO;
     }
 
     @PreAuthorize("hasRole('ROLE_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public RoleTO unassign(final Long roleId, final Collection<String> resources) {
         LOG.debug("About to unassign role({}) and resources {}", roleId, resources);
@@ -427,7 +386,7 @@ public class RoleController extends Abst
     }
 
     @PreAuthorize("hasRole('ROLE_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public RoleTO deprovision(final Long roleId, final Collection<String> resources) {
         LOG.debug("About to deprovision role({}) from resources {}", roleId, resources);
@@ -450,11 +409,39 @@ public class RoleController extends Abst
         final RoleTO updatedTO = binder.getRoleTO(role);
         updatedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
-        auditManager.audit(Category.user, AuditElements.RoleSubCategory.update, Result.success,
-                "Successfully deprovisioned role: " + updatedTO.getName());
-
         LOG.debug("About to return updated role\n{}", updatedTO);
 
         return updatedTO;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected RoleTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException {
+        Long id = null;
+
+        if (ArrayUtils.isNotEmpty(args)) {
+            for (int i = 0; id == null && i < args.length; i++) {
+                if (args[i] instanceof Long) {
+                    id = (Long) args[i];
+                } else if (args[i] instanceof RoleTO) {
+                    id = ((RoleTO) args[i]).getId();
+                } else if (args[i] instanceof RoleMod) {
+                    id = ((RoleMod) args[i]).getId();
+                }
+            }
+        }
+
+        if (id != null) {
+            try {
+                return binder.getRoleTO(id);
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
+
+        throw new UnresolvedReferenceException();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java Wed Nov 20 11:37:34 2013
@@ -18,20 +18,20 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import javax.persistence.EntityExistsException;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.common.to.AbstractSchemaTO;
 import org.apache.syncope.common.to.DerSchemaTO;
 import org.apache.syncope.common.to.SchemaTO;
 import org.apache.syncope.common.to.VirSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.AuditElements;
-import org.apache.syncope.common.types.SchemaType;
 import org.apache.syncope.common.types.ClientExceptionType;
+import org.apache.syncope.common.types.SchemaType;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
 import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
 import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
@@ -46,10 +46,7 @@ import org.springframework.security.acce
 import org.springframework.stereotype.Component;
 
 @Component
-public class SchemaController extends AbstractController {
-
-    @Autowired
-    private AuditManager auditManager;
+public class SchemaController extends AbstractTransactionalController<SchemaTO> {
 
     @Autowired
     private SchemaDAO schemaDAO;
@@ -109,10 +106,8 @@ public class SchemaController extends Ab
                 AbstractVirSchema virSchema = attrUtil.newVirSchema();
                 binder.create((VirSchemaTO) schemaTO, virSchema);
                 virSchema = virSchemaDAO.save(virSchema);
-
                 created = (T) binder.getVirSchemaTO(virSchema);
                 break;
-
             case DERIVED:
                 AbstractDerSchema derSchema = attrUtil.newDerSchema();
                 binder.create((DerSchemaTO) schemaTO, derSchema);
@@ -129,11 +124,6 @@ public class SchemaController extends Ab
 
                 created = (T) binder.getSchemaTO(normalSchema, attrUtil);
         }
-
-        auditManager.audit(AuditElements.Category.schema, AuditElements.SchemaSubCategory.create,
-                AuditElements.Result.success,
-                "Successfully created schema: " + schemaType + "/" + attrType + "/" + created.getName());
-
         return created;
     }
 
@@ -158,10 +148,6 @@ public class SchemaController extends Ab
             default:
                 schemaDAO.delete(schemaName, attrUtil);
         }
-
-        auditManager.audit(AuditElements.Category.schema, AuditElements.SchemaSubCategory.delete,
-                AuditElements.Result.success,
-                "Successfully deleted schema: " + schemaType + "/" + attrType + "/" + schemaName);
     }
 
     @PreAuthorize("isAuthenticated()")
@@ -196,17 +182,13 @@ public class SchemaController extends Ab
                 }
         }
 
-        auditManager.audit(AuditElements.Category.schema, AuditElements.SchemaSubCategory.list,
-                AuditElements.Result.success,
-                "Successfully listed schemas: " + schemaType + "/" + attrType + " " + result.size());
-
         return result;
     }
 
     @PreAuthorize("hasRole('SCHEMA_READ')")
     @SuppressWarnings("unchecked")
-    public <T extends AbstractSchemaTO> T read(final AttributableType attrType, final SchemaType schemaType,
-            final String schemaName) {
+    public <T extends AbstractSchemaTO> T read(
+            final AttributableType attrType, final SchemaType schemaType, final String schemaName) {
 
         final AttributableUtil attrUtil = AttributableUtil.getInstance(attrType);
 
@@ -240,10 +222,6 @@ public class SchemaController extends Ab
                 read = (T) binder.getSchemaTO(schema, attrUtil);
         }
 
-        auditManager.audit(AuditElements.Category.schema, AuditElements.SchemaSubCategory.read,
-                AuditElements.Result.success,
-                "Successfully read schema: " + schemaType + "/" + attrType + "/" + schemaName);
-
         return read;
     }
 
@@ -288,9 +266,40 @@ public class SchemaController extends Ab
                 binder.update((SchemaTO) schemaTO, schema, attrUtil);
                 schemaDAO.save(schema);
         }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected SchemaTO resolveReference(final Method method, final Object... args)
+            throws UnresolvedReferenceException {
+        String kind = null;
+        String name = null;
+        if (ArrayUtils.isNotEmpty(args)) {
+            for (int i = 0; (name == null || kind == null) && i < args.length; i++) {
+                if (args[i] instanceof String) {
+                    if (kind == null) {
+                        kind = (String) args[i];
+                    } else {
+                        name = (String) args[i];
+                    }
+                } else if (args[i] instanceof SchemaTO) {
+                    name = ((SchemaTO) args[i]).getName();
+                }
+            }
+        }
+
+        if (name != null) {
+            try {
+                final AttributableUtil attrUtil = AttributableUtil.valueOf(kind);
+                return binder.getSchemaTO(schemaDAO.find(name, attrUtil.schemaClass()), attrUtil);
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
 
-        auditManager.audit(AuditElements.Category.schema, AuditElements.SchemaSubCategory.update,
-                AuditElements.Result.success,
-                "Successfully updated schema: " + schemaType + "/" + attrType + "/" + schemaName);
+        throw new UnresolvedReferenceException();
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/TaskController.java Wed Nov 20 11:37:34 2013
@@ -18,26 +18,23 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.syncope.common.to.BulkAction;
 import org.apache.syncope.common.to.BulkActionRes;
 import org.apache.syncope.common.to.SchedTaskTO;
 import org.apache.syncope.common.to.SyncTaskTO;
 import org.apache.syncope.common.to.TaskExecTO;
 import org.apache.syncope.common.to.AbstractTaskTO;
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.Result;
-import org.apache.syncope.common.types.AuditElements.TaskSubCategory;
 import org.apache.syncope.common.types.PropagationMode;
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.types.TaskType;
-import org.apache.syncope.common.validation.SyncopeClientCompositeException;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.init.ImplementationClassNamesLoader;
 import org.apache.syncope.core.init.JobInstanceLoader;
 import org.apache.syncope.core.notification.NotificationJob;
@@ -62,10 +59,7 @@ import org.springframework.security.acce
 import org.springframework.stereotype.Component;
 
 @Component
-public class TaskController extends AbstractController {
-
-    @Autowired
-    private AuditManager auditManager;
+public class TaskController extends AbstractTransactionalController<AbstractTaskTO> {
 
     @Autowired
     private TaskDAO taskDAO;
@@ -110,9 +104,6 @@ public class TaskController extends Abst
             throw sce;
         }
 
-        auditManager.audit(Category.task, TaskSubCategory.create, Result.success,
-                "Successfully created task: " + task.getId() + "/" + taskUtil);
-
         return binder.getTaskTO(task, taskUtil);
     }
 
@@ -145,9 +136,6 @@ public class TaskController extends Abst
             throw sce;
         }
 
-        auditManager.audit(Category.task, TaskSubCategory.update, Result.success,
-                "Successfully udpated task: " + task.getId() + "/" + taskUtil);
-
         return binder.getTaskTO(task, taskUtil);
     }
 
@@ -167,9 +155,6 @@ public class TaskController extends Abst
             taskTOs.add((T) binder.getTaskTO(task, taskUtil));
         }
 
-        auditManager.audit(Category.task, TaskSubCategory.list, Result.success,
-                "Successfully listed all tasks: " + taskTOs.size() + "/" + taskUtil);
-
         return taskTOs;
     }
 
@@ -184,31 +169,17 @@ public class TaskController extends Abst
             taskTOs.add((T) binder.getTaskTO(task, taskUtil));
         }
 
-        auditManager.audit(Category.task, TaskSubCategory.list, Result.success,
-                "Successfully listed all tasks (page=" + page + ", size=" + size + "): "
-                + taskTOs.size() + "/" + taskUtil);
-
         return taskTOs;
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
     public Set<String> getJobClasses() {
-        Set<String> jobClasses = classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.TASKJOB);
-
-        auditManager.audit(Category.task, TaskSubCategory.getJobClasses, Result.success,
-                "Successfully listed all Job classes: " + jobClasses.size());
-
-        return jobClasses;
-    }
+        return classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.TASKJOB);
+        }
 
     @PreAuthorize("hasRole('TASK_LIST')")
     public Set<String> getSyncActionsClasses() {
-        Set<String> actionsClasses = classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.SYNC_ACTIONS);
-
-        auditManager.audit(Category.task, TaskSubCategory.getSyncActionsClasses, Result.success,
-                "Successfully listed all SyncActions classes: " + actionsClasses.size());
-
-        return actionsClasses;
+        return classNamesLoader.getClassNames(ImplementationClassNamesLoader.Type.SYNC_ACTIONS);
     }
 
     @PreAuthorize("hasRole('TASK_READ')")
@@ -217,13 +188,8 @@ public class TaskController extends Abst
         if (task == null) {
             throw new NotFoundException("Task " + taskId);
         }
-        TaskUtil taskUtil = TaskUtil.getInstance(task);
-
-        auditManager.audit(Category.task, TaskSubCategory.read, Result.success,
-                "Successfully read task: " + task.getId() + "/" + taskUtil);
-
-        return binder.getTaskTO(task, taskUtil);
-    }
+        return binder.getTaskTO(task, TaskUtil.getInstance(task));
+}
 
     @PreAuthorize("hasRole('TASK_READ')")
     public TaskExecTO readExecution(final Long executionId) {
@@ -231,10 +197,6 @@ public class TaskController extends Abst
         if (taskExec == null) {
             throw new NotFoundException("Task execution " + executionId);
         }
-
-        auditManager.audit(Category.task, TaskSubCategory.readExecution, Result.success,
-                "Successfully read task execution: " + taskExec.getId());
-
         return binder.getTaskExecTO(taskExec);
     }
 
@@ -274,9 +236,6 @@ public class TaskController extends Abst
                 } catch (Exception e) {
                     LOG.error("While executing task {}", task, e);
 
-                    auditManager.audit(Category.task, TaskSubCategory.execute, Result.failure,
-                            "Could not start execution for task: " + task.getId() + "/" + taskUtil, e);
-
                     SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
                     sce.getElements().add(e.getMessage());
                     throw sce;
@@ -292,10 +251,6 @@ public class TaskController extends Abst
             default:
         }
         LOG.debug("Execution finished for {}, {}", task, result);
-
-        auditManager.audit(Category.task, TaskSubCategory.execute, Result.success,
-                "Successfully started execution for task: " + task.getId() + "/" + taskUtil);
-
         return result;
     }
 
@@ -334,19 +289,12 @@ public class TaskController extends Abst
         }
 
         if (!sce.isEmpty()) {
-            auditManager.audit(Category.task, TaskSubCategory.report, Result.failure,
-                    "Could not reported execution status: " + exec.getId() + "/" + taskUtil, sce);
             throw sce;
         }
 
         exec.setStatus(status.toString());
         exec.setMessage(message);
-        exec = taskExecDAO.save(exec);
-
-        auditManager.audit(Category.task, TaskSubCategory.report, Result.success,
-                "Successfully reported execution status: " + exec.getId() + "/" + taskUtil);
-
-        return binder.getTaskExecTO(exec);
+        return binder.getTaskExecTO(taskExecDAO.save(exec));
     }
 
     @PreAuthorize("hasRole('TASK_DELETE')")
@@ -364,10 +312,6 @@ public class TaskController extends Abst
         }
 
         taskDAO.delete(task);
-
-        auditManager.audit(Category.task, TaskSubCategory.delete, Result.success,
-                "Successfully deleted task: " + task.getId() + "/" + taskUtil);
-
         return taskToDelete;
     }
 
@@ -379,11 +323,7 @@ public class TaskController extends Abst
         }
 
         TaskExecTO taskExecutionToDelete = binder.getTaskExecTO(taskExec);
-
         taskExecDAO.delete(taskExec);
-
-        auditManager.audit(Category.task, TaskSubCategory.deleteExecution, Result.success,
-                "Successfully deleted task execution: " + taskExec.getId());
         return taskExecutionToDelete;
     }
 
@@ -437,4 +377,36 @@ public class TaskController extends Abst
 
         return res;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected AbstractTaskTO resolveReference(final Method method, final Object... args) throws
+            UnresolvedReferenceException {
+        Long id = null;
+
+        if (ArrayUtils.isNotEmpty(args)
+                && !"deleteExecution".equals(method.getName()) && !"readExecution".equals(method.getName())) {
+            for (int i = 0; id == null && i < args.length; i++) {
+                if (args[i] instanceof Long) {
+                    id = (Long) args[i];
+                } else if (args[i] instanceof AbstractTaskTO) {
+                    id = ((AbstractTaskTO) args[i]).getId();
+                }
+            }
+        }
+
+        if (id != null) {
+            try {
+                final Task task = taskDAO.find(id);
+                return binder.getTaskTO(task, TaskUtil.getInstance(task));
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
+
+        throw new UnresolvedReferenceException();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java Wed Nov 20 11:37:34 2013
@@ -18,15 +18,16 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.security.AccessControlException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.syncope.common.mod.StatusMod;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.syncope.common.mod.UserMod;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.services.InvalidSearchConditionException;
@@ -36,16 +37,9 @@ import org.apache.syncope.common.to.Bulk
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.AuditElements;
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.Result;
-import org.apache.syncope.common.types.AuditElements.UserSubCategory;
 import org.apache.syncope.common.types.ClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientException;
-import org.apache.syncope.core.audit.AuditManager;
-import org.apache.syncope.core.notification.NotificationManager;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
-import org.apache.syncope.core.persistence.beans.SyncopeConf;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
@@ -85,9 +79,6 @@ public class UserController extends Abst
     protected static final Logger LOG = LoggerFactory.getLogger(UserController.class);
 
     @Autowired
-    protected AuditManager auditManager;
-
-    @Autowired
     protected UserDAO userDAO;
 
     @Autowired
@@ -114,16 +105,8 @@ public class UserController extends Abst
     @Autowired
     protected AttributableTransformer attrTransformer;
 
-    @Autowired
-    protected NotificationManager notificationManager;
-
     public boolean isSelfRegistrationAllowed() {
-        final SyncopeConf selfRegistrationAllowed = confDAO.find("selfRegistration.allowed", "false");
-
-        auditManager.audit(Category.user, AuditElements.UserSubCategory.selfRegistrationAllowed, Result.success,
-                "Successfully checked whether self registration is allowed");
-
-        return Boolean.valueOf(selfRegistrationAllowed.getValue());
+        return Boolean.valueOf(confDAO.find("selfRegistration.allowed", "false").getValue());
     }
 
     @PreAuthorize("hasRole('USER_READ')")
@@ -137,13 +120,13 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_LIST')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public int count() {
         return userDAO.count(EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()));
     }
 
     @PreAuthorize("hasRole('USER_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public int searchCount(final NodeCond searchCondition) throws InvalidSearchConditionException {
         if (!searchCondition.isValid()) {
             LOG.error("Invalid search condition: {}", searchCondition);
@@ -155,7 +138,7 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_LIST')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<UserTO> list() {
         List<SyncopeUser> users = userDAO.findAll(
                 EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames()));
@@ -165,14 +148,11 @@ public class UserController extends Abst
             userTOs.add(binder.getUserTO(user));
         }
 
-        auditManager.audit(Category.user, UserSubCategory.list, Result.success,
-                "Successfully listed all users: " + userTOs.size());
-
         return userTOs;
     }
 
     @PreAuthorize("hasRole('USER_LIST')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<UserTO> list(final int page, final int size) {
         Set<Long> adminRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
 
@@ -182,9 +162,6 @@ public class UserController extends Abst
             userTOs.add(binder.getUserTO(user));
         }
 
-        auditManager.audit(Category.user, UserSubCategory.list, Result.success,
-                "Successfully listed all users (page=" + page + ", size=" + size + "): " + userTOs.size());
-
         return userTOs;
     }
 
@@ -192,27 +169,17 @@ public class UserController extends Abst
             + "and not(hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT))")
     @Transactional(readOnly = true)
     public UserTO readSelf() {
-        UserTO userTO = binder.getAuthenticatedUserTO();
-
-        auditManager.audit(Category.user, UserSubCategory.read, Result.success,
-                "Successfully read own data: " + userTO.getUsername());
-
-        return userTO;
+        return binder.getAuthenticatedUserTO();
     }
 
     @PreAuthorize("hasRole('USER_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public UserTO read(final Long userId) {
-        UserTO result = binder.getUserTO(userId);
-
-        auditManager.audit(Category.user, UserSubCategory.read, Result.success,
-                "Successfully read user: " + userId);
-
-        return result;
+        return binder.getUserTO(userId);
     }
 
     @PreAuthorize("hasRole('USER_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<UserTO> search(final NodeCond searchCondition)
             throws InvalidSearchConditionException {
 
@@ -220,7 +187,7 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_READ')")
-    @Transactional(readOnly = true, rollbackFor = { Throwable.class })
+    @Transactional(readOnly = true, rollbackFor = {Throwable.class})
     public List<UserTO> search(final NodeCond searchCondition, final int page, final int size)
             throws InvalidSearchConditionException {
 
@@ -240,9 +207,6 @@ public class UserController extends Abst
             result.add(binder.getUserTO(user));
         }
 
-        auditManager.audit(Category.user, UserSubCategory.read, Result.success,
-                "Successfully searched for users (page=" + page + ", size=" + size + "): " + result.size());
-
         return result;
     }
 
@@ -294,16 +258,11 @@ public class UserController extends Abst
             propagationReporter.onPrimaryResourceFailure(tasks);
         }
 
-        notificationManager.createTasks(created.getResult().getKey(), created.getPerformedTasks());
-
         final UserTO savedTO = binder.getUserTO(created.getResult().getKey());
         savedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
         LOG.debug("About to return created user\n{}", savedTO);
 
-        auditManager.audit(Category.user, UserSubCategory.create, Result.success,
-                "Successfully created user: " + savedTO.getUsername());
-
         return savedTO;
     }
 
@@ -342,14 +301,9 @@ public class UserController extends Abst
             propagationReporter.onPrimaryResourceFailure(tasks);
         }
 
-        notificationManager.createTasks(updated.getResult().getKey().getId(), updated.getPerformedTasks());
-
         final UserTO updatedTO = binder.getUserTO(updated.getResult().getKey().getId());
         updatedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
-        auditManager.audit(Category.user, UserSubCategory.update, Result.success,
-                "Successfully updated user: " + updatedTO.getUsername());
-
         LOG.debug("About to return updated user\n{}", updatedTO);
 
         return updatedTO;
@@ -378,7 +332,7 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public UserTO status(final StatusMod statusMod) {
         LOG.debug("About to mod status {}", statusMod);
 
@@ -397,14 +351,17 @@ public class UserController extends Abst
 
         List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
                 user, statusMod.getType() != StatusMod.ModType.SUSPEND, resourcesToBeExcluded);
-        taskExecutor.execute(tasks);
-
-        notificationManager.createTasks(updated.getResult(), updated.getPerformedTasks());
+        PropagationReporter propReporter =
+                ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class);
+        try {
+            taskExecutor.execute(tasks, propReporter);
+        } catch (PropagationException e) {
+            LOG.error("Error propagation primary resource", e);
+            propReporter.onPrimaryResourceFailure(tasks);
+        }
 
         final UserTO savedTO = binder.getUserTO(updated.getResult());
-
-        auditManager.audit(Category.user, UserSubCategory.setStatus, Result.success,
-                "Successfully changed status to " + savedTO.getStatus() + " for user: " + savedTO.getUsername());
+        savedTO.getPropagationStatusTOs().addAll(propReporter.getStatuses());
 
         LOG.debug("About to return updated user\n{}", savedTO);
 
@@ -430,9 +387,6 @@ public class UserController extends Abst
                 owned.add(role.getId() + " " + role.getName());
             }
 
-            auditManager.audit(Category.user, UserSubCategory.delete, Result.failure,
-                    "Could not delete user: " + userId + " because of role(s) ownership " + owned);
-
             SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RoleOwnership);
             sce.getElements().addAll(owned);
             throw sce;
@@ -443,7 +397,6 @@ public class UserController extends Abst
         // information could only be available after uwfAdapter.delete(), which
         // will also effectively remove user from db, thus making virtually
         // impossible by NotificationManager to fetch required user information
-        notificationManager.createTasks(userId, Collections.singleton("delete"));
 
         List<PropagationTask> tasks = propagationManager.getUserDeleteTaskIds(userId);
 
@@ -468,9 +421,6 @@ public class UserController extends Abst
         }
         deletedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
-        auditManager.audit(Category.user, UserSubCategory.delete, Result.success,
-                "Successfully deleted user: " + userId);
-
         LOG.debug("User successfully deleted: {}", userId);
 
         return deletedTO;
@@ -532,7 +482,7 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public UserTO unlink(final Long userId, final Collection<String> resources) {
         LOG.debug("About to unlink user({}) and resources {}", userId, resources);
@@ -546,16 +496,13 @@ public class UserController extends Abst
 
         final UserTO updatedTO = binder.getUserTO(updated.getResult().getKey().getId());
 
-        auditManager.audit(Category.user, UserSubCategory.update, Result.success,
-                "Successfully updated user: " + updatedTO.getUsername());
-
         LOG.debug("About to return updated user\n{}", updatedTO);
 
         return updatedTO;
     }
 
     @PreAuthorize("hasRole('USER_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public UserTO unassign(final Long userId, final Collection<String> resources) {
         LOG.debug("About to unassign user({}) and resources {}", userId, resources);
@@ -568,7 +515,7 @@ public class UserController extends Abst
     }
 
     @PreAuthorize("hasRole('USER_UPDATE')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     @Override
     public UserTO deprovision(final Long userId, final Collection<String> resources) {
         LOG.debug("About to deprovision user({}) from resources {}", userId, resources);
@@ -591,11 +538,41 @@ public class UserController extends Abst
         final UserTO updatedUserTO = binder.getUserTO(user);
         updatedUserTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());
 
-        auditManager.audit(Category.user, UserSubCategory.update, Result.success,
-                "Successfully deprovisioned user: " + updatedUserTO.getUsername());
-
         LOG.debug("About to return updated user\n{}", updatedUserTO);
 
         return updatedUserTO;
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected UserTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException {
+        Object id = null;
+
+        if (ArrayUtils.isNotEmpty(args)) {
+            for (int i = 0; id == null && i < args.length; i++) {
+                if (args[i] instanceof Long) {
+                    id = (Long) args[i];
+                } else if (args[i] instanceof String) {
+                    id = (String) args[i];
+                } else if (args[i] instanceof UserTO) {
+                    id = ((UserTO) args[i]).getId();
+                } else if (args[i] instanceof UserMod) {
+                    id = ((UserMod) args[i]).getId();
+                }
+            }
+        }
+
+        if (id != null) {
+            try {
+                return id instanceof Long ? binder.getUserTO((Long) id) : binder.getUserTO((String) id);
+            } catch (Throwable ignore) {
+                LOG.debug("Unresolved reference", ignore);
+                throw new UnresolvedReferenceException(ignore);
+            }
+        }
+
+        throw new UnresolvedReferenceException();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java Wed Nov 20 11:37:34 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.rest.controller;
 
+import java.lang.reflect.Method;
 import java.util.AbstractMap;
 import java.util.List;
 import java.util.Map;
@@ -25,9 +26,6 @@ import org.apache.syncope.common.mod.Abs
 import org.apache.syncope.common.mod.UserMod;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.to.WorkflowFormTO;
-import org.apache.syncope.common.types.AuditElements;
-import org.apache.syncope.core.audit.AuditManager;
-import org.apache.syncope.core.notification.NotificationManager;
 import org.apache.syncope.core.persistence.beans.PropagationTask;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 import org.apache.syncope.core.propagation.PropagationTaskExecutor;
@@ -42,10 +40,7 @@ import org.springframework.stereotype.Co
 import org.springframework.transaction.annotation.Transactional;
 
 @Component
-public class UserWorkflowController extends AbstractController {
-
-    @Autowired
-    protected AuditManager auditManager;
+public class UserWorkflowController extends AbstractTransactionalController<WorkflowFormTO> {
 
     @Autowired
     protected UserWorkflowAdapter uwfAdapter;
@@ -57,22 +52,13 @@ public class UserWorkflowController exte
     protected PropagationTaskExecutor taskExecutor;
 
     @Autowired
-    protected NotificationManager notificationManager;
-
-    @Autowired
     protected UserDataBinder binder;
 
     @PreAuthorize("hasRole('WORKFLOW_FORM_CLAIM')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public WorkflowFormTO claimForm(final String taskId) {
-        WorkflowFormTO result = uwfAdapter.claimForm(taskId,
+        return uwfAdapter.claimForm(taskId,
                 SecurityContextHolder.getContext().getAuthentication().getName());
-
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.claimForm,
-                AuditElements.Result.success,
-                "Successfully claimed workflow form: " + taskId);
-
-        return result;
     }
 
     @PreAuthorize("hasRole('USER_UPDATE')")
@@ -86,64 +72,40 @@ public class UserWorkflowController exte
 
         List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
                 new WorkflowResult<Map.Entry<UserMod, Boolean>>(
-                        new AbstractMap.SimpleEntry<UserMod, Boolean>(userMod, null),
-                        updated.getPropByRes(), updated.getPerformedTasks()));
+                new AbstractMap.SimpleEntry<UserMod, Boolean>(userMod, null),
+                updated.getPropByRes(), updated.getPerformedTasks()));
 
         taskExecutor.execute(tasks);
 
-        notificationManager.createTasks(updated.getResult(), updated.getPerformedTasks());
-
         final UserTO savedTO = binder.getUserTO(updated.getResult());
 
         LOG.debug("About to return updated user\n{}", savedTO);
 
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.executeWorkflow,
-                AuditElements.Result.success,
-                "Successfully executed workflow action " + taskId + " on user: " + userTO.getUsername());
-
         return savedTO;
     }
 
     @PreAuthorize("hasRole('WORKFLOW_FORM_READ') and hasRole('USER_READ')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public WorkflowFormTO getFormForUser(final Long userId) {
         SyncopeUser user = binder.getUserFromId(userId);
-        WorkflowFormTO result = uwfAdapter.getForm(user.getWorkflowId());
-
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.getFormForUser,
-                AuditElements.Result.success,
-                "Successfully read workflow form for user: " + user.getUsername());
-
-        return result;
+        return uwfAdapter.getForm(user.getWorkflowId());
     }
 
     @PreAuthorize("hasRole('WORKFLOW_FORM_LIST')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public List<WorkflowFormTO> getForms() {
-        List<WorkflowFormTO> forms = uwfAdapter.getForms();
-
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.getForms,
-                AuditElements.Result.success,
-                "Successfully list workflow forms: " + forms.size());
-
-        return forms;
+        return uwfAdapter.getForms();
     }
 
     @PreAuthorize("hasRole('WORKFLOW_FORM_READ') and hasRole('USER_READ')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public List<WorkflowFormTO> getForms(final Long userId, final String formName) {
         SyncopeUser user = binder.getUserFromId(userId);
-        final List<WorkflowFormTO> result = uwfAdapter.getForms(user.getWorkflowId(), formName);
-
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.getFormForUser,
-                AuditElements.Result.success,
-                "Successfully read workflow form for user: " + user.getUsername());
-
-        return result;
+        return uwfAdapter.getForms(user.getWorkflowId(), formName);
     }
 
     @PreAuthorize("hasRole('WORKFLOW_FORM_SUBMIT')")
-    @Transactional(rollbackFor = { Throwable.class })
+    @Transactional(rollbackFor = {Throwable.class})
     public UserTO submitForm(final WorkflowFormTO form) {
         LOG.debug("About to process form {}", form);
 
@@ -157,21 +119,23 @@ public class UserWorkflowController exte
 
             List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
                     new WorkflowResult<Map.Entry<UserMod, Boolean>>(
-                            new AbstractMap.SimpleEntry<UserMod, Boolean>((UserMod) updated.getResult(), Boolean.TRUE),
-                            updated.getPropByRes(),
-                            updated.getPerformedTasks()));
+                    new AbstractMap.SimpleEntry<UserMod, Boolean>((UserMod) updated.getResult(), Boolean.TRUE),
+                    updated.getPropByRes(),
+                    updated.getPerformedTasks()));
 
             taskExecutor.execute(tasks);
         }
 
-        UserTO savedTO = binder.getUserTO(updated.getResult().getId());
-
-        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.submitForm,
-                AuditElements.Result.success,
-                "Successfully submitted workflow form for : " + savedTO.getUsername());
+        final UserTO savedTO = binder.getUserTO(updated.getResult().getId());
 
         LOG.debug("About to return user after form processing\n{}", savedTO);
 
         return savedTO;
     }
+
+    @Override
+    protected WorkflowFormTO resolveReference(final Method method, final Object... args)
+            throws UnresolvedReferenceException {
+        throw new UnresolvedReferenceException();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/WorkflowController.java Wed Nov 20 11:37:34 2013
@@ -19,13 +19,9 @@
 package org.apache.syncope.core.rest.controller;
 
 import java.io.OutputStream;
-import java.util.List;
+import java.lang.reflect.Method;
 import javax.ws.rs.core.MediaType;
-
-import org.apache.syncope.common.types.AuditElements.Category;
-import org.apache.syncope.common.types.AuditElements.Result;
-import org.apache.syncope.common.types.AuditElements.WorkflowSubCategory;
-import org.apache.syncope.core.audit.AuditManager;
+import org.apache.syncope.common.AbstractBaseBean;
 import org.apache.syncope.core.workflow.WorkflowAdapter;
 import org.apache.syncope.core.workflow.WorkflowDefinitionFormat;
 import org.apache.syncope.core.workflow.WorkflowException;
@@ -37,10 +33,7 @@ import org.springframework.stereotype.Co
 import org.springframework.transaction.annotation.Transactional;
 
 @Component
-public class WorkflowController extends AbstractController {
-
-    @Autowired
-    private AuditManager auditManager;
+public class WorkflowController extends AbstractTransactionalController<AbstractBaseBean> {
 
     @Autowired
     private UserWorkflowAdapter uwfAdapter;
@@ -53,9 +46,6 @@ public class WorkflowController extends 
             throws WorkflowException {
 
         adapter.exportDefinition(format, os);
-
-        auditManager.audit(Category.workflow, WorkflowSubCategory.exportDefinition, Result.success,
-                "Successfully exported workflow definition");
     }
 
     private WorkflowDefinitionFormat getFormat(final MediaType format) {
@@ -82,11 +72,7 @@ public class WorkflowController extends 
 
     private void exportDiagram(final WorkflowAdapter adapter, final OutputStream os)
             throws WorkflowException {
-
         adapter.exportDiagram(os);
-
-        auditManager.audit(Category.workflow, WorkflowSubCategory.exportDiagram, Result.success,
-                "Successfully export workflow diagram");
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_READ')")
@@ -107,11 +93,7 @@ public class WorkflowController extends 
 
     private void importDefinition(
             final WorkflowAdapter adapter, final WorkflowDefinitionFormat format, final String definition) {
-
         adapter.importDefinition(format, definition);
-
-        auditManager.audit(Category.workflow, WorkflowSubCategory.importDefinition, Result.success,
-                "Successfully imported workflow definition");
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_UPDATE')")
@@ -124,22 +106,12 @@ public class WorkflowController extends 
         importDefinition(rwfAdapter, getFormat(format), definition);
     }
 
-    private List<String> getDefinedTasks(final WorkflowAdapter adapter) {
-        List<String> definedTasks = adapter.getDefinedTasks();
-
-        auditManager.audit(Category.workflow, WorkflowSubCategory.getDefinedTasks, Result.success,
-                "Successfully got the list of defined workflow tasks: " + definedTasks.size());
-
-        return definedTasks;
-    }
-
-    @PreAuthorize("hasRole('WORKFLOW_TASK_LIST')")
-    public List<String> getDefinedUserTasks() {
-        return getDefinedTasks(uwfAdapter);
-    }
-
-    @PreAuthorize("hasRole('WORKFLOW_TASK_LIST')")
-    public List<String> getDefinedRoleTasks() {
-        return getDefinedTasks(rwfAdapter);
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected AbstractBaseBean resolveReference(final Method method, final Object... args)
+            throws UnresolvedReferenceException {
+        throw new UnresolvedReferenceException();
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Wed Nov 20 11:37:34 2013
@@ -191,7 +191,7 @@ public abstract class AbstractAttributab
                 LOG.debug("Ignoring invalid virtual schema {}", virSchemaName);
             }
         }
-
+        
         return virtualSchema;
     }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/NotificationDataBinder.java Wed Nov 20 11:37:34 2013
@@ -42,15 +42,12 @@ public class NotificationDataBinder {
 
     public Notification createNotification(final NotificationTO notificationTO) {
         Notification result = new Notification();
-
         updateNotification(result, notificationTO);
-
         return result;
     }
 
     public void updateNotification(final Notification notification, final NotificationTO notificationTO) {
         BeanUtils.copyProperties(notificationTO, notification, IGNORE_PROPERTIES);
-
         notification.setAbout(notificationTO.getAbout());
         notification.setRecipients(notificationTO.getRecipients());
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java Wed Nov 20 11:37:34 2013
@@ -88,7 +88,8 @@ public class SchemaDataBinder {
         fill(schema, schemaTO);
     }
 
-    public <T extends AbstractNormalSchema> SchemaTO getSchemaTO(final T schema, final AttributableUtil attributableUtil) {
+    public <T extends AbstractNormalSchema> SchemaTO getSchemaTO(
+            final T schema, final AttributableUtil attributableUtil) {
         SchemaTO schemaTO = new SchemaTO();
         BeanUtils.copyProperties(schema, schemaTO);
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java Wed Nov 20 11:37:34 2013
@@ -64,9 +64,9 @@ public class TaskDataBinder {
      */
     private static final Logger LOG = LoggerFactory.getLogger(TaskDataBinder.class);
 
-    private static final String[] IGNORE_TASK_PROPERTIES = { "executions", "resource", };
+    private static final String[] IGNORE_TASK_PROPERTIES = {"executions", "resource",};
 
-    private static final String[] IGNORE_TASK_EXECUTION_PROPERTIES = { "id", "task" };
+    private static final String[] IGNORE_TASK_EXECUTION_PROPERTIES = {"id", "task"};
 
     @Autowired
     private ResourceDAO resourceDAO;
@@ -83,6 +83,7 @@ public class TaskDataBinder {
                 sce.getElements().add("Invalid JEXL: " + attrTO.getValues().get(0));
             }
         }
+
         for (AttributeTO attrTO : attributableTO.getVirAttrs()) {
             if (!attrTO.getValues().isEmpty() && !JexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
                 sce.getElements().add("Invalid JEXL: " + attrTO.getValues().get(0));

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Wed Nov 20 11:37:34 2013
@@ -61,7 +61,7 @@ import org.springframework.stereotype.Co
 import org.springframework.transaction.annotation.Transactional;
 
 @Component
-@Transactional(rollbackFor = { Throwable.class })
+@Transactional(rollbackFor = {Throwable.class})
 public class UserDataBinder extends AbstractAttributableDataBinder {
 
     private static final String[] IGNORE_USER_PROPERTIES = {

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java Wed Nov 20 11:37:34 2013
@@ -21,8 +21,7 @@ package org.apache.syncope.core.security
 import java.util.Date;
 import javax.annotation.Resource;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.syncope.common.types.AuditElements.AuthenticationSubCategory;
-import org.apache.syncope.common.types.AuditElements.Category;
+import org.apache.syncope.common.types.AuditElements;
 import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.CipherAlgorithm;
 import org.apache.syncope.core.audit.AuditManager;
@@ -148,7 +147,15 @@ public class SyncopeAuthenticationProvid
 
             token.setDetails(authentication.getDetails());
 
-            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.success,
+            auditManager.audit(
+                    AuditElements.EventCategoryType.REST,
+                    "AuthenticationController",
+                    null,
+                    "login",
+                    Result.SUCCESS,
+                    null,
+                    authenticated,
+                    authentication,
                     "Successfully authenticated, with roles: " + token.getAuthorities());
 
             LOG.debug("User {} successfully authenticated, with roles {}",
@@ -165,7 +172,15 @@ public class SyncopeAuthenticationProvid
                 userDAO.save(user);
             }
 
-            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.failure,
+            auditManager.audit(
+                    AuditElements.EventCategoryType.REST,
+                    "AuthenticationController",
+                    null,
+                    "login",
+                    Result.FAILURE,
+                    null,
+                    authenticated,
+                    authentication,
                     "User " + authentication.getPrincipal() + " not authenticated");
 
             LOG.debug("User {} not authenticated", authentication.getPrincipal());

Copied: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java (from r1543384, syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java?p2=syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java&p1=syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java&r1=1543384&r2=1543782&rev=1543782&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ControllerHandler.java Wed Nov 20 11:37:34 2013
@@ -43,7 +43,7 @@ public class ControllerHandler {
     @Autowired
     private AuditManager auditManager;
 
-    @Around("within(@org.springframework.stereotype.Controller *)")
+    @Around("execution(* org.apache.syncope.core.rest.controller.AbstractController+.*(..))")
     public Object around(final ProceedingJoinPoint joinPoint) throws Throwable {
         final Class<?> clazz = joinPoint.getTarget().getClass();
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/LoggerServiceImpl.java Wed Nov 20 11:37:34 2013
@@ -25,6 +25,7 @@ import javax.ws.rs.BadRequestException;
 import javax.ws.rs.NotFoundException;
 
 import org.apache.syncope.common.services.LoggerService;
+import org.apache.syncope.common.to.EventCategoryTO;
 import org.apache.syncope.common.to.LoggerTO;
 import org.apache.syncope.common.types.AuditLoggerName;
 import org.apache.syncope.common.types.LoggerType;
@@ -109,4 +110,9 @@ public class LoggerServiceImpl extends A
                 throw new BadRequestException();
         }
     }
+
+    @Override
+    public List<EventCategoryTO> events() {
+        return controller.listAuditEvents();
+    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java Wed Nov 20 11:37:34 2013
@@ -21,6 +21,9 @@ package org.apache.syncope.core.services
 import java.io.IOException;
 import java.io.OutputStream;
 import javax.ws.rs.BadRequestException;
+import org.apache.syncope.common.types.RESTHeaders;
+import org.apache.syncope.core.rest.controller.WorkflowController;
+import org.springframework.beans.factory.annotation.Autowired;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -28,11 +31,7 @@ import javax.ws.rs.core.StreamingOutput;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.syncope.common.services.WorkflowService;
-import org.apache.syncope.common.types.WorkflowTasks;
 import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.types.RESTHeaders;
-import org.apache.syncope.core.rest.controller.WorkflowController;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
@@ -121,19 +120,4 @@ public class WorkflowServiceImpl extends
                 throw new BadRequestException();
         }
     }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public WorkflowTasks getDefinedTasks(final AttributableType kind) {
-        switch (kind) {
-            case USER:
-                return new WorkflowTasks(controller.getDefinedUserTasks());
-
-            case ROLE:
-                return new WorkflowTasks(controller.getDefinedRoleTasks());
-
-            default:
-                throw new BadRequestException();
-        }
-    }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPMembershipSyncActions.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPMembershipSyncActions.java?rev=1543782&r1=1543781&r2=1543782&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPMembershipSyncActions.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/sync/impl/LDAPMembershipSyncActions.java Wed Nov 20 11:37:34 2013
@@ -29,7 +29,10 @@ import org.apache.syncope.common.mod.Mem
 import org.apache.syncope.common.mod.UserMod;
 import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.RoleTO;
+import org.apache.syncope.common.types.AuditElements;
+import org.apache.syncope.common.types.AuditElements.Result;
 import org.apache.syncope.common.types.ConnConfProperty;
+import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.notification.NotificationManager;
 import org.apache.syncope.core.persistence.beans.ConnInstance;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -82,6 +85,9 @@ public class LDAPMembershipSyncActions e
     @Autowired
     private NotificationManager notificationManager;
 
+    @Autowired
+    private AuditManager auditManager;
+
     protected Map<Long, Long> membersBeforeRoleUpdate = Collections.<Long, Long>emptyMap();
 
     /**
@@ -197,20 +203,47 @@ public class LDAPMembershipSyncActions e
             return;
         }
 
+        Result result;
+
+        WorkflowResult<Map.Entry<UserMod, Boolean>> updated = null;
+
         try {
-            WorkflowResult<Map.Entry<UserMod, Boolean>> updated = uwfAdapter.update(userMod);
+            updated = uwfAdapter.update(userMod);
 
             List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
                     updated, Collections.singleton(resourceName));
 
             taskExecutor.execute(tasks);
-
-            notificationManager.createTasks(updated.getResult().getKey().getId(), updated.getPerformedTasks());
+            result = Result.SUCCESS;
         } catch (PropagationException e) {
+            result = Result.FAILURE;
             LOG.error("Could not propagate {}", userMod, e);
         } catch (Exception e) {
+            result = Result.FAILURE;
             LOG.error("Could not perform update {}", userMod, e);
         }
+
+        notificationManager.createTasks(
+                AuditElements.EventCategoryType.SYNCHRONIZATION,
+                this.getClass().getSimpleName(),
+                null,
+                "update",
+                result,
+                null, // searching for before object is too much expensive ... 
+                updated == null ? null : updated.getResult().getKey(),
+                userMod,
+                resourceName);
+
+        auditManager.audit(
+                AuditElements.EventCategoryType.SYNCHRONIZATION,
+                this.getClass().getSimpleName(),
+                null,
+                "update",
+                result,
+                null, // searching for before object is too much expensive ... 
+                updated == null ? null : updated.getResult().getKey(),
+                userMod,
+                resourceName);
     }
 
     /**



Mime
View raw message