Author: jbernhardt
Date: Fri Jan 25 10:00:28 2013
New Revision: 1438409

URL: http://svn.apache.org/viewvc?rev=1438409&view=rev
Log:
[SYNCOPE-231]
* Adding ResourceService
* Adding JAX-B Annotations
* Code cleanup (according to Checkstyle and PMD)

Added:
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
Modified:
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingItemTO.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingTO.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ResourceTO.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/types/IntMappingType.java
    
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
    
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
    
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
    syncope/trunk/core/src/main/resources/restContext.xml
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java
 Fri Jan 25 10:00:28 2013
@@ -18,14 +18,20 @@
  */
 package org.apache.syncope.client.services.proxy;
 
+import java.net.URI;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
+import javax.ws.rs.core.Response;
+
 import org.apache.syncope.common.services.ResourceService;
 import org.apache.syncope.common.to.ConnObjectTO;
+import org.apache.syncope.common.to.PropagationActionClassTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.util.CollectionWrapper;
 import org.springframework.web.client.RestTemplate;
 
 public class ResourceServiceProxy extends SpringServiceProxy implements 
ResourceService {
@@ -35,19 +41,21 @@ public class ResourceServiceProxy extend
     }
 
     @Override
-    public ResourceTO create(final ResourceTO resourceTO) {
-        return getRestTemplate().postForObject(baseUrl + 
"resource/create.json", resourceTO, ResourceTO.class);
+    public Response create(final ResourceTO resourceTO) {
+        ResourceTO resource = getRestTemplate().postForObject(baseUrl + 
"resource/create.json", resourceTO,
+                ResourceTO.class);
+
+        return Response.created(URI.create(baseUrl + "resource/read/" + 
resource.getName() + ".json")).build();
     }
 
     @Override
-    public ResourceTO update(final String resourceName, final ResourceTO 
resourceTO) {
-        return getRestTemplate().postForObject(baseUrl + 
"resource/update.json", resourceTO, ResourceTO.class);
+    public void update(final String resourceName, final ResourceTO resourceTO) 
{
+        getRestTemplate().postForObject(baseUrl + "resource/update.json", 
resourceTO, ResourceTO.class);
     }
 
     @Override
-    public ResourceTO delete(final String resourceName) {
-        return getRestTemplate().getForObject(baseUrl + 
"resource/delete/{resourceName}.json", ResourceTO.class,
-                resourceName);
+    public void delete(final String resourceName) {
+        getRestTemplate().getForObject(baseUrl + 
"resource/delete/{resourceName}.json", ResourceTO.class, resourceName);
     }
 
     @Override
@@ -57,9 +65,11 @@ public class ResourceServiceProxy extend
     }
 
     @Override
-    public Set<String> getPropagationActionsClasses() {
-        return new 
HashSet<String>(Arrays.asList(getRestTemplate().getForObject(baseUrl
-                + "resource/propagationActionsClasses.json", String[].class)));
+    public Set<PropagationActionClassTO> getPropagationActionsClasses() {
+        Set<String> classes = new 
HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
+                baseUrl + "resource/propagationActionsClasses.json", 
String[].class)));
+
+        return CollectionWrapper.wrapPropagationActionClasses(classes);
     }
 
     @Override
@@ -85,7 +95,7 @@ public class ResourceServiceProxy extend
 
     @Override
     public boolean check(final ResourceTO resourceTO) {
-        return getRestTemplate().postForObject(baseUrl + 
"resource/check.json", resourceTO, Boolean.class).
-                booleanValue();
+        return getRestTemplate().postForObject(baseUrl + 
"resource/check.json", resourceTO, Boolean.class)
+                .booleanValue();
     }
 }

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java
 Fri Jan 25 10:00:28 2013
@@ -27,8 +27,10 @@ import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
 
 import org.apache.syncope.common.to.ConnObjectTO;
+import org.apache.syncope.common.to.PropagationActionClassTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.AttributableType;
 
