syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbernha...@apache.org
Subject svn commit: r1430170 - in /syncope/trunk: client/src/main/java/org/apache/syncope/services/ client/src/main/java/org/apache/syncope/services/proxy/ core/src/test/java/org/apache/syncope/core/rest/
Date Tue, 08 Jan 2013 08:37:36 GMT
Author: jbernhardt
Date: Tue Jan  8 08:37:35 2013
New Revision: 1430170

URL: http://svn.apache.org/viewvc?rev=1430170&view=rev
Log:
[SYNCOPE-259]
Introduces Notification Service.
Refactoring proxy services into proxy sub-package.

Added:
    syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java
Removed:
    syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/PolicyServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/ReportServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/ResourceServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/RoleServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/TaskServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
    syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowServiceProxy.java
Modified:
    syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/NotificationService.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.services;
+
+import java.util.List;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.apache.syncope.client.to.NotificationTO;
+
+@Path("notifications")
+public interface NotificationService {
+
+    @GET
+    @Path("{notificationId}")
+//    @RequestMapping(method = RequestMethod.GET, value = "/read/{notificationId}")
+    NotificationTO read(@PathParam("notificationId") final Long notificationId);
+
+    @GET
+//    @RequestMapping(method = RequestMethod.GET, value = "/list")
+    List<NotificationTO> list();
+
+    @POST
+//    @RequestMapping(method = RequestMethod.POST, value = "/create")
+    NotificationTO create(final NotificationTO notificationTO);
+
+    @PUT
+    @Path("{notificationId}")
+//    @RequestMapping(method = RequestMethod.POST, value = "/update")
+    NotificationTO update(@PathParam("notificationId") final Long notificationId, final NotificationTO notificationTO);
+
+    @DELETE
+    @Path("{notificationId}")
+//    @RequestMapping(method = RequestMethod.GET, value = "/delete/{notificationId}")
+    NotificationTO delete(@PathParam("notificationId") final Long notificationId);
+
+}
\ No newline at end of file

Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java?rev=1430170&r1=1430169&r2=1430170&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/WorkflowService.java Tue Jan  8 08:37:35 2013
@@ -31,21 +31,21 @@ import org.apache.syncope.client.to.Work
 public interface WorkflowService {
 
     @GET
-    @Path("{type}")
+    @Path("{kind}")
     //    @RequestMapping(method = RequestMethod.GET, value = "/definition/user")
     //    @RequestMapping(method = RequestMethod.GET, value = "/definition/role")
-    WorkflowDefinitionTO getDefinition(@PathParam("type") final String type);
+    WorkflowDefinitionTO getDefinition(@PathParam("kind") final String kind);
 
 
 
     @PUT
-    @Path("{type}")
+    @Path("{kind}")
 //    @RequestMapping(method = RequestMethod.PUT, value = "/definition/user")
 //    @RequestMapping(method = RequestMethod.PUT, value = "/definition/role")
-    void updateDefinition(@PathParam("type") final String type, final WorkflowDefinitionTO definition);
+    void updateDefinition(@PathParam("kind") final String kind, final WorkflowDefinitionTO definition);
 
     @GET
-    @Path("{type}/tasks")
+    @Path("{kind}/tasks")
 //    @RequestMapping(method = RequestMethod.GET, value = "/tasks/user")
-    List<String> getDefinedTasks(@PathParam("type") final String type);
+    List<String> getDefinedTasks(@PathParam("kind") final String kind);
 }
