syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1505995 [3/4] - in /syncope/trunk: ./ build-tools/ build-tools/src/main/resources/ client/src/main/java/org/apache/syncope/client/http/ client/src/main/java/org/apache/syncope/client/rest/ client/src/main/java/org/apache/syncope/client/ser...
Date Tue, 23 Jul 2013 11:52:07 GMT
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java Tue Jul 23 11:52:05 2013
@@ -40,16 +40,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.stereotype.Controller;
+import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.servlet.ModelAndView;
 
-@Controller
-@RequestMapping("/user/request")
+@Component
 public class UserRequestController {
 
     /**
@@ -69,24 +63,17 @@ public class UserRequestController {
     @Autowired
     private UserRequestDataBinder binder;
 
-    public Boolean isCreateAllowedByConf() {
+    public boolean isCreateAllowed() {
         final SyncopeConf createRequestAllowed = confDAO.find("createRequest.allowed", "false");
 
-        return Boolean.valueOf(createRequestAllowed.getValue());
-    }
-
-    @RequestMapping(method = RequestMethod.GET, value = "/create/allowed")
-    @Transactional(readOnly = true)
-    public ModelAndView isCreateAllowed() {
         auditManager.audit(Category.userRequest, UserRequestSubCategory.isCreateAllowed, Result.success,
                 "Successfully checked whether self create is allowed");
 
-        return new ModelAndView().addObject(isCreateAllowedByConf());
+        return Boolean.valueOf(createRequestAllowed.getValue());
     }
 
-    @RequestMapping(method = RequestMethod.POST, value = "/create")
-    public UserRequestTO create(@RequestBody final UserTO userTO) {
-        if (!isCreateAllowedByConf()) {
+    public UserRequestTO create(final UserTO userTO) {
+        if (!isCreateAllowed()) {
             LOG.error("Create requests are not allowed");
 
             throw new UnauthorizedRoleException(-1L);
@@ -111,8 +98,7 @@ public class UserRequestController {
     }
 
     @PreAuthorize("isAuthenticated()")
-    @RequestMapping(method = RequestMethod.POST, value = "/update")
-    public UserRequestTO update(@RequestBody final UserMod userMod) {
+    public UserRequestTO update(final UserMod userMod) {
         LOG.debug("Request user update called with {}", userMod);
 
         try {
@@ -132,7 +118,6 @@ public class UserRequestController {
     }
 
     @PreAuthorize("hasRole('USER_REQUEST_LIST')")
-    @RequestMapping(method = RequestMethod.GET, value = "/list")
     @Transactional(readOnly = true)
     public List<UserRequestTO> list() {
         List<UserRequestTO> result = new ArrayList<UserRequestTO>();
@@ -148,9 +133,8 @@ public class UserRequestController {
     }
 
     @PreAuthorize("hasRole('USER_REQUEST_READ')")
-    @RequestMapping(method = RequestMethod.GET, value = "/read/{requestId}")
     @Transactional(readOnly = true)
-    public UserRequestTO read(@PathVariable("requestId") final Long requestId) {
+    public UserRequestTO read(final Long requestId) {
         UserRequest request = userRequestDAO.find(requestId);
         if (request == null) {
             throw new NotFoundException("User request " + requestId);
@@ -163,8 +147,7 @@ public class UserRequestController {
     }
 
     @PreAuthorize("isAuthenticated()")
-    @RequestMapping(method = RequestMethod.GET, value = "/delete/{userId}")
-    public UserRequestTO delete(@PathVariable("userId") final Long userId) {
+    public UserRequestTO delete(final Long userId) {
         LOG.debug("Request user delete called with {}", userId);
 
         try {
@@ -184,8 +167,7 @@ public class UserRequestController {
     }
 
     @PreAuthorize("hasRole('USER_REQUEST_DELETE')")
-    @RequestMapping(method = RequestMethod.GET, value = "/deleteRequest/{requestId}")
-    public UserRequestTO deleteRequest(@PathVariable("requestId") final Long requestId) {
+    public UserRequestTO deleteRequest(final Long requestId) {
         UserRequest request = userRequestDAO.find(requestId);
         if (request == null) {
             throw new NotFoundException("User request " + requestId);

Added: 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=1505995&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java Tue Jul 23 11:52:05 2013
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest.controller;
+
+import java.util.AbstractMap;
+import java.util.List;
+import java.util.Map;
+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;
+import org.apache.syncope.core.propagation.impl.PropagationManager;
+import org.apache.syncope.core.rest.data.UserDataBinder;
+import org.apache.syncope.core.workflow.WorkflowResult;
+import org.apache.syncope.core.workflow.user.UserWorkflowAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+@Component
+public class UserWorkflowController extends AbstractController {
+
+    @Autowired
+    protected AuditManager auditManager;
+
+    @Autowired
+    protected UserWorkflowAdapter uwfAdapter;
+
+    @Autowired
+    protected PropagationManager propagationManager;
+
+    @Autowired
+    protected PropagationTaskExecutor taskExecutor;
+
+    @Autowired
+    protected NotificationManager notificationManager;
+
+    @Autowired
+    protected UserDataBinder binder;
+
+    @PreAuthorize("hasRole('WORKFLOW_FORM_CLAIM')")
+    @Transactional(rollbackFor = {Throwable.class})
+    public WorkflowFormTO claimForm(final String taskId) {
+        WorkflowFormTO result = 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')")
+    public UserTO executeWorkflow(final UserTO userTO, final String taskId) {
+        LOG.debug("About to execute {} on {}", taskId, userTO.getId());
+
+        WorkflowResult<Long> updated = uwfAdapter.execute(userTO, taskId);
+
+        List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
+                new WorkflowResult<Map.Entry<Long, Boolean>>(
+                new AbstractMap.SimpleEntry<Long, Boolean>(updated.getResult(), 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})
+    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;
+    }
+
+    @PreAuthorize("hasRole('WORKFLOW_FORM_LIST')")
+    @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;
+    }
+
+    @PreAuthorize("hasRole('WORKFLOW_FORM_SUBMIT')")
+    @Transactional(rollbackFor = {Throwable.class})
+    public UserTO submitForm(final WorkflowFormTO form) {
+        LOG.debug("About to process form {}", form);
+
+        WorkflowResult<Map.Entry<Long, String>> updated = uwfAdapter.submitForm(form,
+                SecurityContextHolder.getContext().getAuthentication().getName());
+
+        // propByRes can be made empty by the workflow definition is no propagation should occur 
+        // (for example, with rejected users)
+        if (updated.getPropByRes() != null && !updated.getPropByRes().isEmpty()) {
+            List<PropagationTask> tasks = propagationManager.getUserUpdateTaskIds(
+                    new WorkflowResult<Map.Entry<Long, Boolean>>(
+                    new AbstractMap.SimpleEntry<Long, Boolean>(updated.getResult().getKey(), Boolean.TRUE),
+                    updated.getPropByRes(),
+                    updated.getPerformedTasks()),
+                    updated.getResult().getValue(),
+                    null,
+                    null,
+                    null);
+            taskExecutor.execute(tasks);
+        }
+
+        final UserTO savedTO = binder.getUserTO(updated.getResult().getKey());
+
+        auditManager.audit(AuditElements.Category.user, AuditElements.UserSubCategory.submitForm,
+                AuditElements.Result.success,
+                "Successfully submitted workflow form for user: " + savedTO.getUsername());
+
+        LOG.debug("About to return user after form processing\n{}", savedTO);
+
+        return savedTO;
+    }
+}

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserWorkflowController.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1505995&r1=1505994&r2=1505995&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 Tue Jul 23 11:52:05 2013
@@ -31,15 +31,11 @@ import org.apache.syncope.core.workflow.
 import org.apache.syncope.core.workflow.user.UserWorkflowAdapter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.stereotype.Controller;
+import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.servlet.ModelAndView;
 
-@Controller
-@RequestMapping("/workflow")
+@Component
 public class WorkflowController extends AbstractController {
 
     @Autowired
@@ -61,14 +57,12 @@ public class WorkflowController extends 
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_READ')")
-    @RequestMapping(method = RequestMethod.GET, value = "/definition/user")
     @Transactional(readOnly = true)
     public WorkflowDefinitionTO getUserDefinition() throws WorkflowException {
         return getDefinition(uwfAdapter);
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_READ')")
-    @RequestMapping(method = RequestMethod.GET, value = "/definition/role")
     @Transactional(readOnly = true)
     public WorkflowDefinitionTO getRoleDefinition() throws WorkflowException {
         return getDefinition(rwfAdapter);
@@ -82,13 +76,11 @@ public class WorkflowController extends 
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_UPDATE')")
-    @RequestMapping(method = RequestMethod.PUT, value = "/definition/user")
     public void updateUserDefinition(@RequestBody final WorkflowDefinitionTO definition) {
         updateDefinition(uwfAdapter, definition);
     }
 
     @PreAuthorize("hasRole('WORKFLOW_DEF_UPDATE')")
-    @RequestMapping(method = RequestMethod.PUT, value = "/definition/role")
     public void updateRoleDefinition(@RequestBody final WorkflowDefinitionTO definition) {
         updateDefinition(rwfAdapter, definition);
     }
@@ -103,14 +95,12 @@ public class WorkflowController extends 
     }
 
     @PreAuthorize("hasRole('WORKFLOW_TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET, value = "/tasks/user")
-    public ModelAndView getDefinedUserTasks() {
-        return new ModelAndView().addObject(getDefinedTasks(uwfAdapter));
+    public List<String> getDefinedUserTasks() {
+        return getDefinedTasks(uwfAdapter);
     }
 
     @PreAuthorize("hasRole('WORKFLOW_TASK_LIST')")
-    @RequestMapping(method = RequestMethod.GET, value = "/tasks/role")
-    public ModelAndView getDefinedRoleTasks() {
-        return new ModelAndView().addObject(getDefinedTasks(rwfAdapter));
+    public List<String> getDefinedRoleTasks() {
+        return getDefinedTasks(rwfAdapter);
     }
 }

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=1505995&r1=1505994&r2=1505995&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 Tue Jul 23 11:52:05 2013
@@ -19,13 +19,16 @@
 package org.apache.syncope.core.rest.data;
 
 import java.util.List;
+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.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.common.validation.SyncopeClientException;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
 import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
 import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
 import org.apache.syncope.core.persistence.dao.SchemaDAO;
 import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.JexlUtil;
@@ -43,7 +46,8 @@ public class SchemaDataBinder {
     @Autowired
     private JexlUtil jexlUtil;
 
-    private <T extends AbstractDerSchema> void populate(final AbstractSchema schema, final SchemaTO schemaTO) {
+    // --------------- NORMAL -----------------
+    private <T extends AbstractSchema> void fill(final T schema, final SchemaTO schemaTO) {
         if (!jexlUtil.isExpressionValid(schemaTO.getMandatoryCondition())) {
             SyncopeClientCompositeErrorException scce =
                     new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
@@ -59,11 +63,13 @@ public class SchemaDataBinder {
         BeanUtils.copyProperties(schemaTO, schema);
     }
 
-    public void create(final SchemaTO schemaTO, final AbstractSchema schema) {
-        populate(schema, schemaTO);
+    public <T extends AbstractSchema> void create(final SchemaTO schemaTO, final T schema) {
+        fill(schema, schemaTO);
     }
 
-    public void update(final SchemaTO schemaTO, final AbstractSchema schema, final AttributableUtil attributableUtil) {
+    public <T extends AbstractSchema> void update(final SchemaTO schemaTO, final T schema,
+            final AttributableUtil attributableUtil) {
+
         SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
         List<AbstractAttr> attrs = schemaDAO.getAttributes(schema, attributableUtil.attrClass());
@@ -88,7 +94,7 @@ public class SchemaDataBinder {
             throw scce;
         }
 
-        populate(schema, schemaTO);
+        fill(schema, schemaTO);
     }
 
     public <T extends AbstractSchema> SchemaTO getSchemaTO(final T schema, final AttributableUtil attributableUtil) {
@@ -97,4 +103,70 @@ public class SchemaDataBinder {
 
         return schemaTO;
     }
+
+    // --------------- DERIVED -----------------
+    private <T extends AbstractDerSchema> T populate(final T derSchema, final DerSchemaTO derSchemaTO) {
+        SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
+
+        if (derSchemaTO.getExpression() == null) {
+            SyncopeClientException requiredValuesMissing = new SyncopeClientException(
+                    SyncopeClientExceptionType.RequiredValuesMissing);
+            requiredValuesMissing.addElement("expression");
+
+            scce.addException(requiredValuesMissing);
+        }
+
+        if (!jexlUtil.isExpressionValid(derSchemaTO.getExpression())) {
+            SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(
+                    SyncopeClientExceptionType.InvalidValues);
+            invalidMandatoryCondition.addElement(derSchemaTO.getExpression());
+
+            scce.addException(invalidMandatoryCondition);
+        }
+
+        if (scce.hasExceptions()) {
+            throw scce;
+        }
+
+        BeanUtils.copyProperties(derSchemaTO, derSchema);
+
+        return derSchema;
+    }
+
+    public <T extends AbstractDerSchema> T create(final DerSchemaTO derSchemaTO, final T derSchema) {
+        return populate(derSchema, derSchemaTO);
+    }
+
+    public <T extends AbstractDerSchema> T update(final DerSchemaTO derSchemaTO, final T derSchema) {
+        return populate(derSchema, derSchemaTO);
+    }
+
+    public <T extends AbstractDerSchema> DerSchemaTO getDerSchemaTO(final T derSchema) {
+        DerSchemaTO derSchemaTO = new DerSchemaTO();
+        BeanUtils.copyProperties(derSchema, derSchemaTO);
+
+        return derSchemaTO;
+    }
+
+    // --------------- VIRTUAL -----------------
+    private <T extends AbstractVirSchema> T fill(final T virSchema, final VirSchemaTO virSchemaTO) {
+        BeanUtils.copyProperties(virSchemaTO, virSchema);
+
+        return virSchema;
+    }
+
+    public <T extends AbstractVirSchema> T create(final VirSchemaTO virSchemaTO, final T virSchema) {
+        return fill(virSchema, virSchemaTO);
+    }
+
+    public <T extends AbstractVirSchema> T update(final VirSchemaTO virSchemaTO, final T virSchema) {
+        return fill(virSchema, virSchemaTO);
+    }
+
+    public <T extends AbstractVirSchema> VirSchemaTO getVirSchemaTO(final T virSchema) {
+        VirSchemaTO virtualSchemaTO = new VirSchemaTO();
+        BeanUtils.copyProperties(virSchema, virtualSchemaTO);
+
+        return virtualSchemaTO;
+    }
 }

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=1505995&r1=1505994&r2=1505995&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 Tue Jul 23 11:52:05 2013
@@ -29,6 +29,7 @@ import org.apache.syncope.common.to.Task
 import org.apache.syncope.common.to.TaskTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.types.TaskType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.common.validation.SyncopeClientException;
 import org.apache.syncope.core.init.JobInstanceLoader;
@@ -149,10 +150,10 @@ public class TaskDataBinder {
         task.setName(taskTO.getName());
         task.setDescription(taskTO.getDescription());
 
-        if (taskUtil == TaskUtil.SCHED) {
+        if (taskUtil.getType() == TaskType.SCHEDULED) {
             task.setJobClassName(taskTO.getJobClassName());
         }
-        if (taskUtil == TaskUtil.SYNC) {
+        if (taskUtil.getType() == TaskType.SYNCHRONIZATION) {
             if (!(taskTO instanceof SyncTaskTO)) {
                 throw new ClassCastException("taskUtil is type SyncTask but taskTO is not SyncTaskTO: " + taskTO.
                         getClass().getName());
@@ -180,7 +181,7 @@ public class TaskDataBinder {
             task.setDescription(taskTO.getDescription());
         }
 
-        if (taskUtil == TaskUtil.SYNC) {
+        if (taskUtil.getType() == TaskType.SYNCHRONIZATION) {
             if (!(task instanceof SyncTask)) {
                 throw new ClassCastException("taskUtil is type SyncTask but task is not SyncTask: " + task.getClass().
                         getName());
@@ -246,7 +247,7 @@ public class TaskDataBinder {
             taskTO.addExecution(getTaskExecTO(execution));
         }
 
-        switch (taskUtil) {
+        switch (taskUtil.getType()) {
             case PROPAGATION:
                 if (!(task instanceof PropagationTask)) {
                     throw new ClassCastException("taskUtil is type Propagation but task is not PropagationTask: "
@@ -254,7 +255,7 @@ public class TaskDataBinder {
                 }
                 break;
 
-            case SCHED:
+            case SCHEDULED:
                 if (!(task instanceof SchedTask)) {
                     throw new ClassCastException("taskUtil is type Sched but task is not SchedTask: "
                             + task.getClass().getName());
@@ -264,7 +265,7 @@ public class TaskDataBinder {
                 ((SchedTaskTO) taskTO).setDescription(((SchedTask) task).getDescription());
                 break;
 
-            case SYNC:
+            case SYNCHRONIZATION:
                 if (!(task instanceof SyncTask)) {
                     throw new ClassCastException("taskUtil is type Sync but task is not SyncTask: "
                             + task.getClass().getName());

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=1505995&r1=1505994&r2=1505995&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 Tue Jul 23 11:52:05 2013
@@ -53,7 +53,6 @@ import org.apache.syncope.core.propagati
 import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
 import org.apache.syncope.core.util.AttributableUtil;
 import org.apache.syncope.core.util.EntitlementUtil;
-import org.apache.syncope.core.util.MappingUtil;
 import org.apache.syncope.core.util.PasswordEncoder;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/utils/RestServiceExceptionMapper.java Tue Jul 23 11:52:05 2013
@@ -33,7 +33,6 @@ import org.apache.syncope.common.service
 import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
-import org.apache.syncope.common.validation.SyncopeClientErrorHandler;
 import org.apache.syncope.common.validation.SyncopeClientException;
 import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
 import org.apache.syncope.core.persistence.dao.NotFoundException;
@@ -54,8 +53,6 @@ public class RestServiceExceptionMapper 
 
     private static final Logger LOG = LoggerFactory.getLogger(RestServiceExceptionMapper.class);
 
-    public static final String EXCEPTION_TYPE_HEADER = "ExceptionType";
-
     @Override
     public Response toResponse(final Exception ex) {
         LOG.error("Exception thrown by REST method: " + ex.getMessage(), ex);
@@ -118,7 +115,8 @@ public class RestServiceExceptionMapper 
     private Response getCompositeExceptionResponse(final SyncopeClientCompositeErrorException ex) {
         ResponseBuilder responseBuilder = Response.status(ex.getStatusCode().value());
         for (SyncopeClientException sce : ex.getExceptions()) {
-            responseBuilder.header(EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
+            responseBuilder.header(
+                    SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
 
             for (String attributeName : sce.getElements()) {
                 responseBuilder.header(sce.getType().getElementHeaderName(), attributeName);
@@ -172,9 +170,10 @@ public class RestServiceExceptionMapper 
             SyncopeClientExceptionType exType = SyncopeClientExceptionType.valueOf("Invalid"
                     + ((InvalidEntityException) ex).getEntityClassSimpleName());
 
-            responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
+            responseBuilder.header(
+                    SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
 
-            for (@SuppressWarnings("rawtypes") Map.Entry<Class, Set<EntityViolationType>> violation
+            for (Map.Entry<Class<?>, Set<EntityViolationType>> violation
                     : ((InvalidEntityException) ex).getViolations().entrySet()) {
 
                 for (EntityViolationType violationType : violation.getValue()) {
@@ -197,7 +196,8 @@ public class RestServiceExceptionMapper 
     private Response buildResponse(final ResponseBuilder responseBuilder, final SyncopeClientExceptionType hType,
             final String msg) {
 
-        return responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
+        return responseBuilder.header(
+                SyncopeClientCompositeErrorException.EXCEPTION_TYPE_HEADER, hType.getHeaderValue()).
                 header(hType.getElementHeaderName(), msg).
                 build();
     }

Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java?rev=1505995&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services;
+
+import javax.ws.rs.core.UriInfo;
+
+abstract class AbstractServiceImpl implements ContextAware {
+
+    protected UriInfo uriInfo;
+
+    @Override
+    public void setUriInfo(final UriInfo uriInfo) {
+        this.uriInfo = uriInfo;
+    }
+}

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/AbstractServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -27,7 +27,6 @@ import java.util.Set;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ConfigurationService;
@@ -41,16 +40,14 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class ConfigurationServiceImpl implements ConfigurationService, ContextAware {
+public class ConfigurationServiceImpl extends AbstractServiceImpl implements ConfigurationService, ContextAware {
 
     @Autowired
-    private ConfigurationController configurationController;
-
-    private UriInfo uriInfo;
+    private ConfigurationController controller;
 
     @Override
     public Response create(final ConfigurationTO configurationTO) {
-        ConfigurationTO created = configurationController.create(new DummyHTTPServletResponse(), configurationTO);
+        ConfigurationTO created = controller.create(configurationTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
         return Response.created(location).
                 header(SyncopeConstants.REST_HEADER_ID, created.getKey()).
@@ -58,12 +55,12 @@ public class ConfigurationServiceImpl im
     }
 
     @Override
-    public Response dbExport() {
+    public Response export() {
         StreamingOutput sout = new StreamingOutput() {
 
             @Override
             public void write(final OutputStream os) throws IOException {
-                configurationController.dbExportInternal(os);
+                controller.export(os);
             }
         };
         return Response.ok(sout)
@@ -75,41 +72,34 @@ public class ConfigurationServiceImpl im
 
     @Override
     public void delete(final String key) {
-        configurationController.delete(key);
+        controller.delete(key);
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public Set<MailTemplateTO> getMailTemplates() {
-        return CollectionWrapper.wrapMailTemplates(
-                (Set<String>) configurationController.getMailTemplates().getModel().values().iterator().next());
+        return CollectionWrapper.wrapMailTemplates(controller.getMailTemplates());
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public Set<ValidatorTO> getValidators() {
-        return CollectionWrapper.wrapValidators(
-                (Set<String>) configurationController.getValidators().getModel().values().iterator().next());
+        return CollectionWrapper.wrapValidators(controller.getValidators());
     }
 
     @Override
     public List<ConfigurationTO> list() {
-        return configurationController.list(null);
+        return controller.list();
     }
 
     @Override
     public ConfigurationTO read(final String key) {
-        return configurationController.read(null, key);
+        return controller.read(key);
 
     }
 
     @Override
     public void update(final String key, final ConfigurationTO configurationTO) {
-        configurationController.update(configurationTO);
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        controller.update(configurationTO);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -22,7 +22,6 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ConnectorService;
 import org.apache.syncope.common.to.BulkAction;
@@ -32,45 +31,43 @@ import org.apache.syncope.common.to.Conn
 import org.apache.syncope.common.to.ConnInstanceTO;
 import org.apache.syncope.common.to.SchemaTO;
 import org.apache.syncope.common.types.ConnConfProperty;
-import org.apache.syncope.core.rest.controller.ConnInstanceController;
+import org.apache.syncope.core.rest.controller.ConnectorController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class ConnectorServiceImpl implements ConnectorService, ContextAware {
+public class ConnectorServiceImpl extends AbstractServiceImpl implements ConnectorService, ContextAware {
 
     @Autowired
-    private ConnInstanceController connInstanceController;
-
-    private UriInfo uriInfo;
+    private ConnectorController controller;
 
     @Override
     public Response create(final ConnInstanceTO connInstanceTO) {
-        ConnInstanceTO connInstance = connInstanceController.create(new DummyHTTPServletResponse(), connInstanceTO);
+        ConnInstanceTO connInstance = controller.create(connInstanceTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(connInstance.getId() + "").build();
         return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, connInstance.getId()).build();
     }
 
     @Override
     public void delete(final Long connInstanceId) {
-        connInstanceController.delete(connInstanceId);
+        controller.delete(connInstanceId);
     }
 
     @Override
     public List<ConnBundleTO> getBundles(final String lang) {
-        return connInstanceController.getBundles(lang);
+        return controller.getBundles(lang);
     }
 
     @Override
     public List<ConnConfProperty> getConfigurationProperties(final Long connInstanceId) {
-        return connInstanceController.getConfigurationProperties(connInstanceId);
+        return controller.getConfigurationProperties(connInstanceId);
     }
 
     @Override
     public List<SchemaTO> getSchemaNames(final Long connInstanceId, final ConnInstanceTO connInstanceTO,
             final boolean includeSpecial) {
 
-        List<String> schemaNames = connInstanceController.getSchemaNames(connInstanceTO, includeSpecial);
+        List<String> schemaNames = controller.getSchemaNames(connInstanceTO, includeSpecial);
         List<SchemaTO> result = new ArrayList<SchemaTO>(schemaNames.size());
         for (String name : schemaNames) {
             SchemaTO schemaTO = new SchemaTO();
@@ -84,7 +81,7 @@ public class ConnectorServiceImpl implem
     public List<ConnIdObjectClassTO> getSupportedObjectClasses(final Long connInstanceId,
             final ConnInstanceTO connInstanceTO) {
 
-        List<String> objectClasses = connInstanceController.getSupportedObjectClasses(connInstanceTO);
+        List<String> objectClasses = controller.getSupportedObjectClasses(connInstanceTO);
         List<ConnIdObjectClassTO> result = new ArrayList<ConnIdObjectClassTO>(objectClasses.size());
         for (String objectClass : objectClasses) {
             result.add(new ConnIdObjectClassTO(objectClass));
@@ -94,41 +91,36 @@ public class ConnectorServiceImpl implem
 
     @Override
     public List<ConnInstanceTO> list(final String lang) {
-        return connInstanceController.list(lang);
+        return controller.list(lang);
     }
 
     @Override
     public ConnInstanceTO read(final Long connInstanceId) {
-        return connInstanceController.read(connInstanceId);
+        return controller.read(connInstanceId);
     }
 
     @Override
     public ConnInstanceTO readByResource(final String resourceName) {
-        return connInstanceController.readByResource(resourceName);
+        return controller.readByResource(resourceName);
     }
 
     @Override
     public void update(final Long connInstanceId, final ConnInstanceTO connInstanceTO) {
-        connInstanceController.update(connInstanceTO);
+        controller.update(connInstanceTO);
     }
 
     @Override
     public boolean check(final ConnInstanceTO connInstanceTO) {
-        return (Boolean) connInstanceController.check(connInstanceTO).getModel().values().iterator().next();
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        return controller.check(connInstanceTO);
     }
 
     @Override
     public void reload() {
-        connInstanceController.reload();
+        controller.reload();
     }
 
     @Override
     public BulkActionRes bulkAction(final BulkAction bulkAction) {
-        return connInstanceController.bulkAction(bulkAction);
+        return controller.bulkAction(bulkAction);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java Tue Jul 23 11:52:05 2013
@@ -21,11 +21,8 @@ package org.apache.syncope.core.services
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.UriInfo;
 
-/**
- * While @Context can also be set on fields this variant is needed to make it compatible with spring proxies
- */
 public interface ContextAware {
 
     @Context
-    void setUriInfo(UriInfo ui);
+    void setUriInfo(UriInfo uriInfo);
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -24,25 +24,25 @@ import java.util.Set;
 import org.apache.syncope.common.services.EntitlementService;
 import org.apache.syncope.common.to.EntitlementTO;
 import org.apache.syncope.common.util.CollectionWrapper;
-import org.apache.syncope.core.rest.controller.AuthenticationController;
+import org.apache.syncope.core.rest.controller.EntitlementController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class EntitlementServiceImpl implements EntitlementService {
+public class EntitlementServiceImpl extends AbstractServiceImpl implements EntitlementService, ContextAware {
 
     @Autowired
-    private AuthenticationController authenticationController;
+    private EntitlementController controller;
 
     @Override
     public Set<EntitlementTO> getAllEntitlements() {
-        Set<String> entitlements = new HashSet<String>(authenticationController.listEntitlements());
+        Set<String> entitlements = new HashSet<String>(controller.listEntitlements());
         return CollectionWrapper.wrap(entitlements);
     }
 
     @Override
     public Set<EntitlementTO> getMyEntitlements() {
-        Set<String> entitlements = authenticationController.getEntitlements();
+        Set<String> entitlements = controller.getEntitlements();
         return CollectionWrapper.wrap(entitlements);
     }
 }

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=1505995&r1=1505994&r2=1505995&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 Tue Jul 23 11:52:05 2013
@@ -34,21 +34,21 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class LoggerServiceImpl implements LoggerService {
+public class LoggerServiceImpl extends AbstractServiceImpl implements LoggerService, ContextAware {
 
     @Autowired
-    private LoggerController loggerController;
+    private LoggerController controller;
 
     @Override
     public void delete(final LoggerType type, final String name) {
         switch (type) {
             case NORMAL:
-                loggerController.deleteLog(name);
+                controller.deleteLog(name);
                 break;
 
             case AUDIT:
                 try {
-                    loggerController.disableAudit(AuditLoggerName.fromLoggerName(name));
+                    controller.disableAudit(AuditLoggerName.fromLoggerName(name));
                 } catch (IllegalArgumentException e) {
                     throw new BadRequestException(e);
                 } catch (ParseException e) {
@@ -66,10 +66,10 @@ public class LoggerServiceImpl implement
     public List<LoggerTO> list(final LoggerType type) {
         switch (type) {
             case NORMAL:
-                return loggerController.listLogs();
+                return controller.listLogs();
 
             case AUDIT:
-                List<AuditLoggerName> auditLogger = loggerController.listAudits();
+                List<AuditLoggerName> auditLogger = controller.listAudits();
                 return CollectionWrapper.unwrapLogger(auditLogger);
 
             default:
@@ -92,12 +92,12 @@ public class LoggerServiceImpl implement
     public void update(final LoggerType type, final String name, final LoggerTO logger) {
         switch (type) {
             case NORMAL:
-                loggerController.setLogLevel(name, logger.getLevel().getLevel());
+                controller.setLogLevel(name, logger.getLevel().getLevel());
                 break;
 
             case AUDIT:
                 try {
-                    loggerController.enableAudit(AuditLoggerName.fromLoggerName(name));
+                    controller.enableAudit(AuditLoggerName.fromLoggerName(name));
                 } catch (IllegalArgumentException e) {
                     throw new BadRequestException(e);
                 } catch (ParseException e) {
@@ -109,5 +109,4 @@ public class LoggerServiceImpl implement
                 throw new BadRequestException();
         }
     }
-
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/NotificationServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -22,7 +22,6 @@ import java.net.URI;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.NotificationService;
@@ -32,16 +31,14 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class NotificationServiceImpl implements NotificationService, ContextAware {
+public class NotificationServiceImpl extends AbstractServiceImpl implements NotificationService, ContextAware {
 
     @Autowired
-    private NotificationController notificationController;
-
-    private UriInfo uriInfo;
+    private NotificationController controller;
 
     @Override
     public Response create(final NotificationTO notificationTO) {
-        NotificationTO createdNotificationTO = notificationController.createInternal(notificationTO);
+        NotificationTO createdNotificationTO = controller.create(notificationTO);
         URI location = uriInfo.getAbsolutePathBuilder().path("" + createdNotificationTO.getId()).build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, createdNotificationTO.getId())
@@ -50,26 +47,21 @@ public class NotificationServiceImpl imp
 
     @Override
     public NotificationTO read(final Long notificationId) {
-        return notificationController.read(notificationId);
+        return controller.read(notificationId);
     }
 
     @Override
     public List<NotificationTO> list() {
-        return notificationController.list();
+        return controller.list();
     }
 
     @Override
     public void update(final Long notificationId, final NotificationTO notificationTO) {
-        notificationController.update(notificationTO);
+        controller.update(notificationTO);
     }
 
     @Override
     public void delete(final Long notificationId) {
-        notificationController.delete(notificationId);
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        controller.delete(notificationId);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/PolicyServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.Set;
 import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.PolicyService;
 import org.apache.syncope.common.to.AccountPolicyTO;
@@ -38,16 +37,14 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class PolicyServiceImpl implements PolicyService, ContextAware {
+public class PolicyServiceImpl extends AbstractServiceImpl implements PolicyService, ContextAware {
 
     @Autowired
     private PolicyController policyController;
 
-    private UriInfo uriInfo;
-
     @Override
     public <T extends PolicyTO> Response create(final PolicyType type, final T policyTO) {
-        PolicyTO policy = policyController.createInternal(policyTO);
+        PolicyTO policy = policyController.create(policyTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(policy.getId() + "").build();
         return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, policy.getId()).build();
     }
@@ -58,9 +55,8 @@ public class PolicyServiceImpl implement
     }
 
     @Override
-    @SuppressWarnings("unchecked")
     public <T extends PolicyTO> List<T> list(final PolicyType type) {
-        return (List<T>) policyController.list(type.toString());
+        return policyController.list(type);
     }
 
     @Override
@@ -120,11 +116,6 @@ public class PolicyServiceImpl implement
     }
 
     @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
-    }
-
-    @Override
     public Set<CorrelationRuleClassTO> getSyncCorrelationRuleClasses(final PolicyType type) {
         Set<CorrelationRuleClassTO> result = null;
 
@@ -132,10 +123,8 @@ public class PolicyServiceImpl implement
             case SYNC:
             case GLOBAL_SYNC:
 
-                @SuppressWarnings("unchecked")
-                final Set<String> classes = (Set<String>) policyController.getSyncCorrelationRuleClasses().getModel().
-                        values().iterator().next();
-                result = CollectionWrapper.wrapSyncCorrelationRuleClasses(classes);
+                result = CollectionWrapper.wrapSyncCorrelationRuleClasses(
+                        policyController.getSyncCorrelationRuleClasses());
                 break;
 
             default:

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ReportServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -24,7 +24,6 @@ import java.net.URI;
 import java.util.List;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.StreamingOutput;
-import javax.ws.rs.core.UriInfo;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ReportService;
 import org.apache.syncope.common.services.ReportletConfClasses;
@@ -38,19 +37,17 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class ReportServiceImpl implements ReportService, ContextAware {
+public class ReportServiceImpl extends AbstractServiceImpl implements ReportService, ContextAware {
 
     @Autowired
-    private ReportController reportController;
+    private ReportController controller;
 
     @Autowired
     private ReportDAO reportDAO;
 
-    private UriInfo uriInfo;
-
     @Override
     public Response create(final ReportTO reportTO) {
-        ReportTO createdReportTO = reportController.createInternal(reportTO);
+        ReportTO createdReportTO = controller.create(reportTO);
         URI location = uriInfo.getAbsolutePathBuilder().path("" + createdReportTO.getId()).build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, createdReportTO.getId())
@@ -59,7 +56,7 @@ public class ReportServiceImpl implement
 
     @Override
     public void update(final Long reportId, final ReportTO reportTO) {
-        reportController.update(reportTO);
+        controller.update(reportTO);
     }
 
     @Override
@@ -69,38 +66,38 @@ public class ReportServiceImpl implement
 
     @Override
     public List<ReportTO> list() {
-        return reportController.list();
+        return controller.list();
     }
 
     @Override
     public List<ReportTO> list(final int page, final int size) {
-        return reportController.list(page, size);
+        return controller.list(page, size);
     }
 
     @Override
     public ReportletConfClasses getReportletConfClasses() {
-        return new ReportletConfClasses(reportController.getReportletConfClassesInternal());
+        return new ReportletConfClasses(controller.getReportletConfClasses());
     }
 
     @Override
     public ReportTO read(final Long reportId) {
-        return reportController.read(reportId);
+        return controller.read(reportId);
     }
 
     @Override
     public ReportExecTO readExecution(final Long executionId) {
-        return reportController.readExecution(executionId);
+        return controller.readExecution(executionId);
     }
 
     @Override
     public Response exportExecutionResult(final Long executionId, final ReportExecExportFormat fmt) {
         final ReportExecExportFormat format = (fmt == null) ? ReportExecExportFormat.XML : fmt;
-        final ReportExec reportExec = reportController.getAndCheckReportExecInternal(executionId);
+        final ReportExec reportExec = controller.getAndCheckReportExec(executionId);
         StreamingOutput sout = new StreamingOutput() {
 
             @Override
             public void write(final OutputStream os) throws IOException {
-                reportController.exportExecutionResultInternal(os, reportExec, format);
+                controller.exportExecutionResult(os, reportExec, format);
             }
         };
         String disposition = "attachment; filename=" + reportExec.getReport().getName() + "." + format.name().
@@ -112,21 +109,16 @@ public class ReportServiceImpl implement
 
     @Override
     public ReportExecTO execute(final Long reportId) {
-        return reportController.execute(reportId);
+        return controller.execute(reportId);
     }
 
     @Override
     public void delete(final Long reportId) {
-        reportController.delete(reportId);
+        controller.delete(reportId);
     }
 
     @Override
     public void deleteExecution(final Long executionId) {
-        reportController.deleteExecution(executionId);
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo uriInfo) {
-        this.uriInfo = uriInfo;
+        controller.deleteExecution(executionId);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.Set;
 
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.ResourceService;
@@ -39,16 +38,14 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class ResourceServiceImpl implements ResourceService, ContextAware {
+public class ResourceServiceImpl extends AbstractServiceImpl implements ResourceService, ContextAware {
 
     @Autowired
-    private ResourceController resourceController;
-
-    private UriInfo uriInfo;
+    private ResourceController controller;
 
     @Override
     public Response create(final ResourceTO resourceTO) {
-        ResourceTO resource = resourceController.create(new DummyHTTPServletResponse(), resourceTO);
+        ResourceTO resource = controller.create(resourceTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(resource.getName()).build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, resource.getName())
@@ -57,54 +54,46 @@ public class ResourceServiceImpl impleme
 
     @Override
     public void update(final String resourceName, final ResourceTO resourceTO) {
-        resourceController.update(resourceTO);
+        controller.update(resourceTO);
     }
 
     @Override
     public void delete(final String resourceName) {
-        resourceController.delete(resourceName);
+        controller.delete(resourceName);
     }
 
     @Override
     public ResourceTO read(final String resourceName) {
-        return resourceController.read(resourceName);
+        return controller.read(resourceName);
     }
 
     @Override
     public Set<PropagationActionClassTO> getPropagationActionsClasses() {
-        @SuppressWarnings("unchecked")
-        Set<String> classes = (Set<String>) resourceController.getPropagationActionsClasses().getModel().values()
-                .iterator().next();
-        return CollectionWrapper.wrapPropagationActionClasses(classes);
+        return CollectionWrapper.wrapPropagationActionClasses(controller.getPropagationActionsClasses());
     }
 
     @Override
     public List<ResourceTO> list() {
-        return resourceController.list(null);
+        return controller.list(null);
     }
 
     @Override
     public List<ResourceTO> list(final Long connInstanceId) {
-        return resourceController.list(connInstanceId);
+        return controller.list(connInstanceId);
     }
 
     @Override
     public ConnObjectTO getConnectorObject(final String resourceName, final AttributableType type, final Long id) {
-        return resourceController.getConnectorObject(resourceName, type, id);
+        return controller.getConnectorObject(resourceName, type, id);
     }
 
     @Override
     public boolean check(final ResourceTO resourceTO) {
-        return (Boolean) resourceController.check(resourceTO).getModel().values().iterator().next();
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        return controller.check(resourceTO);
     }
 
     @Override
     public BulkActionRes bulkAction(final BulkAction bulkAction) {
-        return resourceController.bulkAction(bulkAction);
+        return controller.bulkAction(bulkAction);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/RoleServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -23,7 +23,6 @@ import java.util.List;
 
 import javax.ws.rs.ServiceUnavailableException;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.mod.RoleMod;
@@ -36,26 +35,24 @@ import org.springframework.beans.factory
 import org.springframework.stereotype.Service;
 
 @Service
-public class RoleServiceImpl implements RoleService, ContextAware {
+public class RoleServiceImpl extends AbstractServiceImpl implements RoleService, ContextAware {
 
     @Autowired
-    private RoleController roleController;
-
-    private UriInfo uriInfo;
+    private RoleController controller;
 
     @Override
     public List<RoleTO> children(final Long roleId) {
-        return roleController.children(roleId);
+        return controller.children(roleId);
     }
 
     @Override
     public int count() {
-        return roleController.list().size();
+        return controller.list().size();
     }
 
     @Override
     public Response create(final RoleTO roleTO) {
-        RoleTO created = roleController.create(new DummyHTTPServletResponse(), roleTO);
+        RoleTO created = controller.create(roleTO);
         URI location = uriInfo.getAbsolutePathBuilder().path(created.getId() + "").build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, created.getId())
@@ -65,12 +62,12 @@ public class RoleServiceImpl implements 
 
     @Override
     public RoleTO delete(final Long roleId) {
-        return roleController.delete(roleId);
+        return controller.delete(roleId);
     }
 
     @Override
     public List<RoleTO> list() {
-        return roleController.list();
+        return controller.list();
     }
 
     @Override
@@ -80,42 +77,38 @@ public class RoleServiceImpl implements 
 
     @Override
     public RoleTO parent(final Long roleId) {
-        return roleController.parent(roleId);
+        return controller.parent(roleId);
     }
 
     @Override
     public RoleTO read(final Long roleId) {
-        return roleController.read(roleId);
+        return controller.read(roleId);
     }
 
     @Override
     public List<RoleTO> search(final NodeCond searchCondition) throws InvalidSearchConditionException {
-        return roleController.search(searchCondition);
+        return controller.search(searchCondition);
     }
 
     @Override
-    public List<RoleTO> search(final NodeCond searchCondition, final int page, final int size) throws InvalidSearchConditionException {
-        return roleController.search(searchCondition, page, size);
+    public List<RoleTO> search(final NodeCond searchCondition, final int page, final int size)
+            throws InvalidSearchConditionException {
+
+        return controller.search(searchCondition, page, size);
     }
 
     @Override
     public int searchCount(final NodeCond searchCondition) throws InvalidSearchConditionException {
-        return (Integer) roleController.searchCount(searchCondition).getModel().values().iterator().next();
+        return controller.searchCount(searchCondition);
     }
 
     @Override
     public RoleTO selfRead(final Long roleId) {
-        return roleController.selfRead(roleId);
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        return controller.selfRead(roleId);
     }
 
     @Override
     public RoleTO update(final Long roleId, final RoleMod roleMod) {
-        return roleController.update(roleMod);
+        return controller.update(roleMod);
     }
-
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/SchemaServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -21,61 +21,29 @@ package org.apache.syncope.core.services
 import java.net.URI;
 import java.util.List;
 
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.SchemaService;
 import org.apache.syncope.common.to.AbstractSchemaTO;
-import org.apache.syncope.common.to.DerivedSchemaTO;
-import org.apache.syncope.common.to.SchemaTO;
-import org.apache.syncope.common.to.VirtualSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.SchemaType;
-import org.apache.syncope.core.rest.controller.DerivedSchemaController;
 import org.apache.syncope.core.rest.controller.SchemaController;
-import org.apache.syncope.core.rest.controller.VirtualSchemaController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class SchemaServiceImpl implements SchemaService, ContextAware {
+public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaService, ContextAware {
 
     @Autowired
-    private SchemaController normalSchemaController;
-
-    @Autowired
-    private DerivedSchemaController derivedSchemaController;
-
-    @Autowired
-    private VirtualSchemaController virtualSchemaController;
-
-    private UriInfo uriInfo;
+    private SchemaController controller;
 
     @Override
-    public <T extends AbstractSchemaTO> Response create(final AttributableType kind, final SchemaType type,
+    public <T extends AbstractSchemaTO> Response create(final AttributableType attrType, final SchemaType schemaType,
             final T schemaTO) {
-        AbstractSchemaTO response;
-        switch (type) {
-            case NORMAL:
-                response = normalSchemaController.create(new DummyHTTPServletResponse(), (SchemaTO) schemaTO,
-                        kind.toString());
-                break;
-
-            case DERIVED:
-                response = derivedSchemaController.create(new DummyHTTPServletResponse(), (DerivedSchemaTO) schemaTO,
-                        kind.toString());
-                break;
-
-            case VIRTUAL:
-                response = virtualSchemaController.create(new DummyHTTPServletResponse(), (VirtualSchemaTO) schemaTO,
-                        kind.toString());
-                break;
-
-            default:
-                throw new BadRequestException();
-        }
+
+        T response = controller.create(attrType, schemaType, schemaTO);
+
         URI location = uriInfo.getAbsolutePathBuilder().path(response.getName()).build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, response.getName())
@@ -83,85 +51,26 @@ public class SchemaServiceImpl implement
     }
 
     @Override
-    public void delete(final AttributableType kind, final SchemaType type, final String schemaName) {
-        switch (type) {
-            case NORMAL:
-                normalSchemaController.delete(kind.toString(), schemaName);
-                break;
-
-            case DERIVED:
-                derivedSchemaController.delete(kind.toString(), schemaName);
-                break;
-
-            case VIRTUAL:
-                virtualSchemaController.delete(kind.toString(), schemaName);
-                break;
-
-            default:
-                throw new BadRequestException();
-        }
+    public void delete(final AttributableType attrType, final SchemaType schemaType, final String schemaName) {
+        controller.delete(attrType, schemaType, schemaName);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends AbstractSchemaTO> List<T> list(final AttributableType kind, final SchemaType type) {
-        switch (type) {
-            case NORMAL:
-                return (List<T>) normalSchemaController.list(kind.toString());
-
-            case DERIVED:
-                return (List<T>) derivedSchemaController.list(kind.toString());
-
-            case VIRTUAL:
-                return (List<T>) virtualSchemaController.list(kind.toString());
-
-            default:
-                throw new BadRequestException();
-        }
+    public <T extends AbstractSchemaTO> List<T> list(final AttributableType attrType, final SchemaType schemaType) {
+        return controller.list(attrType, schemaType);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends AbstractSchemaTO> T read(final AttributableType kind, final SchemaType type,
+    public <T extends AbstractSchemaTO> T read(final AttributableType attrType, final SchemaType schemaType,
             final String schemaName) {
-        switch (type) {
-            case NORMAL:
-                return (T) normalSchemaController.read(kind.toString(), schemaName);
-
-            case DERIVED:
-                return (T) derivedSchemaController.read(kind.toString(), schemaName);
-
-            case VIRTUAL:
-                return (T) virtualSchemaController.read(kind.toString(), schemaName);
-
-            default:
-                throw new BadRequestException();
-        }
+
+        return controller.read(attrType, schemaType, schemaName);
     }
 
     @Override
-    public <T extends AbstractSchemaTO> void update(final AttributableType kind, final SchemaType type,
+    public <T extends AbstractSchemaTO> void update(final AttributableType attrType, final SchemaType schemaType,
             final String schemaName, final T schemaTO) {
-        switch (type) {
-            case NORMAL:
-                normalSchemaController.update((SchemaTO) schemaTO, kind.toString());
-                break;
-
-            case DERIVED:
-                derivedSchemaController.update((DerivedSchemaTO) schemaTO, kind.toString());
-                break;
-
-            case VIRTUAL:
-                virtualSchemaController.update((VirtualSchemaTO) schemaTO, kind.toString());
-                break;
-
-            default:
-                throw new BadRequestException();
-        }
-    }
 
-    @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
+        controller.update(attrType, schemaType, schemaName, schemaTO);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/TaskServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -23,14 +23,11 @@ import java.util.List;
 import java.util.Set;
 import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.TaskService;
 import org.apache.syncope.common.to.BulkAction;
 import org.apache.syncope.common.to.BulkActionRes;
 import org.apache.syncope.common.to.JobClassTO;
-import org.apache.syncope.common.to.NotificationTaskTO;
-import org.apache.syncope.common.to.PropagationTaskTO;
 import org.apache.syncope.common.to.ReportExecTO;
 import org.apache.syncope.common.to.SchedTaskTO;
 import org.apache.syncope.common.to.SyncActionClassTO;
@@ -41,124 +38,100 @@ import org.apache.syncope.common.types.P
 import org.apache.syncope.common.types.TaskType;
 import org.apache.syncope.common.util.CollectionWrapper;
 import org.apache.syncope.core.rest.controller.TaskController;
+import org.apache.syncope.core.util.TaskUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class TaskServiceImpl implements TaskService, ContextAware {
+public class TaskServiceImpl extends AbstractServiceImpl implements TaskService, ContextAware {
 
     @Autowired
-    private TaskController taskController;
-
-    private UriInfo uriInfo;
+    private TaskController controller;
 
     @Override
     public int count(final TaskType taskType) {
-        return taskController.countInternal(taskType.toString());
+        return controller.count(taskType);
     }
 
     @Override
     public Response create(final TaskTO taskTO) {
         TaskTO createdTask;
         if (taskTO instanceof SyncTaskTO || taskTO instanceof SchedTaskTO) {
-            createdTask = taskController.createSchedTaskInternal((SchedTaskTO) taskTO);
+            createdTask = controller.createSchedTask((SchedTaskTO) taskTO);
         } else {
             throw new BadRequestException();
         }
-        TaskType taskType = getTaskType(taskTO.getClass());
+
+        TaskType taskType = TaskUtil.getInstance(taskTO.getClass()).getType();
         URI location = uriInfo.getAbsolutePathBuilder().path(taskType.toString() + "/" + createdTask.getId()).build();
         return Response.created(location).header(SyncopeConstants.REST_HEADER_ID, createdTask.getId()).build();
     }
 
-    private TaskType getTaskType(Class<? extends TaskTO> taskClass) {
-        if (taskClass == PropagationTaskTO.class) {
-            return TaskType.PROPAGATION;
-        } else if (taskClass == NotificationTaskTO.class) {
-            return TaskType.NOTIFICATION;
-        } else if (taskClass == SchedTaskTO.class) {
-            return TaskType.SCHEDULED;
-        } else if (taskClass == SyncTaskTO.class) {
-            return TaskType.SYNCHRONIZATION;
-        } else {
-            throw new IllegalArgumentException("Invalid task class: " + taskClass.getName());
-        }
-    }
-
     @Override
     public void delete(final Long taskId) {
-        taskController.delete(taskId);
+        controller.delete(taskId);
     }
 
     @Override
     public void deleteExecution(final Long executionId) {
-        taskController.deleteExecution(executionId);
+        controller.deleteExecution(executionId);
     }
 
     @Override
     public TaskExecTO execute(final Long taskId, final boolean dryRun) {
-        return taskController.execute(taskId, dryRun);
+        return controller.execute(taskId, dryRun);
     }
 
     @Override
     public Set<JobClassTO> getJobClasses() {
-        @SuppressWarnings("unchecked")
-        Set<String> jobClasses = (Set<String>) taskController.getJobClasses().getModel().values().iterator().next();
-        return CollectionWrapper.wrapJobClasses(jobClasses);
+        return CollectionWrapper.wrapJobClasses(controller.getJobClasses());
     }
 
     @Override
     public Set<SyncActionClassTO> getSyncActionsClasses() {
-        @SuppressWarnings("unchecked")
-        Set<String> actionClasses = (Set<String>) taskController.getSyncActionsClasses().getModel().values().iterator()
-                .next();
-        return CollectionWrapper.wrapSyncActionClasses(actionClasses);
+        return CollectionWrapper.wrapSyncActionClasses(controller.getSyncActionsClasses());
     }
 
     @Override
     public <T extends TaskTO> List<T> list(final TaskType taskType) {
-        return (List<T>) taskController.list(taskType.toString());
+        return controller.list(taskType);
     }
 
     @Override
     public <T extends TaskTO> List<T> list(final TaskType taskType, final int page, final int size) {
-        return (List<T>) taskController.list(taskType.toString(), page, size);
+        return controller.list(taskType, page, size);
     }
 
     @SuppressWarnings("unchecked")
     @Override
     public <T extends TaskTO> T read(final TaskType taskType, final Long taskId) {
-        return (T) taskController.read(taskId);
+        return (T) controller.read(taskId);
     }
 
     @Override
     public TaskExecTO readExecution(final Long executionId) {
-        return taskController.readExecution(executionId);
+        return controller.readExecution(executionId);
     }
 
     @Override
     public void report(final Long executionId, final ReportExecTO report) {
-        taskController.report(executionId, PropagationTaskExecStatus.fromString(report.getStatus()),
+        controller.report(executionId, PropagationTaskExecStatus.fromString(report.getStatus()),
                 report.getMessage());
     }
 
     @Override
     public void update(final Long taskId, final TaskTO taskTO) {
         if (taskTO instanceof SyncTaskTO) {
-            taskController.updateSync((SyncTaskTO) taskTO);
+            controller.updateSync((SyncTaskTO) taskTO);
         } else if (taskTO instanceof SchedTaskTO) {
-            taskController.updateSched((SchedTaskTO) taskTO);
+            controller.updateSched((SchedTaskTO) taskTO);
         } else {
             throw new BadRequestException();
         }
     }
 
     @Override
-    public void setUriInfo(final UriInfo ui) {
-        this.uriInfo = ui;
-    }
-
-    @Override
-    public BulkActionRes bulkAction(BulkAction bulkAction) {
-        return taskController.bulkAction(bulkAction);
+    public BulkActionRes bulkAction(final BulkAction bulkAction) {
+        return controller.bulkAction(bulkAction);
     }
 }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java?rev=1505995&r1=1505994&r2=1505995&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/UserRequestServiceImpl.java Tue Jul 23 11:52:05 2013
@@ -22,45 +22,50 @@ import java.net.URI;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.services.UserRequestService;
 import org.apache.syncope.common.to.UserRequestTO;
-import org.apache.syncope.common.types.UserRequestType;
 import org.apache.syncope.core.rest.controller.UserRequestController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class UserRequestServiceImpl implements UserRequestService, ContextAware {
+public class UserRequestServiceImpl extends AbstractServiceImpl implements UserRequestService, ContextAware {
 
     @Autowired
-    private UserRequestController userRequestController;
-
-    private UriInfo uriInfo;
+    private UserRequestController controller;
 
     @Override
     public Response getOptions() {
         return Response.ok().header("Allow", "GET,POST,OPTIONS,HEAD")
-                .header(SYNCOPE_CREATE_ALLOWED, userRequestController.isCreateAllowedByConf()).build();
+                .header(SYNCOPE_CREATE_ALLOWED, controller.isCreateAllowed()).
+                build();
     }
 
     @Override
     public boolean isCreateAllowed() {
-        return userRequestController.isCreateAllowedByConf();
+        return controller.isCreateAllowed();
     }
 
     @Override
     public Response create(final UserRequestTO userRequestTO) {
-        UserRequestTO outUserRequestTO = null;
-        if (userRequestTO.getType() == UserRequestType.CREATE) {
-            outUserRequestTO = userRequestController.create(userRequestTO.getUserTO());
-        } else if (userRequestTO.getType() == UserRequestType.UPDATE) {
-            outUserRequestTO = userRequestController.update(userRequestTO.getUserMod());
-        } else if (userRequestTO.getType() == UserRequestType.DELETE) {
-            outUserRequestTO = userRequestController.delete(userRequestTO.getUserId());
+        UserRequestTO outUserRequestTO;
+        switch (userRequestTO.getType()) {
+            case CREATE:
+                outUserRequestTO = controller.create(userRequestTO.getUserTO());
+                break;
+
+            case UPDATE:
+                outUserRequestTO = controller.update(userRequestTO.getUserMod());
+                break;
+
+            case DELETE:
+            default:
+                outUserRequestTO = controller.delete(userRequestTO.getUserId());
+                break;
         }
+
         URI location = uriInfo.getAbsolutePathBuilder().path("" + outUserRequestTO.getId()).build();
         return Response.created(location)
                 .header(SyncopeConstants.REST_HEADER_ID, outUserRequestTO.getId())
@@ -69,21 +74,16 @@ public class UserRequestServiceImpl impl
 
     @Override
     public List<UserRequestTO> list() {
-        return userRequestController.list();
+        return controller.list();
     }
 
     @Override
     public UserRequestTO read(final Long requestId) {
-        return userRequestController.read(requestId);
+        return controller.read(requestId);
     }
 
     @Override
     public void delete(final Long requestId) {
-        userRequestController.deleteRequest(requestId);
-    }
-
-    @Override
-    public void setUriInfo(final UriInfo uriInfo) {
-        this.uriInfo = uriInfo;
+        controller.deleteRequest(requestId);
     }
 }



Mime
View raw message