@@ -36,24 +38,25 @@ import org.apache.syncope.common.types.A
 public interface ResourceService {
 
     @POST
-    ResourceTO create(ResourceTO resourceTO);
+    @Path("validate")
+    boolean check(ResourceTO resourceTO);
 
-    @PUT
-    @Path("{resourceName}")
-    ResourceTO update(@PathParam("resourceName") String resourceName, 
ResourceTO resourceTO);
+    @POST
+    Response create(ResourceTO resourceTO);
 
     @DELETE
     @Path("{resourceName}")
-    ResourceTO delete(@PathParam("resourceName") String resourceName);
+    void delete(@PathParam("resourceName") String resourceName);
 
     @GET
-    @Path("{resourceName}")
-    ResourceTO read(@PathParam("resourceName") String resourceName);
+    @Path("{resourceName}/{type}/{objectId}")
+    ConnObjectTO getConnector(@PathParam("resourceName") String resourceName,
+            @PathParam("type") AttributableType type, @PathParam("objectId") 
String objectId);
 
-    // TODO: is it resource method?
+    // TODO: is it a resource method?
     @GET
     @Path("propagationActionsClasses")
-    Set<String> getPropagationActionsClasses();
+    Set<PropagationActionClassTO> getPropagationActionsClasses();
 
     @GET
     List<ResourceTO> list();
@@ -62,11 +65,11 @@ public interface ResourceService {
     List<ResourceTO> list(@MatrixParam("connInstanceId") Long connInstanceId);
 
     @GET
-    @Path("{resourceName}/{type}/{objectId}")
-    ConnObjectTO getConnector(@PathParam("resourceName") String resourceName,
-            @PathParam("type") AttributableType type, @PathParam("objectId") 
String objectId);
+    @Path("{resourceName}")
+    ResourceTO read(@PathParam("resourceName") String resourceName);
+
+    @PUT
+    @Path("{resourceName}")
+    void update(@PathParam("resourceName") String resourceName, ResourceTO 
resourceTO);
 
-    @POST
-    @Path("validate")
-    boolean check(ResourceTO resourceTO);
 }

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingItemTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingItemTO.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingItemTO.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingItemTO.java
 Fri Jan 25 10:00:28 2013
@@ -18,9 +18,14 @@
  */
 package org.apache.syncope.common.to;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.common.AbstractBaseBean;
 import org.apache.syncope.common.types.IntMappingType;
 
+@XmlRootElement(name = "mappingItem")
+@XmlType
 public class MappingItemTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 2983498836767176862L;

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingTO.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingTO.java 
(original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/MappingTO.java 
Fri Jan 25 10:00:28 2013
@@ -21,16 +21,24 @@ package org.apache.syncope.common.to;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.common.AbstractBaseBean;
 import org.apache.syncope.common.types.IntMappingType;
 
+@XmlRootElement(name = "mapping")
+@XmlType
 public class MappingTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 8447688036282611118L;
 
     private String accountLink;
 
-    private List<MappingItemTO> items;
+    private final List<MappingItemTO> items;
 
     public MappingTO() {
         super();
@@ -104,6 +112,8 @@ public class MappingTO extends AbstractB
     }
 
     @SuppressWarnings("unchecked")
+    @XmlElementWrapper(name = "items")
+    @XmlElement(name = "item")
     public <T extends MappingItemTO> List<T> getItems() {
         return (List<T>) items;
     }

Added: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java?rev=1438409&view=auto
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
 (added)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/PropagationActionClassTO.java
 Fri Jan 25 10:00:28 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.common.to;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.syncope.common.AbstractBaseBean;
+
+@XmlRootElement(name = "propagationActionClass")
+@XmlType
+public class PropagationActionClassTO extends AbstractBaseBean {
+
+    private static final long serialVersionUID = 2187654394121198308L;
+
+    private String name;
+
+    public static PropagationActionClassTO instance(final String name) {
+        PropagationActionClassTO instance = new PropagationActionClassTO();
+        instance.setName(name);
+        return instance;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(final String name) {
+        this.name = name;
+    }
+}

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ResourceTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ResourceTO.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ResourceTO.java 
(original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/to/ResourceTO.java 
Fri Jan 25 10:00:28 2013
@@ -21,11 +21,16 @@ package org.apache.syncope.common.to;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.common.AbstractBaseBean;
 import org.apache.syncope.common.types.ConnConfProperty;
 import org.apache.syncope.common.types.PropagationMode;
 import org.apache.syncope.common.types.TraceLevel;
 
+@XmlRootElement(name = "resource")
+@XmlType
 public class ResourceTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = -9193551354041698963L;

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/types/IntMappingType.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/types/IntMappingType.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/types/IntMappingType.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/types/IntMappingType.java
 Fri Jan 25 10:00:28 2013
@@ -22,9 +22,12 @@ import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.xml.bind.annotation.XmlEnum;
+
 /**
  * Internal attribute mapping type.
  */
+@XmlEnum
 public enum IntMappingType {
 
     // Unfortunately enum type cannot be extended ...

Modified: 
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
 (original)
+++ 
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
 Fri Jan 25 10:00:28 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.common.util;
 
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -28,6 +27,7 @@ import org.apache.syncope.common.to.Enti
 import org.apache.syncope.common.to.JobClassTO;
 import org.apache.syncope.common.to.LoggerTO;
 import org.apache.syncope.common.to.MailTemplateTO;
+import org.apache.syncope.common.to.PropagationActionClassTO;
 import org.apache.syncope.common.to.SyncActionClassTO;
 import org.apache.syncope.common.to.ValidatorTO;
 import org.apache.syncope.common.types.AuditLoggerName;
@@ -169,4 +169,20 @@ public final class CollectionWrapper {
         }
         return respons;
     }
+
+    public static Set<PropagationActionClassTO> 
wrapPropagationActionClasses(Set<String> classes) {
+        Set<PropagationActionClassTO> respons = new 
HashSet<PropagationActionClassTO>();
+        for (String cl : classes) {
+            respons.add(PropagationActionClassTO.instance(cl));
+        }
+        return respons;
+    }
+
+    public static List<String> 
unwrapPropagationActionClasses(Set<PropagationActionClassTO> actions) {
+        List<String> respons = new ArrayList<String>();
+        for (PropagationActionClassTO e : actions) {
+            respons.add(e.getName());
+        }
+        return respons;
+    }
 }

Modified: 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
 (original)
+++ 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java
 Fri Jan 25 10:00:28 2013
@@ -20,9 +20,12 @@ package org.apache.syncope.console.rest;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.syncope.common.services.ResourceService;
+import org.apache.syncope.common.to.PropagationActionClassTO;
 import org.apache.syncope.common.to.ResourceTO;
+import org.apache.syncope.common.util.CollectionWrapper;
 import 
org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.springframework.stereotype.Component;
 
@@ -38,7 +41,8 @@ public class ResourceRestClient extends 
         List<String> actions = null;
 
         try {
-            actions = new 
ArrayList<String>(getService(ResourceService.class).getPropagationActionsClasses());
+            Set<PropagationActionClassTO> response = 
getService(ResourceService.class).getPropagationActionsClasses();
+            actions = 
CollectionWrapper.unwrapPropagationActionClasses(response);
         } catch (SyncopeClientCompositeErrorException e) {
             LOG.error("While getting all propagation actions classes", e);
         }
@@ -76,7 +80,7 @@ public class ResourceRestClient extends 
         getService(ResourceService.class).update(resourceTO.getName(), 
resourceTO);
     }
 
-    public ResourceTO delete(final String name) {
-        return getService(ResourceService.class).delete(name);
+    public void delete(final String name) {
+        getService(ResourceService.class).delete(name);
     }
 }

Modified: 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
 (original)
+++ 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/TaskRestClient.java
 Fri Jan 25 10:00:28 2013
@@ -91,7 +91,7 @@ public class TaskRestClient extends Base
         return result;
     }
 
-    private TaskType getTaskType(Class<?> reference) {
+    private TaskType getTaskType(final Class<?> reference) {
         TaskType result = null;
         if (PropagationTaskTO.class.equals(reference)) {
             result = TaskType.PROPAGATION;
@@ -149,7 +149,7 @@ public class TaskRestClient extends Base
      *
      * @param taskId task id
      */
-    public void startExecution(final Long taskId, boolean dryRun) {
+    public void startExecution(final Long taskId, final boolean dryRun) {
         getService(TaskService.class).execute(taskId, dryRun);
     }
 

Added: 
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=1438409&view=auto
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
 (added)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java
 Fri Jan 25 10:00:28 2013
@@ -0,0 +1,146 @@
+/*
+ * 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 java.net.URI;
+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.ResourceService;
+import org.apache.syncope.common.to.ConnObjectTO;
+import org.apache.syncope.common.to.PropagationActionClassTO;
+import org.apache.syncope.common.to.ResourceTO;
+import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.util.CollectionWrapper;
+import 
org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.core.rest.controller.ResourceController;
+import org.apache.syncope.core.util.NotFoundException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ResourceServiceImpl implements ResourceService, ContextAware {
+
+    @Autowired
+    private ResourceController resourceController;
+
+    private UriInfo uriInfo;
+
+    @Override
+    public Response create(final ResourceTO resourceTO) {
+        try {
+            ResourceTO resource = resourceController.create(new 
DummyHTTPServletResponse(), resourceTO);
+            URI location = 
uriInfo.getAbsolutePathBuilder().path(resource.getName()).build();
+            return 
Response.created(location).header(SyncopeConstants.REST_HEADER_ID, 
resource.getName()).build();
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void update(final String resourceName, final ResourceTO resourceTO) 
{
+        try {
+            resourceController.update(resourceTO);
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void delete(final String resourceName) {
+        try {
+            resourceController.delete(resourceName);
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public ResourceTO read(final String resourceName) {
+        try {
+            return resourceController.read(resourceName);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public Set<PropagationActionClassTO> getPropagationActionsClasses() {
+        @SuppressWarnings("unchecked")
+        Set<String> classes = (Set<String>) 
resourceController.getPropagationActionsClasses().getModel().values()
+                .iterator().next();
+        return CollectionWrapper.wrapPropagationActionClasses(classes);
+    }
+
+    @Override
+    public List<ResourceTO> list() {
+        try {
+            return resourceController.list(null);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public List<ResourceTO> list(final Long connInstanceId) {
+        try {
+            return resourceController.list(connInstanceId);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public ConnObjectTO getConnector(final String resourceName, final 
AttributableType type, final String objectId) {
+        try {
+            return resourceController.getObject(resourceName, type, objectId);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public boolean check(final ResourceTO resourceTO) {
+        try {
+            return (Boolean) resourceController.check(new 
DummyHTTPServletResponse(), resourceTO).getModel().values()
+                    .iterator().next();
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void setUriInfo(UriInfo ui) {
+        this.uriInfo = ui;
+    }
+
+}

Modified: syncope/trunk/core/src/main/resources/restContext.xml
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Fri Jan 25 10:00:28 
2013
@@ -66,13 +66,15 @@ under the License.
 
   <jaxrs:server id="restContainer" address="/">
     <jaxrs:serviceBeans>
-      <ref bean="configurationServiceImpl"/>
-      <ref bean="notificationServiceImpl"/>
       <ref bean="connectorServiceImpl"/>
+      <ref bean="configurationServiceImpl"/>
       <ref bean="entitlementServiceImpl"/>
+      <ref bean="loggerServiceImpl"/>
+      <ref bean="notificationServiceImpl"/>
       <ref bean="policyServiceImpl"/>
-      <ref bean="schemaServiceImpl"/>
       <ref bean="reportServiceImpl"/>
+      <ref bean="resourceServiceImpl"/>
+      <ref bean="schemaServiceImpl"/>
     </jaxrs:serviceBeans>
     <jaxrs:resourceComparator>
       <bean id="myServiceComparator" 
class="org.apache.syncope.core.rest.utils.QueryResourceInfoComperator"/>

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
 Fri Jan 25 10:00:28 2013
@@ -58,7 +58,7 @@ public class ConnInstanceTestITCase exte
     private static String bundlesDirectory;
 
     // Enable running test more than once with parameters
-    public ConnInstanceTestITCase(String contentType) {
+    public ConnInstanceTestITCase(final String contentType) {
         super(contentType);
     }
 
@@ -288,7 +288,8 @@ public class ConnInstanceTestITCase exte
         // ----------------------------------
         // Check for connector instance update after resource creation.
         // ----------------------------------
-        resourceTO = resourceService.create(resourceTO);
+        response = resourceService.create(resourceTO);
+        resourceTO = getObject(response, ResourceTO.class, resourceService);
 
         assertNotNull(resourceTO);
 

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
 Fri Jan 25 10:00:28 2013
@@ -30,8 +30,11 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import javax.ws.rs.core.Response;
+
 import org.apache.syncope.common.to.MappingItemTO;
 import org.apache.syncope.common.to.MappingTO;
+import org.apache.syncope.common.to.PropagationActionClassTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.ConnConfPropSchema;
 import org.apache.syncope.common.types.ConnConfProperty;
@@ -49,13 +52,13 @@ import org.springframework.web.client.Ht
 public class ResourceTestITCase extends AbstractTest {
 
     // Enable running test more than once with parameters
-    public ResourceTestITCase(String contentType) {
+    public ResourceTestITCase(final String contentType) {
         super(contentType);
     }
 
     @Test
     public void getPropagationActionsClasses() {
-        Set<String> actions = resourceService.getPropagationActionsClasses();
+        Set<PropagationActionClassTO> actions = 
resourceService.getPropagationActionsClasses();
         assertNotNull(actions);
         assertFalse(actions.isEmpty());
     }
@@ -65,7 +68,8 @@ public class ResourceTestITCase extends 
         String resourceName = "ws-target-resource-create";
         ResourceTO resourceTO = buildResourceTO(resourceName);
 
-        ResourceTO actual = resourceService.create(resourceTO);
+        Response response = resourceService.create(resourceTO);
+        ResourceTO actual = getObject(response, ResourceTO.class, 
resourceService);
         assertNotNull(actual);
 
         // check for existence
@@ -116,7 +120,8 @@ public class ResourceTestITCase extends 
         Set<ConnConfProperty> connectorConfigurationProperties = new 
HashSet<ConnConfProperty>(Arrays.asList(p));
         
resourceTO.setConnectorConfigurationProperties(connectorConfigurationProperties);
 
-        ResourceTO actual = resourceService.create(resourceTO);
+        Response response = resourceService.create(resourceTO);
+        ResourceTO actual = getObject(response, ResourceTO.class, 
resourceService);
         assertNotNull(actual);
 
         // check the existence
@@ -150,7 +155,9 @@ public class ResourceTestITCase extends 
 
         resourceTO.setRmapping(rmapping);
 
-        ResourceTO actual = resourceService.create(resourceTO);
+        Response response = resourceService.create(resourceTO);
+        ResourceTO actual = getObject(response, ResourceTO.class, 
resourceService);
+
         assertNotNull(actual);
         assertNotNull(actual.getUmapping());
         assertNotNull(actual.getUmapping().getItems());
@@ -240,7 +247,8 @@ public class ResourceTestITCase extends 
 
         resourceTO.setUmapping(mapping);
 
-        ResourceTO actual = resourceService.create(resourceTO);
+        Response response = resourceService.create(resourceTO);
+        ResourceTO actual = getObject(response, ResourceTO.class, 
resourceService);
         assertNotNull(actual);
 
         // check the existence
@@ -297,7 +305,8 @@ public class ResourceTestITCase extends 
 
         resourceTO.setUmapping(mapping);
 
-        ResourceTO actual = resourceService.update(resourceTO.getName(), 
resourceTO);
+        resourceService.update(resourceTO.getName(), resourceTO);
+        ResourceTO actual = resourceService.read(resourceTO.getName());
         assertNotNull(actual);
 
         // check for existence
@@ -324,7 +333,8 @@ public class ResourceTestITCase extends 
         resourceService.create(pre);
 
         pre.setUsyncToken(null);
-        ResourceTO actual = resourceService.update(pre.getName(), pre);
+        resourceService.update(pre.getName(), pre);
+        ResourceTO actual = resourceService.read(pre.getName());
         // check that the synctoken has been reset
         assertNull(actual.getUsyncToken());
     }
@@ -334,11 +344,11 @@ public class ResourceTestITCase extends 
         String resourceName = "ws-target-resource-delete";
 
         ResourceTO resource = buildResourceTO(resourceName);
-        ResourceTO actual = resourceService.create(resource);
+        Response response = resourceService.create(resource);
+        ResourceTO actual = getObject(response, ResourceTO.class, 
resourceService);
         assertNotNull(actual);
 
-        ResourceTO deletedResource = resourceService.delete(resourceName);
-        assertNotNull(deletedResource);
+        resourceService.delete(resourceName);
 
         try {
             resourceService.read(resourceName);

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1438409&r1=1438408&r2=1438409&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
 Fri Jan 25 10:00:28 2013
@@ -31,7 +31,9 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+
 import javax.ws.rs.core.Response;
+
 import org.apache.syncope.common.mod.AttributeMod;
 import org.apache.syncope.common.mod.MembershipMod;
 import org.apache.syncope.common.mod.UserMod;
@@ -75,7 +77,7 @@ import org.springframework.web.client.Ht
 public class UserTestITCase extends AbstractTest {
 
     // Enable running test more than once with parameters
-    public UserTestITCase(String contentType) {
+    public UserTestITCase(final String contentType) {
         super(contentType);
     }
 
@@ -289,7 +291,9 @@ public class UserTestITCase extends Abst
         assertNotNull(resourceTO);
         resourceTO.setName("resource-csv-enforcing");
         resourceTO.setEnforceMandatoryCondition(true);
-        resourceTO = resourceService.create(resourceTO);
+
+        Response response = resourceService.create(resourceTO);
+        resourceTO = getObject(response, ResourceTO.class, resourceService);
         assertNotNull(resourceTO);
 
         UserTO userTO = getUniqueSampleTO("[email protected]");


Reply via email to