\ No newline at end of file

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,87 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.syncope.client.to.ConfigurationTO;
+import org.apache.syncope.services.ConfigurationService;
+import org.springframework.web.client.RestTemplate;
+
+public class ConfigurationServiceProxy extends SpringServiceProxy implements
+		ConfigurationService {
+
+	public ConfigurationServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		super(baseUrl, restTemplate);
+	}
+
+	@Override
+	public ConfigurationTO create(ConfigurationTO configurationTO) {
+		return restTemplate.postForObject(BASE_URL + "configuration/create",
+				configurationTO, ConfigurationTO.class);
+	}
+
+	@Override
+	public ConfigurationTO delete(String key) {
+		return restTemplate
+				.getForObject(BASE_URL + "configuration/delete/{key}.json",
+						ConfigurationTO.class, key);
+	}
+
+	@Override
+	public List<ConfigurationTO> list() {
+		return Arrays.asList(restTemplate.getForObject(BASE_URL
+				+ "configuration/list.json", ConfigurationTO[].class));
+	}
+
+	@Override
+	public ConfigurationTO read(String key) {
+		return restTemplate.getForObject(BASE_URL
+				+ "configuration/read/{key}.json", ConfigurationTO.class, key);
+	}
+
+	@Override
+	public ConfigurationTO update(String key, ConfigurationTO configurationTO) {
+		return restTemplate.postForObject(BASE_URL + "configuration/update",
+				configurationTO, ConfigurationTO.class);
+	}
+
+	@Override
+	public Set<String> getValidators() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Set<String> getMailTemplates() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Response dbExport() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,108 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.ConnBundleTO;
+import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.services.ConnectorService;
+import org.apache.syncope.types.ConnConfProperty;
+import org.springframework.web.client.RestTemplate;
+
+public class ConnectorServiceProxy extends SpringServiceProxy implements ConnectorService {
+
+    public ConnectorServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public ConnInstanceTO create(ConnInstanceTO connectorTO) {
+        return restTemplate.postForObject(BASE_URL + "connector/create.json", connectorTO,
+                ConnInstanceTO.class);
+    }
+
+    @Override
+    public ConnInstanceTO update(Long connectorId, ConnInstanceTO connectorTO) {
+        return restTemplate.postForObject(BASE_URL + "connector/update.json", connectorTO,
+                ConnInstanceTO.class);
+    }
+
+    @Override
+    public ConnInstanceTO delete(Long connectorId) {
+        return restTemplate.getForObject(BASE_URL + "connector/delete/{connectorId}.json",
+                ConnInstanceTO.class, connectorId);
+    }
+
+    @Override
+    public List<ConnInstanceTO> list(String lang) {
+        String param = (lang != null)
+                ? "?lang=" + lang
+                : "";
+
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "connector/list.json" + param,
+                ConnInstanceTO[].class));
+    }
+
+    @Override
+    public ConnInstanceTO read(Long connectorId) {
+        return restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}", ConnInstanceTO.class,
+                connectorId);
+    }
+
+    @Override
+    public List<ConnBundleTO> getBundles(String lang) {
+        String param = (lang != null)
+                ? "?lang=" + lang
+                : "";
+
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "connector/bundle/list.json" + param,
+                ConnBundleTO[].class));
+    }
+
+    @Override
+    public List<String> getSchemaNames(Long connectorId, ConnInstanceTO connectorTO, boolean showall) {
+        String param = (showall)
+                ? "?showall=true"
+                : "?showall=false";
+
+        return Arrays.asList(restTemplate.postForObject(BASE_URL + "connector/schema/list" + param, connectorTO,
+                String[].class));
+    }
+
+    @Override
+    public List<ConnConfProperty> getConfigurationProperties(Long connectorId) {
+        return Arrays.asList(restTemplate
+                .getForObject(BASE_URL + "connector/{connectorId}/configurationProperty/list",
+                        ConnConfProperty[].class, connectorId));
+    }
+
+    @Override
+    public boolean validate(ConnInstanceTO connectorTO) {
+        return restTemplate.postForObject(BASE_URL + "connector/check.json", connectorTO, Boolean.class);
+    }
+
+    @Override
+    public ConnInstanceTO readConnectorBean(String resourceName) {
+        return restTemplate.getForObject(BASE_URL + "connector/{resourceName}/connectorBean",
+                ConnInstanceTO.class, resourceName);
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.syncope.services.EntitlementService;
+import org.springframework.web.client.RestTemplate;
+
+public class EntitlementServiceProxy extends SpringServiceProxy implements EntitlementService {
+	
+	public EntitlementServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		super(baseUrl, restTemplate);
+	}
+
+	@Override
+	public Set<String> getAllEntitlements() {
+		return new HashSet<String>(Arrays.asList(new RestTemplate().getForObject(
+                BASE_URL + "auth/allentitlements.json", String[].class)));
+	}
+
+	@Override
+	public Set<String> getMyEntitlements() {
+		return new HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL
+                + "auth/entitlements.json", String[].class)));
+	}
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/LoggerServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.LoggerTO;
+import org.apache.syncope.services.LoggerService;
+import org.apache.syncope.types.AuditLoggerName;
+import org.springframework.web.client.RestTemplate;
+
+import ch.qos.logback.classic.Level;
+
+public class LoggerServiceProxy extends SpringServiceProxy implements LoggerService {
+
+    public LoggerServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public List<LoggerTO> listLogs() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/log/list", LoggerTO[].class));
+    }
+
+    @Override
+    public List<AuditLoggerName> listAudits() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list",
+                AuditLoggerName[].class));
+    }
+
+    @Override
+    public LoggerTO setLogLevel(String name, Level level) {
+        return restTemplate.postForObject(BASE_URL + "logger/log/{name}/{level}", null, LoggerTO.class, name,
+                level);
+    }
+
+    @Override
+    public LoggerTO deleteLog(String name) {
+        return restTemplate.getForObject(BASE_URL + "logger/log/delete/{name}", LoggerTO.class, name);
+    }
+
+    @Override
+    public void enableAudit(AuditLoggerName auditLoggerName) {
+        restTemplate.put(BASE_URL + "logger/audit/enable", auditLoggerName);
+    }
+
+    @Override
+    public void disableAudit(AuditLoggerName auditLoggerName) {
+        restTemplate.put(BASE_URL + "logger/audit/disable", auditLoggerName);
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/NotificationServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,64 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.NotificationTO;
+import org.apache.syncope.services.NotificationService;
+import org.springframework.web.client.RestTemplate;
+
+public class NotificationServiceProxy extends SpringServiceProxy implements NotificationService {
+
+    public NotificationServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public NotificationTO read(Long notificationId) {
+        return restTemplate.getForObject(BASE_URL + "notification/read/{notificationId}.json",
+                NotificationTO.class, notificationId);
+    }
+
+    @Override
+    public List<NotificationTO> list() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "notification/list.json",
+                NotificationTO[].class));
+    }
+
+    @Override
+    public NotificationTO create(NotificationTO notificationTO) {
+        return restTemplate.postForObject(BASE_URL + "notification/create.json", notificationTO,
+                NotificationTO.class);
+    }
+
+    @Override
+    public NotificationTO update(Long notificationId, NotificationTO notificationTO) {
+        return restTemplate.postForObject(BASE_URL + "notification/update.json", notificationTO,
+                NotificationTO.class);
+    }
+
+    @Override
+    public NotificationTO delete(Long notificationId) {
+        return restTemplate.getForObject(BASE_URL + "notification/delete/{notificationId}.json",
+                NotificationTO.class, notificationId);
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/PolicyServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,88 @@
+/*
+ * 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.services.proxy;
+
+import java.util.List;
+
+import org.apache.syncope.client.to.PolicyTO;
+import org.apache.syncope.services.PolicyService;
+import org.apache.syncope.types.PolicyType;
+import org.springframework.web.client.RestTemplate;
+
+public class PolicyServiceProxy extends SpringServiceProxy implements PolicyService {
+
+	public PolicyServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		super(baseUrl, restTemplate);
+	}
+
+	@Override
+	public <T extends PolicyTO> T create(final T policyTO) {
+		@SuppressWarnings("unchecked")
+		T result = (T) restTemplate.postForObject(BASE_URL
+				+ "policy/{kind}/create", policyTO, policyTO.getClass(),
+				typeToUrl(policyTO.getType()));
+		return result;
+	}
+
+	@Override
+	public <T extends PolicyTO> T update(Long policyId, T policyTO) {
+		@SuppressWarnings("unchecked")
+		T result = (T) restTemplate.postForObject(BASE_URL
+				+ "policy/{kind}/update", policyTO, policyTO.getClass(),
+				typeToUrl(policyTO.getType()));
+		return result;
+	}
+
+	@Override
+	public <T extends PolicyTO> List<T> listByType(PolicyType type) {
+		@SuppressWarnings("unchecked")
+		List<T> result = restTemplate.getForObject(BASE_URL + "policy/{kind}/list",
+				List.class, typeToUrl(type));
+		return result;
+	}
+
+	@Override
+	public <T extends PolicyTO> T readGlobal(PolicyType type, Class<T> policyClass) {
+		T result = restTemplate.getForObject(BASE_URL + "policy/{kind}/global/read",
+                policyClass, typeToUrl(type));
+		return result;
+	}
+
+	@Override
+	public <T extends PolicyTO> T read(Long policyId, Class<T> policyClass) {
+		T result = restTemplate.getForObject(BASE_URL + "policy/read/{id}", policyClass, policyId);
+		return result;
+	}
+
+	@Override
+	public <T extends PolicyTO> T delete(Long policyId, Class<T> policyClass) {
+		T result = restTemplate.getForObject(BASE_URL + "policy/delete/{id}", policyClass, policyId);
+		return result;
+	}
+
+    private String typeToUrl(PolicyType type) {
+    	String url = type.name().toLowerCase();
+    	int index = url.indexOf("_");
+    	if (index != -1) {
+    		return url.substring(index + 1);
+    	} else {
+    		return url;
+    	}
+    }
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ReportServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,109 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.ReportExecTO;
+import org.apache.syncope.client.to.ReportTO;
+import org.apache.syncope.services.ReportService;
+import org.apache.syncope.types.ReportExecExportFormat;
+import org.springframework.web.client.RestTemplate;
+
+public class ReportServiceProxy extends SpringServiceProxy implements ReportService {
+
+    public ReportServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public ReportTO create(ReportTO reportTO) {
+        return restTemplate.postForObject(BASE_URL + "report/create", reportTO, ReportTO.class);
+    }
+
+    @Override
+    public ReportTO update(Long reportId, ReportTO reportTO) {
+        return restTemplate.postForObject(BASE_URL + "report/update", reportTO, ReportTO.class);
+    }
+
+    @Override
+    public int count() {
+        return restTemplate.getForObject(BASE_URL + "report/count.json", Integer.class);
+    }
+
+    @Override
+    public List<ReportTO> list() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "report/list", ReportTO[].class));
+    }
+
+    @Override
+    public List<ReportTO> list(int page, int size) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public List<ReportExecTO> listExecutions() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "report/execution/list",
+                ReportExecTO[].class));
+    }
+
+    @Override
+    public List<String> getReportletConfClasses() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "report/reportletConfClasses.json",
+                String[].class));
+    }
+
+    @Override
+    public ReportTO read(Long reportId) {
+        return restTemplate.getForObject(BASE_URL + "report/read/{reportId}", ReportTO.class, reportId);
+    }
+
+    @Override
+    public ReportExecTO readExecution(Long executionId) {
+        return restTemplate.getForObject(BASE_URL + "report/execution/read/{reportId}",
+                ReportExecTO.class, executionId);
+    }
+
+    @Override
+    public void exportExecutionResult(Long executionId, ReportExecExportFormat fmt) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public ReportExecTO execute(Long reportId) {
+        return restTemplate.postForObject(BASE_URL + "report/execute/{reportId}", null,
+                ReportExecTO.class, reportId);
+    }
+
+    @Override
+    public ReportTO delete(Long reportId) {
+        return restTemplate.getForObject(BASE_URL + "report/delete/{reportId}",
+                ReportTO.class, reportId);
+    }
+
+    @Override
+    public ReportExecTO deleteExecution(Long executionId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ResourceServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,89 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.syncope.client.to.ConnObjectTO;
+import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.services.ResourceService;
+import org.apache.syncope.types.AttributableType;
+import org.springframework.web.client.RestTemplate;
+
+public class ResourceServiceProxy extends SpringServiceProxy implements ResourceService {
+
+    public ResourceServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public ResourceTO create(ResourceTO resourceTO) {
+        return restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);
+    }
+
+    @Override
+    public ResourceTO update(String resourceName, ResourceTO resourceTO) {
+        return restTemplate.postForObject(BASE_URL + "resource/update.json", resourceTO, ResourceTO.class);
+    }
+
+    @Override
+    public ResourceTO delete(String resourceName) {
+        return restTemplate.getForObject(BASE_URL + "resource/delete/{resourceName}.json", ResourceTO.class,
+                resourceName);
+    }
+
+    @Override
+    public ResourceTO read(String resourceName) {
+        return restTemplate.getForObject(BASE_URL + "resource/read/{resourceName}.json", ResourceTO.class,
+                resourceName);
+    }
+
+    @Override
+    public Set<String> getPropagationActionsClasses() {
+        return new HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL
+                + "resource/propagationActionsClasses.json", String[].class)));
+    }
+
+    @Override
+    public List<ResourceTO> list(Long connInstanceId) {
+        String query = (connInstanceId != null)
+                ? query = "?connInstanceId=" + connInstanceId.toString()
+                : "";
+
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "resource/list.json" + query,
+                ResourceTO[].class, connInstanceId));
+    }
+
+    @Override
+    public ConnObjectTO getConnector(String resourceName, AttributableType type, String objectId) {
+        return restTemplate.getForObject(BASE_URL + "resource/{resourceName}/read/{type}/{objectId}.json",
+                ConnObjectTO.class, resourceName, type, objectId);
+    }
+
+    @Override
+    public boolean check(ResourceTO resourceTO) {
+        return restTemplate.postForObject(BASE_URL + "resource/check.json", resourceTO, Boolean.class)
+                .booleanValue();
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/RoleServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,102 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.mod.RoleMod;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.to.RoleTO;
+import org.apache.syncope.services.RoleService;
+import org.springframework.web.client.RestTemplate;
+
+public class RoleServiceProxy extends SpringServiceProxy implements RoleService {
+
+	public RoleServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		super(baseUrl, restTemplate);
+	}
+
+	@Override
+	public List<RoleTO> children(Long roleId) {
+		return Arrays.asList(restTemplate.getForObject(BASE_URL
+				+ "role/children/{roleId}.json", RoleTO[].class, roleId));
+	}
+
+	@Override
+	public RoleTO create(RoleTO roleTO) {
+		return restTemplate.postForObject(BASE_URL + "role/create", roleTO,
+				RoleTO.class);
+	}
+
+	@Override
+	public RoleTO delete(Long roleId) {
+		return restTemplate.getForObject(BASE_URL + "role/delete/{roleId}",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public List<RoleTO> list() {
+		return Arrays.asList(restTemplate.getForObject(BASE_URL
+				+ "role/list.json", RoleTO[].class));
+	}
+
+	@Override
+	public RoleTO parent(Long roleId) {
+		return restTemplate.getForObject(BASE_URL + "role/parent/{roleId}.json",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public RoleTO read(Long roleId) {
+		return restTemplate.getForObject(BASE_URL + "role/read/{roleId}.json",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public List<RoleTO> search(NodeCond searchCondition) {
+		return Arrays.asList(restTemplate.postForObject(
+				BASE_URL + "role/search", searchCondition, RoleTO[].class));
+	}
+
+	@Override
+	public List<RoleTO> search(NodeCond searchCondition, int page, int size) {
+		return Arrays.asList(restTemplate.postForObject(
+				BASE_URL + "role/search/{page}/{size}", searchCondition, RoleTO[].class, page, size));
+	}
+
+	@Override
+	public int searchCount(NodeCond searchCondition) {
+		return restTemplate.postForObject(BASE_URL + "role/search/count.json",
+				searchCondition, Integer.class);
+	}
+
+	@Override
+	public RoleTO selfRead(Long roleId) {
+		return restTemplate.getForObject(BASE_URL + "role/selfRead/{roleId}",
+				RoleTO.class, roleId);
+	}
+
+	@Override
+	public RoleTO update(Long roleId, RoleMod roleMod) {
+		return restTemplate.postForObject(BASE_URL + "role/update", roleMod,
+				RoleTO.class);
+	}
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.services.proxy;
+
+import org.springframework.web.client.RestTemplate;
+
+public abstract class SpringServiceProxy {
+
+	protected RestTemplate restTemplate;
+
+	protected String BASE_URL; //TODO rename property to baseUrl to match naming conventions
+
+	public SpringServiceProxy(String baseUrl, RestTemplate restTemplate) {
+		this.restTemplate = restTemplate;
+		this.BASE_URL = baseUrl;
+	}
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/TaskServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,140 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.syncope.client.to.SchedTaskTO;
+import org.apache.syncope.client.to.SyncTaskTO;
+import org.apache.syncope.client.to.TaskExecTO;
+import org.apache.syncope.client.to.TaskTO;
+import org.apache.syncope.services.TaskService;
+import org.apache.syncope.types.PropagationTaskExecStatus;
+import org.springframework.web.client.RestTemplate;
+
+public class TaskServiceProxy extends SpringServiceProxy implements TaskService {
+
+    public TaskServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public int count(String kind) {
+        return restTemplate.getForObject(BASE_URL + "task/{kind}/count.json", Integer.class, kind);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends TaskTO> T create(T taskTO) {
+        String subTypeString = (taskTO instanceof SyncTaskTO)
+                ? "sync"
+                : (taskTO instanceof SchedTaskTO)
+                        ? "sched"
+                        : "";
+
+        return (T) restTemplate.postForObject(BASE_URL + "task/create/{type}", taskTO, taskTO.getClass(),
+                subTypeString);
+    }
+
+    @Override
+    public <T extends TaskTO> T delete(Long taskId, Class<T> type) {
+        return restTemplate.getForObject(BASE_URL + "task/delete/{taskId}", type, taskId);
+    }
+
+    @Override
+    public TaskExecTO deleteExecution(Long executionId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public TaskExecTO execute(Long taskId, boolean dryRun) {
+        String param = (dryRun)
+                ? "?dryRun=true"
+                : "";
+        return restTemplate.postForObject(BASE_URL + "task/execute/{taskId}" + param, null, TaskExecTO.class,
+                taskId);
+    }
+
+    @Override
+    public Set<String> getJobClasses() {
+        return new HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL + "task/jobClasses.json",
+                String[].class)));
+    }
+
+    @Override
+    public Set<String> getSyncActionsClasses() {
+        return new HashSet<String>(Arrays.asList(restTemplate.getForObject(BASE_URL
+                + "task/syncActionsClasses.json", String[].class)));
+    }
+
+    @Override
+    public <T extends TaskTO> List<T> list(String kind, Class<T[]> type) {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "task/{kind}/list", type, kind));
+    }
+
+    @Override
+    public <T extends TaskTO> List<T> list(String kind, int page, int size, Class<T[]> type) {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "task/{kind}/list/{page}/{size}.json",
+                type, kind, page, size));
+    }
+
+    @Override
+    public List<TaskExecTO> listExecutions(String kind) {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "task/{kind}/execution/list",
+                TaskExecTO[].class, kind));
+    }
+
+    @Override
+    public <T extends TaskTO> T read(Long taskId, Class<T> type) {
+        return restTemplate.getForObject(BASE_URL + "task/read/{taskId}", type, taskId);
+    }
+
+    @Override
+    public TaskExecTO readExecution(Long executionId) {
+        return restTemplate.getForObject(BASE_URL + "task/execution/read/{taskId}", TaskExecTO.class,
+                executionId);
+    }
+
+    @Override
+    public TaskExecTO report(Long executionId, PropagationTaskExecStatus status, String message) {
+        return restTemplate.getForObject(BASE_URL + "task/execution/report/{executionId}"
+                + "?executionStatus={status}&message={message}", TaskExecTO.class, executionId, status,
+                message);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T extends TaskTO> T update(Long taskId, T taskTO) {
+        String path = (taskTO instanceof SyncTaskTO)
+                ? "sync"
+                : (taskTO instanceof SchedTaskTO)
+                        ? "sched"
+
+                        : null;
+        if (path == null)
+            throw new IllegalArgumentException("Task can only be instance of SchedTaskTO or SyncTaskTO");
+
+        return (T) restTemplate.postForObject(BASE_URL + "task/update/" + path, taskTO, taskTO.getClass());
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/UserServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,187 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.mod.StatusMod;
+import org.apache.syncope.client.mod.UserMod;
+import org.apache.syncope.client.search.NodeCond;
+import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.services.UserService;
+import org.springframework.web.client.RestTemplate;
+
+public class UserServiceProxy extends SpringServiceProxy implements UserService {
+
+    public UserServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public Boolean verifyPassword(String username, String password) {
+        return restTemplate.getForObject(
+                BASE_URL + "user/verifyPassword/{username}.json?password={password}", Boolean.class,
+                username, password);
+    }
+
+    @Override
+    public int count() {
+        return restTemplate.getForObject(BASE_URL + "user/count.json", Integer.class);
+    }
+
+    @Override
+    public List<UserTO> list() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "user/list.json", UserTO[].class));
+    }
+
+    @Override
+    public List<UserTO> list(int page, int size) {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "user/list/{page}/{size}.json",
+                UserTO[].class, page, size));
+    }
+
+    @Override
+    public UserTO read(Long userId) {
+        return restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userId);
+    }
+
+    @Override
+    public UserTO read(String username) {
+        return restTemplate.getForObject(BASE_URL + "user/readByUsername/{username}.json", UserTO.class,
+                username);
+    }
+
+    @Override
+    public UserTO create(UserTO userTO) {
+        return restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+    }
+
+    @Override
+    public UserTO update(Long userId, UserMod userMod) {
+        return restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
+    }
+
+    @Override
+    public UserTO delete(Long userId) {
+        return restTemplate.getForObject(BASE_URL + "user/delete/{userId}", UserTO.class, userId);
+    }
+
+    @Override
+    public UserTO executeWorkflow(String taskId, UserTO userTO) {
+        return null;
+    }
+
+    @Override
+    public List<WorkflowFormTO> getForms() {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "user/workflow/form/list",
+                WorkflowFormTO[].class));
+    }
+
+    @Override
+    public WorkflowFormTO getFormForUser(Long userId) {
+        return restTemplate.getForObject(BASE_URL + "user/workflow/form/{userId}", WorkflowFormTO.class,
+                userId);
+    }
+
+    @Override
+    public WorkflowFormTO claimForm(String taskId) {
+        return restTemplate.getForObject(BASE_URL + "user/workflow/form/claim/{taskId}",
+                WorkflowFormTO.class, taskId);
+    }
+
+    @Override
+    public UserTO submitForm(WorkflowFormTO form) {
+        return restTemplate.postForObject(BASE_URL + "user/workflow/form/submit", form, UserTO.class);
+    }
+
+    @Override
+    public UserTO activate(long userId, String token) {
+        return restTemplate.getForObject(BASE_URL + "user/activate/{userId}?token=" + token, UserTO.class,
+                userId);
+    }
+
+    @Override
+    public UserTO activateByUsername(String username, String token) {
+        return restTemplate.getForObject(BASE_URL + "user/activateByUsername/{username}.json?token=" + token,
+                UserTO.class, username);
+    }
+
+    @Override
+    public UserTO suspend(long userId) {
+        return restTemplate.getForObject(BASE_URL + "user/suspend/{userId}", UserTO.class, userId);
+    }
+
+    @Override
+    public UserTO reactivate(long userId) {
+        return restTemplate.getForObject(BASE_URL + "user/reactivate/{userId}", UserTO.class, userId);
+    }
+
+    @Override
+    public UserTO reactivate(long userId, String query) {
+        return restTemplate.getForObject(BASE_URL + "user/reactivate/" + userId + query, UserTO.class);
+    }
+
+    @Override
+    public UserTO suspendByUsername(String username) {
+        return restTemplate.getForObject(BASE_URL + "user/suspendByUsername/{username}.json", UserTO.class,
+                username);
+    }
+
+    @Override
+    public UserTO reactivateByUsername(String username) {
+        return restTemplate.getForObject(BASE_URL + "user/reactivateByUsername/{username}.json",
+                UserTO.class, username);
+    }
+
+    @Override
+    public UserTO suspend(long userId, String query) {
+        return restTemplate.getForObject(BASE_URL + "user/suspend/" + userId + query, UserTO.class);
+    }
+
+    @Override
+    public UserTO readSelf() {
+        return restTemplate.getForObject(BASE_URL + "user/read/self", UserTO.class);
+    }
+
+    @Override
+    public List<UserTO> search(NodeCond searchCondition) {
+        return Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search", searchCondition,
+                UserTO[].class));
+    }
+
+    @Override
+    public List<UserTO> search(NodeCond searchCondition, int page, int size) {
+        return Arrays.asList(restTemplate.postForObject(BASE_URL + "user/search/{page}/{size}",
+                searchCondition, UserTO[].class, page, size));
+    }
+
+    @Override
+    public int searchCount(NodeCond searchCondition) {
+        return restTemplate
+                .postForObject(BASE_URL + "user/search/count.json", searchCondition, Integer.class);
+    }
+
+    @Override
+    public UserTO setStatus(Long userId, StatusMod statusUpdate) {
+        return null; // Not used in old REST API
+    }
+
+}

Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java?rev=1430170&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/WorkflowServiceProxy.java Tue Jan  8 08:37:35 2013
@@ -0,0 +1,50 @@
+/*
+ * 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.services.proxy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.WorkflowDefinitionTO;
+import org.apache.syncope.services.WorkflowService;
+import org.springframework.web.client.RestTemplate;
+
+public class WorkflowServiceProxy extends SpringServiceProxy implements WorkflowService {
+
+    public WorkflowServiceProxy(String baseUrl, RestTemplate restTemplate) {
+        super(baseUrl, restTemplate);
+    }
+
+    @Override
+    public WorkflowDefinitionTO getDefinition(String type) {
+        return restTemplate
+                .getForObject(BASE_URL + "workflow/definition/" + type, WorkflowDefinitionTO.class);
+    }
+
+    @Override
+    public void updateDefinition(String type, WorkflowDefinitionTO definition) {
+        restTemplate.put(BASE_URL + "workflow/definition/" + type, definition);
+    }
+
+    @Override
+    public List<String> getDefinedTasks(final String type) {
+        return Arrays.asList(restTemplate.getForObject(BASE_URL + "workflow/tasks/" + type, String.class));
+    }
+
+}

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1430170&r1=1430169&r2=1430170&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Tue Jan  8 08:37:35 2013
@@ -25,17 +25,18 @@ import org.apache.http.impl.client.Defau
 import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
 import org.apache.syncope.client.mod.AttributeMod;
 import org.apache.syncope.client.to.AttributeTO;
-import org.apache.syncope.services.ConfigurationServiceProxy;
-import org.apache.syncope.services.ConnectorServiceProxy;
-import org.apache.syncope.services.EntitlementServiceProxy;
-import org.apache.syncope.services.LoggerServiceProxy;
-import org.apache.syncope.services.ReportServiceProxy;
-import org.apache.syncope.services.ResourceServiceProxy;
-import org.apache.syncope.services.RoleServiceProxy;
-import org.apache.syncope.services.TaskServiceProxy;
-import org.apache.syncope.services.UserServiceProxy;
-import org.apache.syncope.services.PolicyServiceProxy;
-import org.apache.syncope.services.WorkflowServiceProxy;
+import org.apache.syncope.services.proxy.ConfigurationServiceProxy;
+import org.apache.syncope.services.proxy.ConnectorServiceProxy;
+import org.apache.syncope.services.proxy.EntitlementServiceProxy;
+import org.apache.syncope.services.proxy.LoggerServiceProxy;
+import org.apache.syncope.services.proxy.NotificationServiceProxy;
+import org.apache.syncope.services.proxy.PolicyServiceProxy;
+import org.apache.syncope.services.proxy.ReportServiceProxy;
+import org.apache.syncope.services.proxy.ResourceServiceProxy;
+import org.apache.syncope.services.proxy.RoleServiceProxy;
+import org.apache.syncope.services.proxy.TaskServiceProxy;
+import org.apache.syncope.services.proxy.UserServiceProxy;
+import org.apache.syncope.services.proxy.WorkflowServiceProxy;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -99,6 +100,8 @@ public abstract class AbstractTest {
 
     protected WorkflowServiceProxy workflowService;
 
+    protected NotificationServiceProxy notificationService;
+
     @Autowired
     protected DataSource testDataSource;
 
@@ -128,5 +131,6 @@ public abstract class AbstractTest {
         taskService = new TaskServiceProxy(BASE_URL, restTemplate);
         policyService = new PolicyServiceProxy(BASE_URL, restTemplate);
         workflowService = new WorkflowServiceProxy(BASE_URL, restTemplate);
+        notificationService = new NotificationServiceProxy(BASE_URL, restTemplate);
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java?rev=1430170&r1=1430169&r2=1430170&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/NotificationTestITCase.java Tue Jan  8 08:37:35 2013
@@ -18,10 +18,13 @@
  */
 package org.apache.syncope.core.rest;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
-import java.util.Arrays;
 import java.util.List;
+
 import org.apache.syncope.client.search.AttributeCond;
 import org.apache.syncope.client.search.MembershipCond;
 import org.apache.syncope.client.search.NodeCond;
@@ -40,16 +43,13 @@ public class NotificationTestITCase exte
 
     @Test
     public void read() {
-        NotificationTO notificationTO = restTemplate.getForObject(BASE_URL + "notification/read/{notificationId}.json",
-                NotificationTO.class, "100");
-
+        NotificationTO notificationTO = notificationService.read(100L);
         assertNotNull(notificationTO);
     }
 
     @Test
     public void list() {
-        List<NotificationTO> notificationTOs = Arrays.asList(restTemplate.getForObject(BASE_URL
-                + "notification/list.json", NotificationTO[].class));
+        List<NotificationTO> notificationTOs = notificationService.list();
         assertNotNull(notificationTOs);
         assertFalse(notificationTOs.isEmpty());
         for (NotificationTO instance : notificationTOs) {
@@ -69,8 +69,8 @@ public class NotificationTestITCase exte
         AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
         fullnameLeafCond2.setSchema("fullname");
         fullnameLeafCond2.setExpression("%i%");
-        NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond.getLeafCond(
-                fullnameLeafCond2));
+        NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1),
+                NodeCond.getLeafCond(fullnameLeafCond2));
 
         notificationTO.setAbout(about);
 
