You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2012/03/07 15:57:57 UTC

svn commit: r1297984 - in /incubator/syncope/trunk/core/src/main/java/org/syncope/core: rest/controller/ConfigurationController.java rest/controller/TaskController.java rest/data/ReportDataBinder.java util/SpringPersistenceUnitPostProcessor.java

Author: ilgrosso
Date: Wed Mar  7 14:57:57 2012
New Revision: 1297984

URL: http://svn.apache.org/viewvc?rev=1297984&view=rev
Log:
[SYNCOPE-27] Using Spring's ClassUtils.getAllInterfacesForClassAsSet() in order to get all interfaces implemented, including ones implemented by superclasses

Modified:
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/ConfigurationController.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/TaskController.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/ReportDataBinder.java
    incubator/syncope/trunk/core/src/main/java/org/syncope/core/util/SpringPersistenceUnitPostProcessor.java

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/ConfigurationController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/ConfigurationController.java?rev=1297984&r1=1297983&r2=1297984&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/ConfigurationController.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/ConfigurationController.java Wed Mar  7 14:57:57 2012
@@ -19,14 +19,12 @@
 package org.syncope.core.rest.controller;
 
 import java.io.IOException;
-import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang.ArrayUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.ResourcePatternResolver;
@@ -36,6 +34,7 @@ import org.springframework.http.MediaTyp
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ClassUtils;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,7 +44,6 @@ import org.syncope.client.to.Configurati
 import org.syncope.core.persistence.beans.SyncopeConf;
 import org.syncope.core.persistence.dao.ConfDAO;
 import org.syncope.core.persistence.dao.MissingConfKeyException;
-import org.syncope.core.persistence.validation.attrvalue.AbstractValidator;
 import org.syncope.core.persistence.validation.attrvalue.Validator;
 import org.syncope.core.rest.data.ConfigurationDataBinder;
 import org.syncope.core.util.ImportExport;
@@ -67,16 +65,13 @@ public class ConfigurationController ext
     private ResourcePatternResolver resResolver;
 
     @PreAuthorize("hasRole('CONFIGURATION_CREATE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/create")
+    @RequestMapping(method = RequestMethod.POST, value = "/create")
     public ConfigurationTO create(final HttpServletResponse response,
             @RequestBody final ConfigurationTO configurationTO) {
 
-        LOG.debug("Configuration create called with parameters {}",
-                configurationTO);
+        LOG.debug("Configuration create called with parameters {}", configurationTO);
 
-        SyncopeConf conf = configurationDataBinder.createSyncopeConfiguration(
-                configurationTO);
+        SyncopeConf conf = configurationDataBinder.createSyncopeConfiguration(configurationTO);
         conf = confDAO.save(conf);
 
         response.setStatus(HttpServletResponse.SC_CREATED);
@@ -85,8 +80,7 @@ public class ConfigurationController ext
     }
 
     @PreAuthorize("hasRole('CONFIGURATION_DELETE')")
-    @RequestMapping(method = RequestMethod.DELETE,
-    value = "/delete/{key}")
+    @RequestMapping(method = RequestMethod.DELETE, value = "/delete/{key}")
     public void delete(@PathVariable("key") final String key)
             throws MissingConfKeyException {
 
@@ -95,16 +89,13 @@ public class ConfigurationController ext
     }
 
     @PreAuthorize("hasRole('CONFIGURATION_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/list")
