Author: jbernhardt
Date: Sat Jan 19 09:30:44 2013
New Revision: 1435513

URL: http://svn.apache.org/viewvc?rev=1435513&view=rev
Log:
[SYNCOPE-231]
Added ConnectorService implementation
Adding JAX-B Annotations for related TOs
Code cleanup (according to checkstyle and PMD)

Added:
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConnectorServiceImpl.java
Modified:
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/AbstractSchemaTO.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnBundleTO.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnInstanceTO.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/SchemaTO.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfPropSchema.java
    
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfProperty.java
    
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/ConnectorFacadeProxy.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java
    
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
    syncope/trunk/core/src/main/resources/restContext.xml
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java
    
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/AbstractSchemaTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/AbstractSchemaTO.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/AbstractSchemaTO.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/AbstractSchemaTO.java
 Sat Jan 19 09:30:44 2013
@@ -18,8 +18,11 @@
  */
 package org.apache.syncope.client.to;
 
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.client.AbstractBaseBean;
 
+@XmlType
 public abstract class AbstractSchemaTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 4088388951694301759L;
@@ -30,7 +33,7 @@ public abstract class AbstractSchemaTO e
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnBundleTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnBundleTO.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnBundleTO.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnBundleTO.java
 Sat Jan 19 09:30:44 2013
@@ -20,9 +20,17 @@ package org.apache.syncope.client.to;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.client.AbstractBaseBean;
 import org.apache.syncope.types.ConnConfPropSchema;
 
+@XmlRootElement(name = "connectorBundle")
+@XmlType
 public class ConnBundleTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 7215115961910138005L;
@@ -35,17 +43,13 @@ public class ConnBundleTO extends Abstra
 
     private String connectorName;
 
-    private List<ConnConfPropSchema> properties;
-
-    public ConnBundleTO() {
-        properties = new ArrayList<ConnConfPropSchema>();
-    }
+    private List<ConnConfPropSchema> properties = new 
ArrayList<ConnConfPropSchema>();
 
     public String getBundleName() {
         return bundleName;
     }
 
-    public void setBundleName(String bundleName) {
+    public void setBundleName(final String bundleName) {
         this.bundleName = bundleName;
     }
 
@@ -53,7 +57,7 @@ public class ConnBundleTO extends Abstra
         return connectorName;
     }
 
-    public void setConnectorName(String connectorName) {
+    public void setConnectorName(final String connectorName) {
         this.connectorName = connectorName;
     }
 
@@ -61,23 +65,25 @@ public class ConnBundleTO extends Abstra
         return displayName;
     }
 