@@ -87,8 +87,7 @@ public class NotificationTestITCase exte
         notificationTO.setSubject("Test notification");
         notificationTO.setTemplate("test");
 
-        NotificationTO actual =
-                restTemplate.postForObject(BASE_URL + "notification/create.json", notificationTO, NotificationTO.class);
+        NotificationTO actual = notificationService.create(notificationTO);
 
         assertNotNull(actual);
         assertNotNull(actual.getId());
@@ -98,15 +97,14 @@ public class NotificationTestITCase exte
 
     @Test
     public void update() {
-        NotificationTO notificationTO = restTemplate.getForObject(BASE_URL + "notification/read/{notificationId}.json",
-                NotificationTO.class, "100");
+        NotificationTO notificationTO = notificationService.read(100L);
         assertNotNull(notificationTO);
 
         notificationTO.setRecipients(NodeCond.getLeafCond(new MembershipCond()));
 
         SyncopeClientException exception = null;
         try {
-            restTemplate.postForObject(BASE_URL + "notification/update.json", notificationTO, NotificationTO.class);
+            notificationService.update(notificationTO.getId(), notificationTO);
         } catch (SyncopeClientCompositeErrorException e) {
             exception = e.getException(SyncopeClientExceptionType.InvalidNotification);
         }
@@ -118,21 +116,19 @@ public class NotificationTestITCase exte
 
         notificationTO.setRecipients(recipients);
 
-        NotificationTO actual = restTemplate.postForObject(BASE_URL + "notification/update.json", notificationTO,
-                NotificationTO.class);
+        NotificationTO actual = notificationService.update(notificationTO.getId(), notificationTO);
         assertNotNull(actual);
         assertEquals(actual, notificationTO);
     }
 
     @Test
     public void delete() {
-        NotificationTO deletedNotification = restTemplate.getForObject(
-                BASE_URL + "notification/delete/{notificationId}.json", NotificationTO.class, "101");
+        NotificationTO deletedNotification = notificationService.delete(101L);
         assertNotNull(deletedNotification);
 
         SyncopeClientException exception = null;
         try {
-            restTemplate.getForObject(BASE_URL + "notification/read/{notificationId}.json", NotificationTO.class, "101");
+            notificationService.read(101L);
         } catch (SyncopeClientCompositeErrorException e) {
             exception = e.getException(SyncopeClientExceptionType.NotFound);
         }
@@ -151,8 +147,8 @@ public class NotificationTestITCase exte
         AttributeCond fullnameLeafCond2 = new AttributeCond(AttributeCond.Type.LIKE);
         fullnameLeafCond2.setSchema("fullname");
         fullnameLeafCond2.setExpression("%i%");
-        NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1), NodeCond.getLeafCond(
-                fullnameLeafCond2));
+        NodeCond about = NodeCond.getAndCond(NodeCond.getLeafCond(fullnameLeafCond1),
+                NodeCond.getLeafCond(fullnameLeafCond2));
 
         notificationTO.setAbout(about);
 
@@ -168,8 +164,7 @@ public class NotificationTestITCase exte
         NotificationTO actual = null;
         SyncopeClientException exception = null;
         try {
-            actual = restTemplate.postForObject(
-                    BASE_URL + "notification/create.json", notificationTO, NotificationTO.class);
+            actual = notificationService.create(notificationTO);
 
         } catch (SyncopeClientCompositeErrorException e) {
             exception = e.getException(SyncopeClientExceptionType.InvalidNotification);



Mime
View raw message