-    public List<ConfigurationTO> list(HttpServletRequest request) {
+    @RequestMapping(method = RequestMethod.GET, value = "/list")
+    public List<ConfigurationTO> list(final HttpServletRequest request) {
         List<SyncopeConf> configurations = confDAO.findAll();
-        List<ConfigurationTO> configurationTOs =
-                new ArrayList<ConfigurationTO>(configurations.size());
+        List<ConfigurationTO> configurationTOs = new ArrayList<ConfigurationTO>(configurations.size());
 
         for (SyncopeConf configuration : configurations) {
-            configurationTOs.add(
-                    configurationDataBinder.getConfigurationTO(configuration));
+            configurationTOs.add(configurationDataBinder.getConfigurationTO(configuration));
         }
 
         return configurationTOs;
@@ -113,8 +104,7 @@ public class ConfigurationController ext
     @PreAuthorize("hasRole('CONFIGURATION_READ')")
     @RequestMapping(method = RequestMethod.GET,
     value = "/read/{key}")
-    public ConfigurationTO read(HttpServletResponse response,
-            @PathVariable("key") String key)
+    public ConfigurationTO read(final HttpServletResponse response, @PathVariable("key") final String key)
             throws MissingConfKeyException {
 
         ConfigurationTO result;
@@ -122,8 +112,7 @@ public class ConfigurationController ext
             SyncopeConf conf = confDAO.find(key);
             result = configurationDataBinder.getConfigurationTO(conf);
         } catch (MissingConfKeyException e) {
-            LOG.error("Could not find configuration key '" + key
-                    + "', returning null");
+            LOG.error("Could not find configuration key '" + key + "', returning null");
 
             result = new ConfigurationTO();
             result.setKey(key);
@@ -139,8 +128,7 @@ public class ConfigurationController ext
             @RequestBody final ConfigurationTO configurationTO)
             throws MissingConfKeyException {
 
-        SyncopeConf syncopeConfiguration =
-                confDAO.find(configurationTO.getKey());
+        SyncopeConf syncopeConfiguration = confDAO.find(configurationTO.getKey());
 
         syncopeConfiguration.setValue(configurationTO.getValue());
 
@@ -148,58 +136,43 @@ public class ConfigurationController ext
     }
 
     @PreAuthorize("hasRole('CONFIGURATION_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/validators")
+    @RequestMapping(method = RequestMethod.GET, value = "/validators")
     public ModelAndView getValidators() {
-        CachingMetadataReaderFactory cachingMetadataReaderFactory =
-                new CachingMetadataReaderFactory();
+        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
 
         Set<String> validators = new HashSet<String>();
         try {
             for (Resource resource : resResolver.getResources(
-                    "classpath:org/syncope/core/persistence/validation/"
-                    + "attrvalue/*.class")) {
+                    "classpath:org/syncope/core/persistence/validation/attrvalue/*.class")) {
+
+                ClassMetadata metadata = cachingMetadataReaderFactory.getMetadataReader(resource).getClassMetadata();
+
+                try {
+                    Set<Class> interfaces = ClassUtils.getAllInterfacesForClassAsSet(
+                            ClassUtils.forName(metadata.getClassName(), ClassUtils.getDefaultClassLoader()));
 
-                ClassMetadata metadata =
-                        cachingMetadataReaderFactory.getMetadataReader(
-                        resource).getClassMetadata();
-                if (ArrayUtils.contains(metadata.getInterfaceNames(),
-                        Validator.class.getName())
-                        || AbstractValidator.class.getName().equals(
-                        metadata.getSuperClassName())) {
-
-                    try {
-                        Class jobClass = Class.forName(metadata.getClassName());
-                        if (!Modifier.isAbstract(jobClass.getModifiers())) {
-                            validators.add(jobClass.getName());
-                        }
-                    } catch (ClassNotFoundException e) {
-                        LOG.error("Could not load class {}",
-                                metadata.getClassName(), e);
+                    if (interfaces.contains(Validator.class) && !metadata.isAbstract()) {
+                        validators.add(metadata.getClassName());
                     }
+                } catch (ClassNotFoundException e) {
+                    LOG.error("Could not load class {}", metadata.getClassName(), e);
                 }
             }
         } catch (IOException e) {
-            LOG.error("While searching for class implementing {}",
-                    Validator.class.getName(), e);
+            LOG.error("While searching for class implementing {}", Validator.class.getName(), e);
         }
 
         return new ModelAndView().addObject(validators);
     }
 
     @PreAuthorize("hasRole('CONFIGURATION_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/mailTemplates")
+    @RequestMapping(method = RequestMethod.GET, value = "/mailTemplates")
     public ModelAndView getMailTemplates() {
-        CachingMetadataReaderFactory cachingMetadataReaderFactory =
-                new CachingMetadataReaderFactory();
-
         Set<String> htmlTemplates = new HashSet<String>();
         Set<String> textTemplates = new HashSet<String>();
 
         try {
-            for (Resource resource : resResolver.getResources(
-                    "classpath:/mailTemplates/*.vm")) {
+            for (Resource resource : resResolver.getResources("classpath:/mailTemplates/*.vm")) {
 
                 String template = resource.getURL().toExternalForm();
                 if (template.endsWith(".html.vm")) {
@@ -211,13 +184,11 @@ public class ConfigurationController ext
                             template.indexOf("mailTemplates/") + 14,
                             template.indexOf(".txt.vm")));
                 } else {
-                    LOG.warn("Unexpected template found: {}, ignoring...",
-                            template);
+                    LOG.warn("Unexpected template found: {}, ignoring...", template);
                 }
             }
         } catch (IOException e) {
-            LOG.error("While searching for class implementing {}",
-                    Validator.class.getName(), e);
+            LOG.error("While searching for class implementing {}", Validator.class.getName(), e);
         }
 
         // Only templates available both as HTML and TEXT are considered
@@ -227,13 +198,11 @@ public class ConfigurationController ext
     }
 
     @PreAuthorize("hasRole('CONFIGURATION_READ')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/dbexport")
+    @RequestMapping(method = RequestMethod.GET, value = "/dbexport")
     @Transactional(readOnly = true)
     public void dbExport(final HttpServletResponse response) {
         response.setContentType(MediaType.TEXT_XML_VALUE);
-        response.setHeader("Content-Disposition",
-                "attachment; filename=content.xml");
+        response.setHeader("Content-Disposition", "attachment; filename=content.xml");
 
         try {
             importExport.export(response.getOutputStream());

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/TaskController.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/TaskController.java?rev=1297984&r1=1297983&r2=1297984&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/TaskController.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/controller/TaskController.java Wed Mar  7 14:57:57 2012
@@ -19,7 +19,6 @@
 package org.syncope.core.rest.controller;
 
 import java.io.IOException;
-import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
@@ -27,7 +26,6 @@ import java.util.List;
 import java.util.Set;
 import javassist.NotFoundException;
 import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang.ArrayUtils;
 import org.quartz.Job;
 import org.quartz.JobDataMap;
 import org.quartz.Scheduler;
@@ -41,6 +39,7 @@ import org.springframework.http.HttpStat
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.ClassUtils;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -103,21 +102,16 @@ public class TaskController extends Abst
     private ResourcePatternResolver resResolver;
 
     @PreAuthorize("hasRole('TASK_CREATE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/create/sync")
-    public TaskTO createSyncTask(final HttpServletResponse response,
-            @RequestBody final SyncTaskTO taskTO)
+    @RequestMapping(method = RequestMethod.POST, value = "/create/sync")
+    public TaskTO createSyncTask(final HttpServletResponse response, @RequestBody final SyncTaskTO taskTO)
             throws NotFoundException {
 
         return createSchedTask(response, taskTO);
     }
 
     @PreAuthorize("hasRole('TASK_CREATE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/create/sched")
-    public TaskTO createSchedTask(
-            final HttpServletResponse response,
-            @RequestBody final SchedTaskTO taskTO)
+    @RequestMapping(method = RequestMethod.POST, value = "/create/sched")
+    public TaskTO createSchedTask(final HttpServletResponse response, @RequestBody final SchedTaskTO taskTO)
             throws NotFoundException {
 
         LOG.debug("Creating task " + taskTO);
@@ -128,17 +122,13 @@ public class TaskController extends Abst
         task = taskDAO.save(task);
 
         try {
-            jobInstanceLoader.registerJob(task, task.getJobClassName(),
-                    task.getCronExpression());
+            jobInstanceLoader.registerJob(task, task.getJobClassName(), task.getCronExpression());
         } catch (Exception e) {
-            LOG.error("While registering quartz job for task "
-                    + task.getId(), e);
+            LOG.error("While registering quartz job for task " + task.getId(), e);
 
             SyncopeClientCompositeErrorException scce =
-                    new SyncopeClientCompositeErrorException(
-                    HttpStatus.BAD_REQUEST);
-            SyncopeClientException sce = new SyncopeClientException(
-                    SyncopeClientExceptionType.Scheduling);
+                    new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+            SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
             sce.addElement(e.getMessage());
             scce.addException(sce);
             throw scce;
@@ -149,8 +139,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_UPDATE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/update/sync")
+    @RequestMapping(method = RequestMethod.POST, value = "/update/sync")
     public TaskTO updateSync(@RequestBody final SyncTaskTO taskTO)
             throws NotFoundException {
 
@@ -158,8 +147,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_UPDATE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/update/sched")
+    @RequestMapping(method = RequestMethod.POST, value = "/update/sched")
     public TaskTO updateSched(@RequestBody final SchedTaskTO taskTO)
             throws NotFoundException {
 
@@ -167,28 +155,22 @@ public class TaskController extends Abst
 
         SchedTask task = taskDAO.find(taskTO.getId());
         if (task == null) {
-            throw new NotFoundException(
-                    "Task " + String.valueOf(taskTO.getId()));
+            throw new NotFoundException("Task " + String.valueOf(taskTO.getId()));
         }
 
         TaskUtil taskUtil = getTaskUtil(task);
 
-        SyncopeClientCompositeErrorException scce =
-                new SyncopeClientCompositeErrorException(
-                HttpStatus.BAD_REQUEST);
+        SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
         binder.updateSchedTask(task, taskTO, taskUtil);
         task = taskDAO.save(task);
 
         try {
-            jobInstanceLoader.registerJob(task, task.getJobClassName(),
-                    task.getCronExpression());
+            jobInstanceLoader.registerJob(task, task.getJobClassName(), task.getCronExpression());
         } catch (Exception e) {
-            LOG.error("While registering quartz job for task "
-                    + task.getId(), e);
+            LOG.error("While registering quartz job for task " + task.getId(), e);
 
-            SyncopeClientException sce = new SyncopeClientException(
-                    SyncopeClientExceptionType.Scheduling);
+            SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
             sce.addElement(e.getMessage());
             scce.addException(sce);
             throw scce;
@@ -198,16 +180,13 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/{kind}/count")
+    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/count")
     public ModelAndView count(@PathVariable("kind") final String kind) {
-        return new ModelAndView().addObject(
-                taskDAO.count(getTaskUtil(kind).taskClass()));
+        return new ModelAndView().addObject(taskDAO.count(getTaskUtil(kind).taskClass()));
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/{kind}/list")
+    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list")
     public List<TaskTO> list(@PathVariable("kind") final String kind) {
         TaskUtil taskUtil = getTaskUtil(kind);
 
@@ -221,8 +200,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/{kind}/list/{page}/{size}")
+    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/list/{page}/{size}")
     public List<TaskTO> list(
             @PathVariable("kind") final String kind,
             @PathVariable("page") final int page,
@@ -242,13 +220,10 @@ public class TaskController extends Abst
     @PreAuthorize("hasRole('TASK_LIST')")
     @RequestMapping(method = RequestMethod.GET,
     value = "/{kind}/execution/list")
-    public List<TaskExecTO> listExecutions(
-            @PathVariable("kind") final String kind) {
+    public List<TaskExecTO> listExecutions(@PathVariable("kind") final String kind) {
 
-        List<TaskExec> executions = taskExecDAO.findAll(
-                getTaskUtil(kind).taskClass());
-        List<TaskExecTO> executionTOs =
-                new ArrayList<TaskExecTO>(executions.size());
+        List<TaskExec> executions = taskExecDAO.findAll(getTaskUtil(kind).taskClass());
+        List<TaskExecTO> executionTOs = new ArrayList<TaskExecTO>(executions.size());
         for (TaskExec execution : executions) {
             executionTOs.add(binder.getTaskExecTO(execution));
         }
@@ -257,46 +232,34 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/jobClasses")
+    @RequestMapping(method = RequestMethod.GET, value = "/jobClasses")
     public ModelAndView getJobClasses() {
-        CachingMetadataReaderFactory cachingMetadataReaderFactory =
-                new CachingMetadataReaderFactory();
+        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
 
         Set<String> jobClasses = new HashSet<String>();
         try {
-            for (Resource resource : resResolver.getResources(
-                    "classpath*:**/*.class")) {
+            for (Resource resource : resResolver.getResources("classpath*:**/*.class")) {
+
+                ClassMetadata metadata = cachingMetadataReaderFactory.getMetadataReader(resource).getClassMetadata();
+
+                try {
+                    Set<Class> interfaces = ClassUtils.getAllInterfacesForClassAsSet(
+                            ClassUtils.forName(metadata.getClassName(), ClassUtils.getDefaultClassLoader()));
+
+                    if ((interfaces.contains(Job.class) || interfaces.contains(StatefulJob.class))
+                            && !metadata.isAbstract()
+                            && !SyncJob.class.getName().equals(metadata.getClassName())
+                            && !ReportJob.class.getName().equals(metadata.getClassName())
+                            && !NotificationJob.class.getName().equals(metadata.getClassName())) {
 
-                ClassMetadata metadata =
-                        cachingMetadataReaderFactory.getMetadataReader(
-                        resource).getClassMetadata();
-                if (ArrayUtils.contains(metadata.getInterfaceNames(),
-                        Job.class.getName())
-                        || AbstractTaskJob.class.getName().equals(
-                        metadata.getSuperClassName())
-                        || ArrayUtils.contains(metadata.getInterfaceNames(),
-                        StatefulJob.class.getName())) {
-
-                    try {
-                        Class jobClass = Class.forName(metadata.getClassName());
-                        if (!Modifier.isAbstract(jobClass.getModifiers())
-                                && !metadata.hasEnclosingClass()
-                                && !jobClass.equals(SyncJob.class)
-                                && !jobClass.equals(ReportJob.class)
-                                && !jobClass.equals(NotificationJob.class)) {
-
-                            jobClasses.add(jobClass.getName());
-                        }
-                    } catch (ClassNotFoundException e) {
-                        LOG.error("Could not load class {}",
-                                metadata.getClassName(), e);
+                        jobClasses.add(metadata.getClassName());
                     }
+                } catch (ClassNotFoundException e) {
+                    LOG.error("Could not load class {}", metadata.getClassName(), e);
                 }
             }
         } catch (IOException e) {
-            LOG.error("While searching for class implementing {}",
-                    Job.class.getName(), e);
+            LOG.error("While searching for class implementing {}", Job.class.getName(), e);
         }
 
         ModelAndView result = new ModelAndView();
@@ -305,37 +268,28 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/jobActionsClasses")
+    @RequestMapping(method = RequestMethod.GET, value = "/jobActionsClasses")
     public ModelAndView getJobActionClasses() {
-        CachingMetadataReaderFactory cachingMetadataReaderFactory =
-                new CachingMetadataReaderFactory();
+        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
 
         Set<String> jobActionsClasses = new HashSet<String>();
         try {
-            for (Resource resource : resResolver.getResources(
-                    "classpath*:**/*.class")) {
+            for (Resource resource : resResolver.getResources("classpath*:**/*.class")) {
+                ClassMetadata metadata = cachingMetadataReaderFactory.getMetadataReader(resource).getClassMetadata();
+
+                try {
+                    Set<Class> interfaces = ClassUtils.getAllInterfacesForClassAsSet(
+                            ClassUtils.forName(metadata.getClassName(), ClassUtils.getDefaultClassLoader()));
 
-                ClassMetadata metadata =
-                        cachingMetadataReaderFactory.getMetadataReader(
-                        resource).getClassMetadata();
-                if (ArrayUtils.contains(metadata.getInterfaceNames(),
-                        SyncJobActions.class.getName())) {
-
-                    try {
-                        Class jobClass = Class.forName(metadata.getClassName());
-                        if (!Modifier.isAbstract(jobClass.getModifiers())) {
-                            jobActionsClasses.add(jobClass.getName());
-                        }
-                    } catch (ClassNotFoundException e) {
-                        LOG.error("Could not load class {}",
-                                metadata.getClassName(), e);
+                    if (interfaces.contains(SyncJobActions.class) && !metadata.isAbstract()) {
+                        jobActionsClasses.add(metadata.getClassName());
                     }
+                } catch (ClassNotFoundException e) {
+                    LOG.error("Could not load class {}", metadata.getClassName(), e);
                 }
             }
         } catch (IOException e) {
-            LOG.error("While searching for class implementing {}",
-                    SyncJobActions.class.getName(), e);
+            LOG.error("While searching for class implementing {}", SyncJobActions.class.getName(), e);
         }
 
         ModelAndView result = new ModelAndView();
@@ -344,8 +298,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_READ')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/read/{taskId}")
+    @RequestMapping(method = RequestMethod.GET, value = "/read/{taskId}")
     public TaskTO read(@PathVariable("taskId") final Long taskId)
             throws NotFoundException {
 
@@ -358,8 +311,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_READ')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/execution/read/{executionId}")
+    @RequestMapping(method = RequestMethod.GET, value = "/execution/read/{executionId}")
     public TaskExecTO readExecution(
             @PathVariable("executionId") final Long executionId)
             throws NotFoundException {
@@ -373,8 +325,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_EXECUTE')")
-    @RequestMapping(method = RequestMethod.POST,
-    value = "/execute/{taskId}")
+    @RequestMapping(method = RequestMethod.POST, value = "/execute/{taskId}")
     public TaskExecTO execute(@PathVariable("taskId") final Long taskId,
             @RequestParam(value = "dryRun", defaultValue = "false") final boolean dryRun)
             throws NotFoundException {
@@ -388,14 +339,12 @@ public class TaskController extends Abst
         LOG.debug("Execution started for {}", task);
         switch (getTaskUtil(task)) {
             case PROPAGATION:
-                final TaskExec propExec = propagationManager.execute(
-                        (PropagationTask) task);
+                final TaskExec propExec = propagationManager.execute((PropagationTask) task);
                 result = binder.getTaskExecTO(propExec);
                 break;
 
             case NOTIFICATION:
-                final TaskExec notExec = notificationManager.execute(
-                        (NotificationTask) task);
+                final TaskExec notExec = notificationManager.execute((NotificationTask) task);
                 result = binder.getTaskExecTO(notExec);
                 break;
 
@@ -415,10 +364,8 @@ public class TaskController extends Abst
                     LOG.error("While executing task {}", task, e);
 
                     SyncopeClientCompositeErrorException scce =
-                            new SyncopeClientCompositeErrorException(
-                            HttpStatus.BAD_REQUEST);
-                    SyncopeClientException sce = new SyncopeClientException(
-                            SyncopeClientExceptionType.Scheduling);
+                            new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+                    SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.Scheduling);
                     sce.addElement(e.getMessage());
                     scce.addException(sce);
                     throw scce;
@@ -439,12 +386,10 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_READ')")
-    @RequestMapping(method = RequestMethod.GET,
-    value = "/execution/report/{executionId}")
+    @RequestMapping(method = RequestMethod.GET, value = "/execution/report/{executionId}")
     public TaskExecTO report(
             @PathVariable("executionId") final Long executionId,
-            @RequestParam("executionStatus")
-            final PropagationTaskExecStatus status,
+            @RequestParam("executionStatus") final PropagationTaskExecStatus status,
             @RequestParam("message") final String message)
             throws NotFoundException, SyncopeClientCompositeErrorException {
 
@@ -454,8 +399,7 @@ public class TaskController extends Abst
         }
 
         SyncopeClientException invalidReportException =
-                new SyncopeClientException(
-                SyncopeClientExceptionType.InvalidPropagationTaskExecReport);
+                new SyncopeClientException(SyncopeClientExceptionType.InvalidPropagationTaskExecReport);
 
         TaskUtil taskUtil = getTaskUtil(exec.getTask());
         if (taskUtil != TaskUtil.PROPAGATION) {
@@ -463,8 +407,7 @@ public class TaskController extends Abst
         } else {
             PropagationTask task = (PropagationTask) exec.getTask();
             if (task.getPropagationMode() != PropagationMode.TWO_PHASES) {
-                invalidReportException.addElement(
-                        "Propagation mode: " + task.getPropagationMode());
+                invalidReportException.addElement("Propagation mode: " + task.getPropagationMode());
             }
         }
 
@@ -476,8 +419,7 @@ public class TaskController extends Abst
             case CREATED:
             case SUBMITTED:
             case UNSUBMITTED:
-                invalidReportException.addElement(
-                        "Execution status to be set: " + status);
+                invalidReportException.addElement("Execution status to be set: " + status);
                 break;
 
             default:
@@ -485,8 +427,7 @@ public class TaskController extends Abst
 
         if (!invalidReportException.isEmpty()) {
             SyncopeClientCompositeErrorException scce =
-                    new SyncopeClientCompositeErrorException(
-                    HttpStatus.BAD_REQUEST);
+                    new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
             scce.addException(invalidReportException);
             throw scce;
         }
@@ -499,8 +440,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_DELETE')")
-    @RequestMapping(method = RequestMethod.DELETE,
-    value = "/delete/{taskId}")
+    @RequestMapping(method = RequestMethod.DELETE, value = "/delete/{taskId}")
     public void delete(@PathVariable("taskId") Long taskId)
             throws NotFoundException, SyncopeClientCompositeErrorException {
 
@@ -509,9 +449,7 @@ public class TaskController extends Abst
             throw new NotFoundException("Task " + taskId);
         }
 
-        if (TaskUtil.SCHED == getTaskUtil(task)
-                || TaskUtil.SYNC == getTaskUtil(task)) {
-
+        if (TaskUtil.SCHED == getTaskUtil(task) || TaskUtil.SYNC == getTaskUtil(task)) {
             jobInstanceLoader.unregisterJob(task);
         }
 
@@ -519,8 +457,7 @@ public class TaskController extends Abst
     }
 
     @PreAuthorize("hasRole('TASK_DELETE')")
-    @RequestMapping(method = RequestMethod.DELETE,
-    value = "/execution/delete/{executionId}")
+    @RequestMapping(method = RequestMethod.DELETE, value = "/execution/delete/{executionId}")
     public void deleteExecution(@PathVariable("executionId") Long executionId)
             throws NotFoundException, SyncopeClientCompositeErrorException {
 

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/ReportDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/ReportDataBinder.java?rev=1297984&r1=1297983&r2=1297984&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/ReportDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/rest/data/ReportDataBinder.java Wed Mar  7 14:57:57 2012
@@ -19,10 +19,8 @@
 package org.syncope.core.rest.data;
 
 import java.io.IOException;
-import java.lang.reflect.Modifier;
 import java.util.HashSet;
 import java.util.Set;
-import org.apache.commons.lang.ArrayUtils;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import org.quartz.Trigger;
@@ -36,6 +34,7 @@ import org.springframework.core.type.Cla
 import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ClassUtils;
 import org.syncope.client.report.ReportletConf;
 import org.syncope.client.to.ReportExecTO;
 import org.syncope.client.to.ReportTO;
@@ -43,7 +42,6 @@ import org.syncope.core.init.JobInstance
 import org.syncope.core.persistence.beans.Report;
 import org.syncope.core.persistence.beans.ReportExec;
 import org.syncope.core.persistence.dao.ReportExecDAO;
-import org.syncope.core.report.AbstractReportlet;
 import org.syncope.core.report.Reportlet;
 import org.syncope.core.report.ReportletConfClass;
 
@@ -78,17 +76,16 @@ public class ReportDataBinder {
         try {
             for (Resource resource : resResolver.getResources("classpath*:**/*.class")) {
                 ClassMetadata metadata = cachingMetadataReaderFactory.getMetadataReader(resource).getClassMetadata();
-                if (ArrayUtils.contains(metadata.getInterfaceNames(), Reportlet.class.getName())
-                        || AbstractReportlet.class.getName().equals(metadata.getSuperClassName())) {
 
-                    try {
-                        Class jobClass = Class.forName(metadata.getClassName());
-                        if (!Modifier.isAbstract(jobClass.getModifiers())) {
-                            reportletClasses.add(jobClass);
-                        }
-                    } catch (ClassNotFoundException e) {
-                        LOG.error("Could not load class {}", metadata.getClassName(), e);
+                try {
+                    Class reportletClass =
+                            ClassUtils.forName(metadata.getClassName(), ClassUtils.getDefaultClassLoader());
+                    Set<Class> interfaces = ClassUtils.getAllInterfacesForClassAsSet(reportletClass);
+                    if (interfaces.contains(Reportlet.class) && !metadata.isAbstract()) {
+                        reportletClasses.add(reportletClass);
                     }
+                } catch (ClassNotFoundException e) {
+                    LOG.error("Could not load class {}", metadata.getClassName(), e);
                 }
             }
         } catch (IOException e) {

Modified: incubator/syncope/trunk/core/src/main/java/org/syncope/core/util/SpringPersistenceUnitPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/syncope/core/util/SpringPersistenceUnitPostProcessor.java?rev=1297984&r1=1297983&r2=1297984&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/syncope/core/util/SpringPersistenceUnitPostProcessor.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/syncope/core/util/SpringPersistenceUnitPostProcessor.java Wed Mar  7 14:57:57 2012
@@ -31,10 +31,8 @@ import org.springframework.orm.jpa.persi
 import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor;
 
 /**
- * Add to JPA persistence context all beans labeled as @Entity from given
- * location.
- * This is needed only when using LocalContainerEntityManagerFactoryBean with
- * non-standard persistence.xml (currently JBoss-only).
+ * Add to JPA persistence context all beans labeled as @Entity from given location. This is needed only when using
+ * LocalContainerEntityManagerFactoryBean with non-standard persistence.xml (currently JBoss-only).
  */
 public class SpringPersistenceUnitPostProcessor
         implements PersistenceUnitPostProcessor {
@@ -42,8 +40,7 @@ public class SpringPersistenceUnitPostPr
     /**
      * Logger.
      */
-    private static final Logger LOG = LoggerFactory.getLogger(
-            SpringPersistenceUnitPostProcessor.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SpringPersistenceUnitPostProcessor.class);
 
     @Autowired
     private ResourcePatternResolver resResolver;
@@ -62,21 +59,14 @@ public class SpringPersistenceUnitPostPr
             LOG.warn("No locations provided");
         }
 
-        CachingMetadataReaderFactory cachingMetadataReaderFactory =
-                new CachingMetadataReaderFactory();
+        CachingMetadataReaderFactory cachingMetadataReaderFactory = new CachingMetadataReaderFactory();
 
         try {
             for (String location : locations) {
                 for (Resource resource : resResolver.getResources(location)) {
-                    MetadataReader metadataReader =
-                            cachingMetadataReaderFactory.getMetadataReader(
-                            resource);
-                    if (metadataReader.getAnnotationMetadata().
-                            isAnnotated(Entity.class.getName())) {
-
-                        mpui.addManagedClassName(
-                                metadataReader.getClassMetadata().
-                                getClassName());
+                    MetadataReader metadataReader = cachingMetadataReaderFactory.getMetadataReader(resource);
+                    if (metadataReader.getAnnotationMetadata().isAnnotated(Entity.class.getName())) {
+                        mpui.addManagedClassName(metadataReader.getClassMetadata().getClassName());
                     }
                 }
             }