-    public void setDisplayName(String displayName) {
+    public void setDisplayName(final String displayName) {
         this.displayName = displayName;
     }
 
+    @XmlElementWrapper(name = "properties")
+    @XmlElement(name = "connConfPropSchema")
     public List<ConnConfPropSchema> getProperties() {
         return properties;
     }
 
-    public void setProperties(List<ConnConfPropSchema> properties) {
+    public void setProperties(final List<ConnConfPropSchema> properties) {
         this.properties = properties;
     }
 
-    public boolean addProperty(ConnConfPropSchema property) {
+    public boolean addProperty(final ConnConfPropSchema property) {
         return properties.add(property);
     }
 
-    public boolean removeProperty(ConnConfPropSchema property) {
+    public boolean removeProperty(final ConnConfPropSchema property) {
         return properties.remove(property);
     }
 
@@ -85,7 +91,7 @@ public class ConnBundleTO extends Abstra
         return version;
     }
 
-    public void setVersion(String version) {
+    public void setVersion(final String version) {
         this.version = version;
     }
 }

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnInstanceTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnInstanceTO.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnInstanceTO.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConnInstanceTO.java
 Sat Jan 19 09:30:44 2013
@@ -24,11 +24,19 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.codehaus.jackson.annotate.JsonIgnore;
 import org.apache.syncope.client.AbstractBaseBean;
 import org.apache.syncope.types.ConnConfProperty;
 import org.apache.syncope.types.ConnectorCapability;
 
+@XmlRootElement(name = "connector")
+@XmlType
 public class ConnInstanceTO extends AbstractBaseBean {
 
     private static final long serialVersionUID = 2707778645445168671L;
@@ -41,9 +49,9 @@ public class ConnInstanceTO extends Abst
 
     private String connectorName;
 
-    private Set<ConnConfProperty> configuration;
+    private final Set<ConnConfProperty> configuration;
 
-    private Set<ConnectorCapability> capabilities;
+    private final Set<ConnectorCapability> capabilities;
 
     private String displayName;
 
@@ -78,6 +86,8 @@ public class ConnInstanceTO extends Abst
         this.version = bundleversion;
     }
 
+    @XmlElementWrapper(name = "configuration")
+    @XmlElement(name = "property")
     public Set<ConnConfProperty> getConfiguration() {
         return this.configuration;
     }
@@ -130,6 +140,8 @@ public class ConnInstanceTO extends Abst
         return capabilities.remove(capability);
     }
 
+    @XmlElementWrapper(name = "capabilities")
+    @XmlElement(name = "capability")
     public Set<ConnectorCapability> getCapabilities() {
         return capabilities;
     }

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/SchemaTO.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/SchemaTO.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/SchemaTO.java 
(original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/SchemaTO.java 
Sat Jan 19 09:30:44 2013
@@ -18,14 +18,19 @@
  */
 package org.apache.syncope.client.to;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.syncope.types.SchemaType;
 
+@XmlRootElement(name = "schema")
+@XmlType
 public class SchemaTO extends AbstractSchemaTO {
 
     private static final long serialVersionUID = -8133983392476990308L;
 
-    private SchemaType type;
+    private SchemaType type = SchemaType.String;
 
     private String mandatoryCondition;
 
@@ -43,15 +48,11 @@ public class SchemaTO extends AbstractSc
 
     private String validatorClass;
 
-    public SchemaTO() {
-        type = SchemaType.String;
-    }
-
     public String getConversionPattern() {
         return conversionPattern;
     }
 
-    public void setConversionPattern(String conversionPattern) {
+    public void setConversionPattern(final String conversionPattern) {
         this.conversionPattern = conversionPattern;
     }
 
@@ -61,7 +62,7 @@ public class SchemaTO extends AbstractSc
                 : "false";
     }
 
-    public void setMandatoryCondition(String mandatoryCondition) {
+    public void setMandatoryCondition(final String mandatoryCondition) {
         this.mandatoryCondition = mandatoryCondition;
     }
 
@@ -69,7 +70,7 @@ public class SchemaTO extends AbstractSc
         return enumerationValues;
     }
 
-    public void setEnumerationValues(String enumerationValues) {
+    public void setEnumerationValues(final String enumerationValues) {
         this.enumerationValues = enumerationValues;
     }
 
@@ -77,7 +78,7 @@ public class SchemaTO extends AbstractSc
         return enumerationKeys;
     }
 
-    public void setEnumerationKeys(String enumerationKeys) {
+    public void setEnumerationKeys(final String enumerationKeys) {
         this.enumerationKeys = enumerationKeys;
     }
 
@@ -85,7 +86,7 @@ public class SchemaTO extends AbstractSc
         return multivalue;
     }
 
-    public void setMultivalue(boolean multivalue) {
+    public void setMultivalue(final boolean multivalue) {
         this.multivalue = multivalue;
     }
 
@@ -93,7 +94,7 @@ public class SchemaTO extends AbstractSc
         return uniqueConstraint;
     }
 
-    public void setUniqueConstraint(boolean uniqueConstraint) {
+    public void setUniqueConstraint(final boolean uniqueConstraint) {
         this.uniqueConstraint = uniqueConstraint;
     }
 
@@ -101,7 +102,7 @@ public class SchemaTO extends AbstractSc
         return readonly;
     }
 
-    public void setReadonly(boolean readonly) {
+    public void setReadonly(final boolean readonly) {
         this.readonly = readonly;
     }
 
@@ -109,7 +110,7 @@ public class SchemaTO extends AbstractSc
         return type;
     }
 
-    public void setType(SchemaType type) {
+    public void setType(final SchemaType type) {
         this.type = type;
     }
 
@@ -117,7 +118,7 @@ public class SchemaTO extends AbstractSc
         return validatorClass;
     }
 
-    public void setValidatorClass(String validatorClass) {
+    public void setValidatorClass(final String validatorClass) {
         this.validatorClass = validatorClass;
     }
 }

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
 Sat Jan 19 09:30:44 2013
@@ -27,8 +27,6 @@ import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import org.apache.syncope.client.to.ConfigurationTO;
@@ -42,7 +40,7 @@ public interface ConfigurationService {
     Response create(ConfigurationTO configurationTO);
 
     @GET
-    @Produces(MediaType.APPLICATION_OCTET_STREAM)
+    @Path("dbDump")
     Response dbExport();
 
     @DELETE

Modified: 
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=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConnectorService.java
 Sat Jan 19 09:30:44 2013
@@ -28,8 +28,11 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
 import org.apache.syncope.client.to.ConnBundleTO;
 import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.client.to.SchemaTO;
 import org.apache.syncope.types.ConnConfProperty;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -38,11 +41,11 @@ import org.springframework.web.bind.anno
 public interface ConnectorService {
 
     @POST
-    ConnInstanceTO create(ConnInstanceTO connectorTO);
+    Response create(ConnInstanceTO connectorTO);
 
     @DELETE
     @Path("{connectorId}")
-    ConnInstanceTO delete(@PathParam("connectorId") Long connectorId);
+    void delete(@PathParam("connectorId") Long connectorId);
 
     @GET
     @Path("bundles")
@@ -53,10 +56,9 @@ public interface ConnectorService {
     List<ConnConfProperty> getConfigurationProperties(
             @PathParam("connectorId") Long connectorId);
 
-    @GET
     @POST
     @Path("{connectorId}/schemas")
-    List<String> getSchemaNames(
+    List<SchemaTO> getSchemaNames(
             @PathParam("connectorId") Long connectorId,
             ConnInstanceTO connectorTO,
             @QueryParam("showall") @DefaultValue("false") boolean showall);
@@ -75,7 +77,7 @@ public interface ConnectorService {
 
     @PUT
     @Path("{connectorId}")
-    ConnInstanceTO update(@PathParam("connectorId") Long connectorId,
+    void update(@PathParam("connectorId") Long connectorId,
             ConnInstanceTO connectorTO);
 
     @POST

Modified: 
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=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConnectorServiceProxy.java
 Sat Jan 19 09:30:44 2013
@@ -18,10 +18,16 @@
  */
 package org.apache.syncope.services.proxy;
 
+import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+
+import javax.ws.rs.core.Response;
+
 import org.apache.syncope.client.to.ConnBundleTO;
 import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.client.to.SchemaTO;
 import org.apache.syncope.services.ConnectorService;
 import org.apache.syncope.types.ConnConfProperty;
 import org.springframework.web.client.RestTemplate;
@@ -33,28 +39,29 @@ public class ConnectorServiceProxy exten
     }
 
     @Override
-    public ConnInstanceTO create(final ConnInstanceTO connectorTO) {
-        return getRestTemplate().postForObject(baseUrl + 
"connector/create.json", connectorTO,
+    public Response create(final ConnInstanceTO connectorTO) {
+        ConnInstanceTO response = getRestTemplate().postForObject(baseUrl + 
"connector/create.json", connectorTO,
                 ConnInstanceTO.class);
+        URI location = URI.create(baseUrl + "connector/read" + 
response.getId());
+        return Response.created(location).entity(response).build();
     }
 
     @Override
-    public ConnInstanceTO update(final Long connectorId, final ConnInstanceTO 
connectorTO) {
-        return getRestTemplate().postForObject(baseUrl + 
"connector/update.json", connectorTO,
-                ConnInstanceTO.class);
+    public void update(final Long connectorId, final ConnInstanceTO 
connectorTO) {
+        getRestTemplate().postForObject(baseUrl + "connector/update.json", 
connectorTO, ConnInstanceTO.class);
     }
 
     @Override
-    public ConnInstanceTO delete(final Long connectorId) {
-        return getRestTemplate().getForObject(baseUrl + 
"connector/delete/{connectorId}.json",
-                ConnInstanceTO.class, connectorId);
+    public void delete(final Long connectorId) {
+        getRestTemplate().getForObject(baseUrl + 
"connector/delete/{connectorId}.json", ConnInstanceTO.class,
+                connectorId);
     }
 
     @Override
     public List<ConnInstanceTO> list(final String lang) {
-        String param = (lang != null)
-                ? "?lang=" + lang
-                : "";
+        String param = (lang == null)
+                ? ""
+                : "?lang=" + lang;
 
         return Arrays.asList(getRestTemplate().getForObject(baseUrl + 
"connector/list.json" + param,
                 ConnInstanceTO[].class));
@@ -68,28 +75,34 @@ public class ConnectorServiceProxy exten
 
     @Override
     public List<ConnBundleTO> getBundles(final String lang) {
-        String param = (lang != null)
-                ? "?lang=" + lang
-                : "";
+        String param = (lang == null)
+                ? ""
+                : "?lang=" + lang;
 
         return Arrays.asList(getRestTemplate().getForObject(baseUrl + 
"connector/bundle/list.json" + param,
                 ConnBundleTO[].class));
     }
 
     @Override
-    public List<String> getSchemaNames(final Long connectorId, final 
ConnInstanceTO connectorTO, boolean showall) {
-        final String queryString = "?showall=" + String.valueOf(showall);
-
-        return Arrays.asList(getRestTemplate().postForObject(baseUrl + 
"connector/schema/list" + queryString,
-                connectorTO,
-                String[].class));
+    public List<SchemaTO> getSchemaNames(final Long connectorId, final 
ConnInstanceTO connectorTO,
+            final boolean showall) {
+        final String queryString = "?showall=" + showall;
+
+        List<String> response = Arrays.asList(getRestTemplate().postForObject(
+                baseUrl + "connector/schema/list" + queryString, connectorTO, 
String[].class));
+        List<SchemaTO> schemaNames = new ArrayList<SchemaTO>();
+        for (String name : response) {
+            SchemaTO schemaTO = new SchemaTO();
+            schemaTO.setName(name);
+            schemaNames.add(schemaTO);
+        }
+        return schemaNames;
     }
 
     @Override
     public List<ConnConfProperty> getConfigurationProperties(final Long 
connectorId) {
-        return Arrays.asList(getRestTemplate()
-                .getForObject(baseUrl + 
"connector/{connectorId}/configurationProperty/list",
-                ConnConfProperty[].class, connectorId));
+        return Arrays.asList(getRestTemplate().getForObject(
+                baseUrl + 
"connector/{connectorId}/configurationProperty/list", ConnConfProperty[].class, 
connectorId));
     }
 
     @Override
@@ -99,7 +112,7 @@ public class ConnectorServiceProxy exten
 
     @Override
     public ConnInstanceTO readConnectorBean(final String resourceName) {
-        return getRestTemplate().getForObject(baseUrl + 
"connector/{resourceName}/connectorBean",
-                ConnInstanceTO.class, resourceName);
+        return getRestTemplate().getForObject(baseUrl + 
"connector/{resourceName}/connectorBean", ConnInstanceTO.class,
+                resourceName);
     }
 }

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfPropSchema.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfPropSchema.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfPropSchema.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfPropSchema.java
 Sat Jan 19 09:30:44 2013
@@ -18,8 +18,13 @@
  */
 package org.apache.syncope.types;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.client.AbstractBaseBean;
 
+@XmlRootElement
+@XmlType
 public class ConnConfPropSchema extends AbstractBaseBean implements 
Comparable<ConnConfPropSchema> {
 
     private static final long serialVersionUID = -1976365781005801296L;
@@ -42,7 +47,7 @@ public class ConnConfPropSchema extends 
         return name;
     }
 
-    public void setName(String name) {
+    public void setName(final String name) {
         this.name = name;
     }
 
@@ -50,7 +55,7 @@ public class ConnConfPropSchema extends 
         return required;
     }
 
-    public void setRequired(boolean required) {
+    public void setRequired(final boolean required) {
         this.required = required;
     }
 
@@ -58,7 +63,7 @@ public class ConnConfPropSchema extends 
         return type;
     }
 
-    public void setType(String type) {
+    public void setType(final String type) {
         this.type = type;
     }
 
@@ -66,7 +71,7 @@ public class ConnConfPropSchema extends 
         return displayName;
     }
 
-    public void setDisplayName(String displayName) {
+    public void setDisplayName(final String displayName) {
         this.displayName = displayName;
     }
 
@@ -74,7 +79,7 @@ public class ConnConfPropSchema extends 
         return helpMessage;
     }
 
-    public void setHelpMessage(String helpMessage) {
+    public void setHelpMessage(final String helpMessage) {
         this.helpMessage = helpMessage;
     }
 
@@ -82,7 +87,7 @@ public class ConnConfPropSchema extends 
         return order;
     }
 
-    public void setOrder(int order) {
+    public void setOrder(final int order) {
         this.order = order;
     }
 
@@ -90,7 +95,7 @@ public class ConnConfPropSchema extends 
         return confidential;
     }
 
-    public void setConfidential(boolean confidential) {
+    public void setConfidential(final boolean confidential) {
         this.confidential = confidential;
     }
 

Modified: 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfProperty.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfProperty.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfProperty.java
 (original)
+++ 
syncope/trunk/client/src/main/java/org/apache/syncope/types/ConnConfProperty.java
 Sat Jan 19 09:30:44 2013
@@ -20,15 +20,23 @@ package org.apache.syncope.types;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
 import org.apache.syncope.client.AbstractBaseBean;
 
+@XmlRootElement
+@XmlType
 public class ConnConfProperty extends AbstractBaseBean implements 
Comparable<ConnConfProperty> {
 
     private static final long serialVersionUID = -8391413960221862238L;
 
     private ConnConfPropSchema schema;
 
-    private List values;
+    private List<?> values = new ArrayList<Object>();
 
     private boolean overridable;
 
@@ -36,18 +44,17 @@ public class ConnConfProperty extends Ab
         return schema;
     }
 
-    public void setSchema(ConnConfPropSchema schema) {
+    public void setSchema(final ConnConfPropSchema schema) {
         this.schema = schema;
     }
 
-    public List getValues() {
-        if (values == null) {
-            values = new ArrayList();
-        }
+    @XmlElementWrapper(name = "values")
+    @XmlElement(name = "value")
+    public List<?> getValues() {
         return values;
     }
 
-    public void setValues(final List values) {
+    public void setValues(final List<?> values) {
         this.values = values;
     }
 
@@ -55,7 +62,7 @@ public class ConnConfProperty extends Ab
         return overridable;
     }
 
-    public void setOverridable(boolean overridable) {
+    public void setOverridable(final boolean overridable) {
         this.overridable = overridable;
     }
 

Modified: 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
 (original)
+++ 
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java
 Sat Jan 19 09:30:44 2013
@@ -27,6 +27,7 @@ import java.util.Set;
 import org.apache.syncope.client.to.ConnBundleTO;
 import org.apache.syncope.client.to.ConnInstanceTO;
 import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.client.to.SchemaTO;
 import 
org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.console.SyncopeSession;
 import org.apache.syncope.services.ConnectorService;
@@ -86,7 +87,9 @@ public class ConnectorRestClient extends
     }
 
     public ConnInstanceTO delete(Long id) {
-        return getService(ConnectorService.class).delete(id);
+        ConnInstanceTO instanceTO = 
getService(ConnectorService.class).read(id);
+        getService(ConnectorService.class).delete(id);
+        return instanceTO;
     }
 
     public List<ConnBundleTO> getAllBundles() {
@@ -179,17 +182,19 @@ public class ConnectorRestClient extends
     }
 
     public List<String> getSchemaNames(final ConnInstanceTO connectorTO) {
-        List<String> schemaNames = null;
-
+        List<String> schemaNames = new ArrayList<String>();
         try {
-            schemaNames = 
getService(ConnectorService.class).getSchemaNames(connectorTO.getId(), 
connectorTO, false);
-
+            List<SchemaTO> response = 
getService(ConnectorService.class).getSchemaNames(connectorTO.getId(),
+                    connectorTO, false);
+            for (SchemaTO schema : response) {
+                schemaNames.add(schema.getName());
+            }
             // re-order schema names list
             Collections.sort(schemaNames);
         } catch (Exception e) {
             LOG.error("While getting resource schema names", e);
+            schemaNames = null;
         }
-
         return schemaNames;
     }
 }

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/ConnectorFacadeProxy.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/ConnectorFacadeProxy.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/ConnectorFacadeProxy.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/propagation/impl/ConnectorFacadeProxy.java
 Sat Jan 19 09:30:44 2013
@@ -484,11 +484,11 @@ public class ConnectorFacadeProxy implem
         return oob.build();
     }
 
-    private Object getPropertyValue(final String propType, final List<Object> 
values) {
+    private Object getPropertyValue(final String propType, final List<?> 
values) {
         Object value = null;
 
         try {
-            final Class propertySchemaClass = ClassUtils.forName(propType, 
ClassUtils.getDefaultClassLoader());
+            final Class<?> propertySchemaClass = ClassUtils.forName(propType, 
ClassUtils.getDefaultClassLoader());
 
             if (GuardedString.class.equals(propertySchemaClass)) {
                 value = new 
GuardedString(values.get(0).toString().toCharArray());

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java
 Sat Jan 19 09:30:44 2013
@@ -326,7 +326,7 @@ public class ConnInstanceController exte
         final Set<ConnConfProperty> conf = 
mergeConnConfProperties(connectorTO.getConfiguration(),
                 connInstance.getConfiguration());
 
-        // We cannot use Spring bean because this method could be used during 
resource definition or modification: 
+        // We cannot use Spring bean because this method could be used during 
resource definition or modification:
         // bean couldn't exist or couldn't be updated.
         // This is the reason why we should take a "not mature" connector 
facade proxy to ask for schema names.
         final List<String> result = new 
ArrayList<String>(connLoader.createConnectorBean(connInstance, conf).

Modified: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
 (original)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConfigurationServiceImpl.java
 Sat Jan 19 09:30:44 2013
@@ -41,6 +41,7 @@ public class ConfigurationServiceImpl im
 
     @Autowired
     private ConfigurationController configurationController;
+
     private UriInfo uriInfo;
 
     @Override

Added: 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConnectorServiceImpl.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConnectorServiceImpl.java?rev=1435513&view=auto
==============================================================================
--- 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConnectorServiceImpl.java
 (added)
+++ 
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/impl/ConnectorServiceImpl.java
 Sat Jan 19 09:30:44 2013
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.syncope.client.to.ConnBundleTO;
+import org.apache.syncope.client.to.ConnInstanceTO;
+import org.apache.syncope.client.to.SchemaTO;
+import 
org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
+import org.apache.syncope.core.rest.controller.ConnInstanceController;
+import org.apache.syncope.core.util.NotFoundException;
+import org.apache.syncope.services.ConnectorService;
+import org.apache.syncope.types.ConnConfProperty;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ConnectorServiceImpl implements ConnectorService, ContextAware {
+
+    @Autowired
+    private ConnInstanceController connectorController;
+
+    private UriInfo uriInfo;
+
+    @Override
+    public Response create(final ConnInstanceTO connectorTO) {
+        try {
+            ConnInstanceTO connector = connectorController.create(new 
DummyHTTPServletResponse(), connectorTO);
+            URI location = 
uriInfo.getAbsolutePathBuilder().path(connector.getId() + "").build();
+            return Response.created(location).entity(connector).build();
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void delete(final Long connectorId) {
+        try {
+            connectorController.delete(connectorId);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public List<ConnBundleTO> getBundles(final String lang) {
+        try {
+            return connectorController.getBundles(lang);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        } catch (MissingConfKeyException e) {
+            throw new BadRequestException(e);
+        }
+    }
+
+    @Override
+    public List<ConnConfProperty> getConfigurationProperties(final Long 
connectorId) {
+        try {
+            return connectorController.getConfigurationProperties(connectorId);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public List<SchemaTO> getSchemaNames(final Long connectorId, final 
ConnInstanceTO connectorTO,
+            final boolean showall) {
+        try {
+            List<String> schemaNames = connectorController.getSchemaNames(new 
DummyHTTPServletResponse(), connectorTO,
+                    showall);
+            List<SchemaTO> schemas = new ArrayList<SchemaTO>();
+            for (String name : schemaNames) {
+                SchemaTO schemaTO = new SchemaTO();
+                schemaTO.setName(name);
+                schemas.add(schemaTO);
+            }
+            return schemas;
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public List<ConnInstanceTO> list(final String lang) {
+        return connectorController.list(lang);
+    }
+
+    @Override
+    public ConnInstanceTO read(final Long connectorId) {
+        try {
+            return connectorController.read(connectorId);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public ConnInstanceTO readConnectorBean(final String resourceName) {
+        try {
+            return connectorController.readConnectorBean(resourceName);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void update(final Long connectorId, final ConnInstanceTO 
connectorTO) {
+        try {
+            connectorController.update(connectorTO);
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public boolean validate(final ConnInstanceTO connectorTO) {
+        try {
+            return (Boolean) connectorController.check(new 
DummyHTTPServletResponse(), connectorTO).getModel().values()
+                    .iterator().next();
+        } catch (SyncopeClientCompositeErrorException e) {
+            throw new BadRequestException(e);
+        } catch (NotFoundException e) {
+            throw new javax.ws.rs.NotFoundException(e);
+        }
+    }
+
+    @Override
+    public void setUriInfo(final UriInfo ui) {
+        this.uriInfo = ui;
+    }
+}

Modified: syncope/trunk/core/src/main/resources/restContext.xml
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/restContext.xml?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/restContext.xml (original)
+++ syncope/trunk/core/src/main/resources/restContext.xml Sat Jan 19 09:30:44 
2013
@@ -67,6 +67,7 @@ under the License.
    <jaxrs:server id="restContainer" address="/">
       <jaxrs:serviceBeans>
          <ref bean="configurationServiceImpl" />
+         <ref bean="connectorServiceImpl" />
          <ref bean="entitlementServiceImpl" />
       </jaxrs:serviceBeans>
       <jaxrs:resourceComparator>

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=1435513&r1=1435512&r2=1435513&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
 Sat Jan 19 09:30:44 2013
@@ -33,11 +33,14 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import javax.ws.rs.core.Response;
+
 import org.apache.syncope.client.to.ConnBundleTO;
 import org.apache.syncope.client.to.ConnInstanceTO;
 import org.apache.syncope.client.to.MappingItemTO;
 import org.apache.syncope.client.to.MappingTO;
 import org.apache.syncope.client.to.ResourceTO;
+import org.apache.syncope.client.to.SchemaTO;
 import 
org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.types.ConnConfPropSchema;
 import org.apache.syncope.types.ConnConfProperty;
@@ -133,7 +136,8 @@ public class ConnInstanceTestITCase exte
         connectorTO.addCapability(ConnectorCapability.ONE_PHASE_CREATE);
         connectorTO.addCapability(ConnectorCapability.TWO_PHASES_UPDATE);
 
-        ConnInstanceTO actual = connectorService.create(connectorTO);
+        Response response = connectorService.create(connectorTO);
+        ConnInstanceTO actual = (ConnInstanceTO) response.getEntity();
 
         assertNotNull(actual);
 
@@ -151,7 +155,8 @@ public class ConnInstanceTestITCase exte
         connectorTO.removeCapability(ConnectorCapability.TWO_PHASES_UPDATE);
         actual = null;
         try {
-            actual = connectorService.update(connectorTO.getId(), connectorTO);
+            connectorService.update(connectorTO.getId(), connectorTO);
+            actual = connectorService.read(connectorTO.getId());
         } catch (HttpStatusCodeException e) {
             LOG.error("update failed", e);
             t = e;
@@ -163,8 +168,7 @@ public class ConnInstanceTestITCase exte
 
         // check also for the deletion of the created object
         try {
-            ConnInstanceTO deletedConn = 
connectorService.delete(actual.getId());
-            assertNotNull(deletedConn);
+            connectorService.delete(actual.getId());
         } catch (HttpStatusCodeException e) {
             LOG.error("delete failed", e);
             t = e;
@@ -221,7 +225,8 @@ public class ConnInstanceTestITCase exte
         // set connector configuration
         connectorTO.setConfiguration(conf);
 
-        ConnInstanceTO actual = connectorService.update(connectorTO.getId(), 
connectorTO);
+        connectorService.update(connectorTO.getId(), connectorTO);
+        ConnInstanceTO actual = connectorService.read(connectorTO.getId());
 
         assertNotNull(actual);
 
@@ -262,7 +267,8 @@ public class ConnInstanceTestITCase exte
         // ----------------------------------
         // Create a new connector instance.
         // ----------------------------------
-        connInstanceTO = connectorService.create(connInstanceTO);
+        Response response = connectorService.create(connInstanceTO);
+        connInstanceTO = (ConnInstanceTO) response.getEntity();
 
         assertNotNull(connInstanceTO);
         assertTrue(connInstanceTO.getCapabilities().isEmpty());
@@ -299,7 +305,8 @@ public class ConnInstanceTestITCase exte
         // ----------------------------------
         connInstanceTO.addCapability(ConnectorCapability.SEARCH);
 
-        ConnInstanceTO actual = 
connectorService.update(connInstanceTO.getId(), connInstanceTO);
+        connectorService.update(connInstanceTO.getId(), connInstanceTO);
+        ConnInstanceTO actual = connectorService.read(connInstanceTO.getId());
 
         assertNotNull(actual);
         assertFalse(connInstanceTO.getCapabilities().isEmpty());
@@ -497,9 +504,11 @@ public class ConnInstanceTestITCase exte
     public void getSchemaNames() {
         ConnInstanceTO conn = connectorService.read(101L);
 
-        List<String> schemaNames = 
connectorService.getSchemaNames(conn.getId(), conn, true);
+        List<SchemaTO> schemaNames = 
connectorService.getSchemaNames(conn.getId(), conn, true);
         assertNotNull(schemaNames);
         assertFalse(schemaNames.isEmpty());
+        assertNotNull(schemaNames.get(0).getName());
+        assertNull(schemaNames.get(0).getEnumerationValues());
 
         schemaNames = connectorService.getSchemaNames(conn.getId(), conn, 
false);
 
@@ -516,100 +525,97 @@ public class ConnInstanceTestITCase exte
         assertFalse(schemaNames.isEmpty());
     }
 
-       @Test
-       public void issueSYNCOPE112() {
+    @Test
+    public void issueSYNCOPE112() {
+
+        // ----------------------------------------
+        // Create a new connector
+        // ----------------------------------------
+        ConnInstanceTO connectorTO = new ConnInstanceTO();
+
+        // set connector version
+        connectorTO.setVersion(connidSoapVersion);
+
+        // set connector name
+        
connectorTO.setConnectorName("org.connid.bundles.soap.WebServiceConnector");
+
+        // set bundle name
+        connectorTO.setBundleName("org.connid.bundles.soap");
+
+        // set display name
+        connectorTO.setDisplayName("WSSoap");
+
+        // set the connector configuration using PropertyTO
+        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();
+
+        ConnConfPropSchema userSchema = new ConnConfPropSchema();
+        userSchema.setName("endpoint");
+        userSchema.setType(String.class.getName());
+        userSchema.setRequired(true);
+        ConnConfProperty endpoint = new ConnConfProperty();
+        endpoint.setSchema(userSchema);
+        
endpoint.setValues(Collections.singletonList("http://localhost:9080/does_not_work";));
+        endpoint.setOverridable(true);
+
+        ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
+        keyColumnSchema.setName("servicename");
+        keyColumnSchema.setType(String.class.getName());
+        keyColumnSchema.setRequired(true);
+        ConnConfProperty servicename = new ConnConfProperty();
+        servicename.setSchema(keyColumnSchema);
+        servicename
+                
.setValues(Collections.singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
+        servicename.setOverridable(false);
+
+        conf.add(endpoint);
+        conf.add(servicename);
 
-               // ----------------------------------------
-               // Create a new connector
-               // ----------------------------------------
-               ConnInstanceTO connectorTO = new ConnInstanceTO();
-
-               // set connector version
-               connectorTO.setVersion(connidSoapVersion);
-
-               // set connector name
-               connectorTO
-                               
.setConnectorName("org.connid.bundles.soap.WebServiceConnector");
-
-               // set bundle name
-               connectorTO.setBundleName("org.connid.bundles.soap");
-
-               // set display name
-               connectorTO.setDisplayName("WSSoap");
-
-               // set the connector configuration using PropertyTO
-               Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();
-
-               ConnConfPropSchema userSchema = new ConnConfPropSchema();
-               userSchema.setName("endpoint");
-               userSchema.setType(String.class.getName());
-               userSchema.setRequired(true);
-               ConnConfProperty endpoint = new ConnConfProperty();
-               endpoint.setSchema(userSchema);
-               endpoint.setValues(Collections
-                               
.singletonList("http://localhost:9080/does_not_work";));
-               endpoint.setOverridable(true);
-
-               ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
-               keyColumnSchema.setName("servicename");
-               keyColumnSchema.setType(String.class.getName());
-               keyColumnSchema.setRequired(true);
-               ConnConfProperty servicename = new ConnConfProperty();
-               servicename.setSchema(keyColumnSchema);
-               servicename
-                               .setValues(Collections
-                                               
.singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
-               servicename.setOverridable(false);
-
-               conf.add(endpoint);
-               conf.add(servicename);
-
-               // set connector configuration
-               connectorTO.setConfiguration(conf);
-
-               try {
-
-                       assertFalse(connectorService.validate(connectorTO));
-
-                       connectorTO = connectorService.create(connectorTO);
-                       assertNotNull(connectorTO);
-                       // ----------------------------------------
-
-                       // ----------------------------------------
-                       // create a resourceTO
-                       // ----------------------------------------
-                       String resourceName = "checkForPropOverriding";
-                       ResourceTO resourceTO = new ResourceTO();
-
-                       resourceTO.setName(resourceName);
-                       resourceTO.setConnectorId(connectorTO.getId());
-
-                       conf = new HashSet<ConnConfProperty>();
-                       endpoint.setValues(Collections
-                                       
.singletonList("http://localhost:9080/wssample/services/provisioning";));
-                       conf.add(endpoint);
-
-                       resourceTO.setConnectorConfigurationProperties(conf);
-
-                       MappingTO mapping = new MappingTO();
-                       resourceTO.setUmapping(mapping);
-
-                       MappingItemTO mapItem = new MappingItemTO();
-                       mapItem.setExtAttrName("uid");
-                       mapItem.setIntAttrName("userId");
-                       mapItem.setIntMappingType(IntMappingType.UserSchema);
-                       mapItem.setAccountid(true);
-                       mapping.setAccountIdItem(mapItem);
-                       // ----------------------------------------
-
-                       // ----------------------------------------
-                       // Check connection without saving the resource ....
-                       // ----------------------------------------
-                       assertTrue(resourceService.check(resourceTO));
-                       // ----------------------------------------
-               } finally {
-                       // Remove connector from db to make test re-runnable
-                       connectorService.delete(connectorTO.getId());
-               }
-       }
+        // set connector configuration
+        connectorTO.setConfiguration(conf);
+
+        try {
+
+            assertFalse(connectorService.validate(connectorTO));
+
+            Response response = connectorService.create(connectorTO);
+            connectorTO = (ConnInstanceTO) response.getEntity();
+            assertNotNull(connectorTO);
+            // ----------------------------------------
+
+            // ----------------------------------------
+            // create a resourceTO
+            // ----------------------------------------
+            String resourceName = "checkForPropOverriding";
+            ResourceTO resourceTO = new ResourceTO();
+
+            resourceTO.setName(resourceName);
+            resourceTO.setConnectorId(connectorTO.getId());
+
+            conf = new HashSet<ConnConfProperty>();
+            
endpoint.setValues(Collections.singletonList("http://localhost:9080/wssample/services/provisioning";));
+            conf.add(endpoint);
+
+            resourceTO.setConnectorConfigurationProperties(conf);
+
+            MappingTO mapping = new MappingTO();
+            resourceTO.setUmapping(mapping);
+
+            MappingItemTO mapItem = new MappingItemTO();
+            mapItem.setExtAttrName("uid");
+            mapItem.setIntAttrName("userId");
+            mapItem.setIntMappingType(IntMappingType.UserSchema);
+            mapItem.setAccountid(true);
+            mapping.setAccountIdItem(mapItem);
+            // ----------------------------------------
+
+            // ----------------------------------------
+            // Check connection without saving the resource ....
+            // ----------------------------------------
+            assertTrue(resourceService.check(resourceTO));
+            // ----------------------------------------
+        } finally {
+            // Remove connector from db to make test re-runnable
+            connectorService.delete(connectorTO.getId());
+        }
+    }
 }

Modified: 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: 
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1435513&r1=1435512&r2=1435513&view=diff
==============================================================================
--- 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
 (original)
+++ 
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
 Sat Jan 19 09:30:44 2013
@@ -18,7 +18,10 @@
  */
 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.Collection;
@@ -26,12 +29,10 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.junit.Test;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.apache.syncope.client.to.ResourceTO;
+
 import org.apache.syncope.client.to.MappingItemTO;
 import org.apache.syncope.client.to.MappingTO;
+import org.apache.syncope.client.to.ResourceTO;
 import 
org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.client.validation.SyncopeClientException;
 import org.apache.syncope.types.ConnConfPropSchema;
@@ -39,7 +40,10 @@ import org.apache.syncope.types.ConnConf
 import org.apache.syncope.types.IntMappingType;
 import org.apache.syncope.types.SyncopeClientExceptionType;
 import org.junit.FixMethodOrder;
+import org.junit.Test;
 import org.junit.runners.MethodSorters;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.client.HttpStatusCodeException;
 
 @FixMethodOrder(MethodSorters.JVM)
 public class ResourceTestITCase extends AbstractTest {
@@ -256,7 +260,7 @@ public class ResourceTestITCase extends 
 
     @Test
     public void update() {
-        final String resourceName = "ws-target-resource-update";
+        String resourceName = "ws-target-resource-update";
         ResourceTO resourceTO = new ResourceTO();
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(101L);
@@ -310,24 +314,24 @@ public class ResourceTestITCase extends 
     public void updateResetSyncToken() {
         // create resource with sync token
         String resourceName = "ws-target-resource-update-resetsynctoken" + 
getUUIDString();
-       ResourceTO pre = buildResourceTO(resourceName);
-       pre.setUsyncToken("test");
-       resourceService.create(pre);
-
-               pre.setUsyncToken(null);
-               ResourceTO actual = resourceService.update(pre.getName(), pre);
-               // check that the synctoken has been reset
-               assertNull(actual.getUsyncToken());
+        ResourceTO pre = buildResourceTO(resourceName);
+        pre.setUsyncToken("test");
+        resourceService.create(pre);
+
+        pre.setUsyncToken(null);
+        ResourceTO actual = resourceService.update(pre.getName(), pre);
+        // check that the synctoken has been reset
+        assertNull(actual.getUsyncToken());
     }
 
     @Test
     public void delete() {
-        final String resourceName = "ws-target-resource-delete";
+        String resourceName = "ws-target-resource-delete";
 
         ResourceTO resource = buildResourceTO(resourceName);
         ResourceTO actual = resourceService.create(resource);
         assertNotNull(actual);
-        
+
         ResourceTO deletedResource = resourceService.delete(resourceName);
         assertNotNull(deletedResource);
 
@@ -364,8 +368,8 @@ public class ResourceTestITCase extends 
         assertNotNull(actual);
     }
 
-       private ResourceTO buildResourceTO(String resourceName) {
-               ResourceTO resourceTO = new ResourceTO();
+    private ResourceTO buildResourceTO(String resourceName) {
+        ResourceTO resourceTO = new ResourceTO();
 
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(102L);
@@ -393,7 +397,7 @@ public class ResourceTestITCase extends 
         mapping.addItem(item);
 
         resourceTO.setUmapping(mapping);
-               return resourceTO;
-       }
+        return resourceTO;
+    }
 
 }


Reply via email to