You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/03 16:09:10 UTC
svn commit: r1428391 - in /syncope/trunk:
client/src/main/java/org/apache/syncope/services/
core/src/test/java/org/apache/syncope/core/rest/
Author: jbernhardt
Date: Thu Jan 3 15:09:09 2013
New Revision: 1428391
URL: http://svn.apache.org/viewvc?rev=1428391&view=rev
Log:
[SYNCOPE-259]
Introduces ConnectionService
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java
Modified:
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.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/ConnInstanceTestITCase.java
Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java?rev=1428391&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java Thu Jan 3 15:09:09 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;
+
+import java.util.List;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+
+import org.apache.syncope.client.to.ConnBundleTO;
+import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.types.ConnConfProperty;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Path("connectors")
+public interface ConnectorService {
+
+ @POST
+ ConnInstanceTO create(final ConnInstanceTO connectorTO);
+
+ @PUT
+ @Path("{connectorId}")
+ ConnInstanceTO update(@PathParam("connectorId") final Long connectorId,
+ final ConnInstanceTO connectorTO);
+
+ @DELETE
+ @Path("{connectorId}")
+ ConnInstanceTO delete(@PathParam("connectorId") final Long connectorId);
+
+ @GET
+ List<ConnInstanceTO> list(@QueryParam("lang") final String lang);
+
+ @GET
+ @Path("{connectorId}")
+ ConnInstanceTO read(@PathParam("connectorId") final Long connectorId);
+
+ @GET
+ @Path("bundles")
+ List<ConnBundleTO> getBundles(@QueryParam("lang") final String lang);
+
+ @GET
+ @POST
+ @Path("{connectorId}/schemas")
+ List<String> getSchemaNames(
+ @PathParam("connectorId") final Long connectorId,
+ ConnInstanceTO connectorTO,
+ @QueryParam("showall") @DefaultValue("false") final boolean showall);
+
+ @GET
+ @Path("{connectorId}/configuration")
+ List<ConnConfProperty> getConfigurationProperties(
+ @PathParam("connectorId") final Long connectorId);
+
+ @POST
+ @Path("validate")
+ @RequestMapping(method = RequestMethod.POST, value = "/check")
+ boolean validate(final ConnInstanceTO connectorTO);
+
+ @GET
+ @RequestMapping(method = RequestMethod.GET, value = "/{resourceName}/connectorBean")
+ ConnInstanceTO readConnectorBean(
+ @MatrixParam("resourceName") String resourceName);
+}
\ No newline at end of file
Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java?rev=1428391&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorServiceProxy.java Thu Jan 3 15:09:09 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.ConnBundleTO;
+import org.apache.syncope.client.to.ConnInstanceTO;
+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);
+ }
+
+}
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java?rev=1428391&r1=1428390&r2=1428391&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java Thu Jan 3 15:09:09 2013
@@ -27,10 +27,10 @@ import javax.ws.rs.Path;
public interface EntitlementService {
@GET
- public abstract Set<String> getAllEntitlements();
+ Set<String> getAllEntitlements();
@GET
@Path("own")
- public abstract Set<String> getMyEntitlements();
+ Set<String> getMyEntitlements();
}
\ No newline at end of file
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java?rev=1428391&r1=1428390&r2=1428391&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/SpringServiceProxy.java Thu Jan 3 15:09:09 2013
@@ -24,7 +24,7 @@ public abstract class SpringServiceProxy
protected RestTemplate restTemplate;
- protected String BASE_URL;
+ protected String BASE_URL; //TODO rename property to baseUrl to match naming conventions
public SpringServiceProxy(String baseUrl, RestTemplate restTemplate) {
this.restTemplate = restTemplate;
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java?rev=1428391&r1=1428390&r2=1428391&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/UserService.java Thu Jan 3 15:09:09 2013
@@ -38,151 +38,155 @@ import org.apache.syncope.client.to.Work
@Path("user")
public interface UserService {
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO activate(long userId, String token);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus()}
- */
- @Deprecated
- UserTO activateByUsername(String username, String token);
-
- /**
- * @deprecated This method needs to be moved to a new workflow service.
- */
- @Deprecated
- @POST
- @Path("workflow/task/{taskId}/claim")
- WorkflowFormTO claimForm(@PathParam("taskId") final String taskId);
-
- @GET
- @Path("count")
- int count();
-
- @POST
- @Path("")
- UserTO create(final UserTO userTO);
-
- @DELETE
- @Path("{userId}")
- UserTO delete(@PathParam("userId") final Long userId);
-
- /**
- * @deprecated This method needs to be moved to a new workflow service.
- */
- @Deprecated
- @POST
- UserTO executeWorkflow(@PathParam("taskId") final String taskId,
- final UserTO userTO);
-
- /**
- * @deprecated This method needs to be moved to a new workflow service.
- */
- @Deprecated
- @GET
- @Path("{userId}/workflow/form")
- WorkflowFormTO getFormForUser(@PathParam("userId") final Long userId);
-
- /**
- * @deprecated This method needs to be moved to a new workflow service.
- */
- @Deprecated
- @GET
- @Path("workflow/form")
- List<WorkflowFormTO> getForms();
-
- @GET
- List<UserTO> list();
-
- @GET
- List<UserTO> list(@QueryParam("page") final int page,
- @QueryParam("size") @DefaultValue("25") final int size);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO reactivate(long userId);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO reactivate(long userId, String query);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO reactivateByUsername(String username);
-
- @GET
- @Path("{userId}")
- UserTO read(@PathParam("userId") final Long userId);
-
- @GET
- UserTO read(@MatrixParam("uname") final String username);
-
- /**
- * @deprecated As of release 1.2.0, use {@link #read(Long)} or
- * {@link #read(String)} instead.
- */
- @Deprecated
- UserTO readSelf();
-
- @POST
- @Path("search")
- List<UserTO> search(final NodeCond searchCondition);
-
- @POST
- @Path("search")
- List<UserTO> search(final NodeCond searchCondition,
- @QueryParam("page") final int page,
- @QueryParam("size") @DefaultValue("25") final int size);
-
- @POST
- @Path("search/count")
- int searchCount(final NodeCond searchCondition);
-
-// @POST
-// @Path("user/{userId}/status")
-// public abstract UserTO setStatus(@PathParam("userId") final Long userId,
-// final StatusMod statusUpdate);
-
- /**
- * @deprecated This method needs to be moved to a new workflow service.
- */
- @Deprecated
- @POST
- @Path("workflow/form")
- UserTO submitForm(final WorkflowFormTO form);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO suspend(long userId);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO suspend(long userId, String query);
-
- /**
- * @deprecated As of release 1.2.0, replaced by {@link #setStatus(Long, StatusMod)}
- */
- @Deprecated
- UserTO suspendByUsername(String username);
-
- @POST
- @Path("{userId}")
- UserTO update(@PathParam("userId") final Long userId, final UserMod userMod);
-
- @GET
- Boolean verifyPassword(@MatrixParam("uname") String username,
- @MatrixParam("pwd") final String password);
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO activate(long userId, String token);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO activateByUsername(String username, String token);
+
+ /**
+ * @deprecated This method needs to be moved to a new workflow service.
+ */
+ @Deprecated
+ @POST
+ @Path("workflow/task/{taskId}/claim")
+ WorkflowFormTO claimForm(@PathParam("taskId") final String taskId);
+
+ @GET
+ @Path("count")
+ int count();
+
+ @POST
+ @Path("")
+ UserTO create(final UserTO userTO);
+
+ @DELETE
+ @Path("{userId}")
+ UserTO delete(@PathParam("userId") final Long userId);
+
+ /**
+ * @deprecated This method needs to be moved to a new workflow service.
+ */
+ @Deprecated
+ @POST
+ UserTO executeWorkflow(@PathParam("taskId") final String taskId, final UserTO userTO);
+
+ /**
+ * @deprecated This method needs to be moved to a new workflow service.
+ */
+ @Deprecated
+ @GET
+ @Path("{userId}/workflow/form")
+ WorkflowFormTO getFormForUser(@PathParam("userId") final Long userId);
+
+ /**
+ * @deprecated This method needs to be moved to a new workflow service.
+ */
+ @Deprecated
+ @GET
+ @Path("workflow/form")
+ List<WorkflowFormTO> getForms();
+
+ @GET
+ List<UserTO> list();
+
+ @GET
+ List<UserTO> list(@QueryParam("page") final int page,
+ @QueryParam("size") @DefaultValue("25") final int size);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO reactivate(long userId);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO reactivate(long userId, String query);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO reactivateByUsername(String username);
+
+ @GET
+ @Path("{userId}")
+ UserTO read(@PathParam("userId") final Long userId);
+
+ @GET
+ UserTO read(@MatrixParam("uname") final String username);
+
+ /**
+ * @deprecated As of release 1.2.0, use {@link #read(Long)} or
+ * {@link #read(String)} instead.
+ */
+ @Deprecated
+ UserTO readSelf();
+
+ @POST
+ @Path("search")
+ List<UserTO> search(final NodeCond searchCondition);
+
+ @POST
+ @Path("search")
+ List<UserTO> search(final NodeCond searchCondition, @QueryParam("page") final int page,
+ @QueryParam("size") @DefaultValue("25") final int size);
+
+ @POST
+ @Path("search/count")
+ int searchCount(final NodeCond searchCondition);
+
+ @POST
+ @Path("user/{userId}/status")
+ public abstract UserTO setStatus(@PathParam("userId") final Long userId, final StatusMod statusUpdate);
+
+ /**
+ * @deprecated This method needs to be moved to a new workflow service.
+ */
+ @Deprecated
+ @POST
+ @Path("workflow/form")
+ UserTO submitForm(final WorkflowFormTO form);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO suspend(long userId);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO suspend(long userId, String query);
+
+ /**
+ * @deprecated As of release 1.2.0, replaced by
+ * {@link #setStatus(Long, StatusMod)}
+ */
+ @Deprecated
+ UserTO suspendByUsername(String username);
+
+ @POST
+ @Path("{userId}")
+ UserTO update(@PathParam("userId") final Long userId, final UserMod userMod);
+
+ @GET
+ Boolean verifyPassword(@MatrixParam("uname") String username, @MatrixParam("pwd") final String password);
}
\ No newline at end of file
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java?rev=1428391&r1=1428390&r2=1428391&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/UserServiceProxy.java Thu Jan 3 15:09:09 2013
@@ -29,6 +29,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
+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;
@@ -140,7 +141,7 @@ public class UserServiceProxy extends Sp
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);
@@ -183,4 +184,9 @@ public class UserServiceProxy extends Sp
return restTemplate.postForObject(BASE_URL + "user/search/count.json", searchCondition, Integer.class);
}
+ @Override
+ public UserTO setStatus(Long userId, StatusMod statusUpdate) {
+ return null;
+ }
+
}
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=1428391&r1=1428390&r2=1428391&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 Thu Jan 3 15:09:09 2013
@@ -26,6 +26,7 @@ import org.apache.syncope.client.http.Pr
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.RoleServiceProxy;
import org.apache.syncope.services.UserServiceProxy;
@@ -81,6 +82,8 @@ public abstract class AbstractTest {
protected EntitlementServiceProxy entitlementService;
protected ConfigurationServiceProxy configurationService;
+
+ protected ConnectorServiceProxy connectorService;
@Autowired
protected DataSource testDataSource;
@@ -106,5 +109,6 @@ public abstract class AbstractTest {
roleService = new RoleServiceProxy(BASE_URL, restTemplate);
entitlementService = new EntitlementServiceProxy(BASE_URL, restTemplate);
configurationService = new ConfigurationServiceProxy(BASE_URL, restTemplate);
+ connectorService = new ConnectorServiceProxy(BASE_URL, restTemplate);
}
}
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=1428391&r1=1428390&r2=1428391&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 Thu Jan 3 15:09:09 2013
@@ -81,7 +81,7 @@ public class ConnInstanceTestITCase exte
public void createWithException() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
- restTemplate.postForObject(BASE_URL + "connector/create.json", connectorTO, ConnInstanceTO.class);
+ connectorService.create(connectorTO);
}
@Test
@@ -129,8 +129,7 @@ public class ConnInstanceTestITCase exte
connectorTO.addCapability(ConnectorCapability.ONE_PHASE_CREATE);
connectorTO.addCapability(ConnectorCapability.TWO_PHASES_UPDATE);
- ConnInstanceTO actual = restTemplate.postForObject(BASE_URL + "connector/create.json", connectorTO,
- ConnInstanceTO.class);
+ ConnInstanceTO actual = connectorService.create(connectorTO);
assertNotNull(actual);
@@ -148,7 +147,7 @@ public class ConnInstanceTestITCase exte
connectorTO.removeCapability(ConnectorCapability.TWO_PHASES_UPDATE);
actual = null;
try {
- actual = restTemplate.postForObject(BASE_URL + "connector/update.json", connectorTO, ConnInstanceTO.class);
+ actual = connectorService.update(connectorTO.getId(), connectorTO);
} catch (HttpStatusCodeException e) {
LOG.error("update failed", e);
t = e;
@@ -160,10 +159,7 @@ public class ConnInstanceTestITCase exte
// check also for the deletion of the created object
try {
- ConnInstanceTO deletedConn = restTemplate.getForObject(
- BASE_URL + "connector/delete/{connectorId}.json",
- ConnInstanceTO.class,
- String.valueOf(actual.getId()));
+ ConnInstanceTO deletedConn = connectorService.delete(actual.getId());
assertNotNull(deletedConn);
} catch (HttpStatusCodeException e) {
LOG.error("delete failed", e);
@@ -174,8 +170,7 @@ public class ConnInstanceTestITCase exte
// check the non existence
try {
- restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}", ConnInstanceTO.class,
- String.valueOf(actual.getId()));
+ connectorService.read(actual.getId());
} catch (HttpStatusCodeException e) {
assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
}
@@ -222,13 +217,11 @@ public class ConnInstanceTestITCase exte
// set connector configuration
connectorTO.setConfiguration(conf);
- ConnInstanceTO actual = (ConnInstanceTO) restTemplate.postForObject(BASE_URL + "connector/update.json",
- connectorTO, ConnInstanceTO.class);
+ ConnInstanceTO actual = connectorService.update(connectorTO.getId(), connectorTO);
assertNotNull(actual);
- actual = restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}", ConnInstanceTO.class, String.
- valueOf(actual.getId()));
+ actual = connectorService.read(actual.getId());
assertNotNull(actual);
assertEquals(actual.getBundleName(), connectorTO.getBundleName());
@@ -242,8 +235,7 @@ public class ConnInstanceTestITCase exte
// Copy resource and connector in order to create new objects.
// ----------------------------------
// Retrieve a connector instance template.
- ConnInstanceTO connInstanceTO =
- restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}", ConnInstanceTO.class, 103L);
+ ConnInstanceTO connInstanceTO = connectorService.read(103L);
assertNotNull(connInstanceTO);
@@ -267,8 +259,7 @@ public class ConnInstanceTestITCase exte
// ----------------------------------
// Create a new connector instance.
// ----------------------------------
- connInstanceTO =
- restTemplate.postForObject(BASE_URL + "connector/create.json", connInstanceTO, ConnInstanceTO.class);
+ connInstanceTO = connectorService.create(connInstanceTO);
assertNotNull(connInstanceTO);
assertTrue(connInstanceTO.getCapabilities().isEmpty());
@@ -282,12 +273,13 @@ public class ConnInstanceTestITCase exte
// ----------------------------------
// Check for connector instance update after resource creation.
// ----------------------------------
- resourceTO = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);
+ resourceTO = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO,
+ ResourceTO.class);
assertNotNull(resourceTO);
- resources = Arrays.asList(restTemplate.getForObject(BASE_URL + "resource/list.json?connInstanceId=" + connId,
- ResourceTO[].class));
+ resources = Arrays.asList(restTemplate.getForObject(BASE_URL + "resource/list.json?connInstanceId="
+ + connId, ResourceTO[].class));
assertEquals(1, resources.size());
// ----------------------------------
@@ -295,8 +287,7 @@ public class ConnInstanceTestITCase exte
// ----------------------------------
// Check for spring bean.
// ----------------------------------
- ConnInstanceTO connInstanceBean = restTemplate.getForObject(
- BASE_URL + "connector/{resourceName}/connectorBean", ConnInstanceTO.class, resourceTO.getName());
+ ConnInstanceTO connInstanceBean = connectorService.readConnectorBean(resourceTO.getName());
assertNotNull(connInstanceBean);
assertTrue(connInstanceBean.getCapabilities().isEmpty());
@@ -307,15 +298,13 @@ public class ConnInstanceTestITCase exte
// ----------------------------------
connInstanceTO.addCapability(ConnectorCapability.SEARCH);
- ConnInstanceTO actual = (ConnInstanceTO) restTemplate.postForObject(BASE_URL + "connector/update.json",
- connInstanceTO, ConnInstanceTO.class);
+ ConnInstanceTO actual = connectorService.update(connInstanceTO.getId(), connInstanceTO);
assertNotNull(actual);
assertFalse(connInstanceTO.getCapabilities().isEmpty());
// check for spring bean update
- connInstanceBean = restTemplate.getForObject(BASE_URL + "connector/{resourceName}/connectorBean",
- ConnInstanceTO.class, resourceTO.getName());
+ connInstanceBean = connectorService.readConnectorBean(resourceTO.getName());
assertFalse(connInstanceBean.getCapabilities().isEmpty());
// ----------------------------------
@@ -324,8 +313,7 @@ public class ConnInstanceTestITCase exte
@Test
public void deleteWithException() {
try {
- restTemplate.getForObject(
- BASE_URL + "connector/delete/{connectorId}.json", ConnInstanceTO.class, "0");
+ connectorService.delete(0L);
} catch (HttpStatusCodeException e) {
assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
}
@@ -333,8 +321,7 @@ public class ConnInstanceTestITCase exte
@Test
public void list() {
- List<ConnInstanceTO> connectorInstanceTOs = Arrays.asList(restTemplate.getForObject(BASE_URL
- + "connector/list.json", ConnInstanceTO[].class));
+ List<ConnInstanceTO> connectorInstanceTOs = connectorService.list(null);
assertNotNull(connectorInstanceTOs);
assertFalse(connectorInstanceTOs.isEmpty());
for (ConnInstanceTO instance : connectorInstanceTOs) {
@@ -344,16 +331,14 @@ public class ConnInstanceTestITCase exte
@Test
public void read() {
- ConnInstanceTO connectorInstanceTO = restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}.json",
- ConnInstanceTO.class, "100");
+ ConnInstanceTO connectorInstanceTO = connectorService.read(100L);
assertNotNull(connectorInstanceTO);
}
@Test
public void getBundles() {
- List<ConnBundleTO> bundles = Arrays.asList(restTemplate.getForObject(BASE_URL + "connector/bundle/list",
- ConnBundleTO[].class));
+ List<ConnBundleTO> bundles = connectorService.getBundles(null);
assertNotNull(bundles);
assertFalse(bundles.isEmpty());
for (ConnBundleTO bundle : bundles) {
@@ -363,16 +348,14 @@ public class ConnInstanceTestITCase exte
@Test
public void getConnectorConfiguration() {
- List<ConnConfProperty> props = Arrays.asList(restTemplate.getForObject(BASE_URL
- + "connector/{connectorId}/configurationProperty/list", ConnConfProperty[].class, 104));
+ List<ConnConfProperty> props = connectorService.getConfigurationProperties(104L);
assertNotNull(props);
assertFalse(props.isEmpty());
}
@Test
public void checkHiddenProperty() {
- ConnInstanceTO connInstanceTO = restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}.json",
- ConnInstanceTO.class, "100");
+ ConnInstanceTO connInstanceTO = connectorService.read(100L);
boolean check = false;
@@ -387,8 +370,7 @@ public class ConnInstanceTestITCase exte
@Test
public void checkSelectedLanguage() {
// 1. Check Italian
- List<ConnInstanceTO> connectorInstanceTOs = Arrays.asList(restTemplate.getForObject(BASE_URL
- + "connector/list.json?lang=it", ConnInstanceTO[].class));
+ List<ConnInstanceTO> connectorInstanceTOs = connectorService.list("it");
Map<String, ConnConfProperty> instanceConfMap;
for (ConnInstanceTO instance : connectorInstanceTOs) {
@@ -400,8 +382,7 @@ public class ConnInstanceTestITCase exte
}
// 2. Check English (default)
- connectorInstanceTOs = Arrays.asList(restTemplate.getForObject(BASE_URL + "connector/list.json",
- ConnInstanceTO[].class));
+ connectorInstanceTOs = connectorService.list(null);
for (ConnInstanceTO instance : connectorInstanceTOs) {
if ("org.connid.bundles.db.table".equals(instance.getBundleName())) {
@@ -413,7 +394,7 @@ public class ConnInstanceTestITCase exte
}
@Test
- public void check() {
+ public void validate() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
@@ -498,7 +479,7 @@ public class ConnInstanceTestITCase exte
// set connector configuration
connectorTO.setConfiguration(conf);
- Boolean verify = restTemplate.postForObject(BASE_URL + "connector/check.json", connectorTO, Boolean.class);
+ Boolean verify = connectorService.validate(connectorTO);
assertTrue(verify);
@@ -506,33 +487,30 @@ public class ConnInstanceTestITCase exte
password.setValues(Collections.singletonList("password"));
conf.add(password);
- verify = restTemplate.postForObject(BASE_URL + "connector/check.json", connectorTO, Boolean.class);
+ verify = connectorService.validate(connectorTO);
assertFalse(verify);
}
@Test
public void getSchemaNames() {
- ConnInstanceTO conn = restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}.json",
- ConnInstanceTO.class, "101");
+ ConnInstanceTO conn = connectorService.read(101L);
- List<String> schemaNames = Arrays.asList(restTemplate.postForObject(BASE_URL
- + "connector/schema/list?showall=true", conn, String[].class));
+ List<String> schemaNames = connectorService.getSchemaNames(conn.getId(), conn, true);
assertNotNull(schemaNames);
assertFalse(schemaNames.isEmpty());
- schemaNames = Arrays.
- asList(restTemplate.postForObject(BASE_URL + "connector/schema/list", conn, String[].class));
+ schemaNames = connectorService.getSchemaNames(conn.getId(), conn, false);
+
assertNotNull(schemaNames);
assertEquals(0, schemaNames.size());
- conn = restTemplate.getForObject(BASE_URL + "connector/read/{connectorId}.json", ConnInstanceTO.class, "104");
+ conn = connectorService.read(104L);
// to be used with overridden properties
conn.getConfiguration().clear();
- schemaNames = Arrays.asList(restTemplate.postForObject(BASE_URL + "connector//schema/list?showall=true", conn,
- String[].class, conn));
+ schemaNames = connectorService.getSchemaNames(conn.getId(), conn, true);
assertNotNull(schemaNames);
assertFalse(schemaNames.isEmpty());
}
@@ -575,8 +553,8 @@ public class ConnInstanceTestITCase exte
keyColumnSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(keyColumnSchema);
- servicename.setValues(
- Collections.singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
+ servicename.setValues(Collections
+ .singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
servicename.setOverridable(false);
conf.add(endpoint);
@@ -585,9 +563,9 @@ public class ConnInstanceTestITCase exte
// set connector configuration
connectorTO.setConfiguration(conf);
- assertFalse(restTemplate.postForObject(BASE_URL + "connector/check.json", connectorTO, Boolean.class));
+ assertFalse(connectorService.validate(connectorTO));
- connectorTO = restTemplate.postForObject(BASE_URL + "connector/create.json", connectorTO, ConnInstanceTO.class);
+ connectorTO = connectorService.create(connectorTO);
assertNotNull(connectorTO);
// ----------------------------------------