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/18 14:51:53 UTC
svn commit: r1435135 [1/2] - in /syncope/trunk: ./ archetype/ client/
client/src/main/java/org/apache/syncope/client/to/
client/src/main/java/org/apache/syncope/client/util/
client/src/main/java/org/apache/syncope/services/
client/src/main/java/org/apa...
Author: jbernhardt
Date: Fri Jan 18 13:51:53 2013
New Revision: 1435135
URL: http://svn.apache.org/viewvc?rev=1435135&view=rev
Log:
[SYNCOPE-231]
* Enabling some first CXF Webservices.
* Code cleanup (adding final to method parameters)
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/MailTemplateTO.java
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ValidatorTO.java
syncope/trunk/client/src/main/java/org/apache/syncope/client/util/CollectionWrapper.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/QueryResourceInfoComperator.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/RestServiceExceptionMapper.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java
Modified:
syncope/trunk/archetype/ (props changed)
syncope/trunk/client/ (props changed)
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConfigurationTO.java
syncope/trunk/client/src/main/java/org/apache/syncope/client/to/EntitlementTO.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/ConfigurationService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/EntitlementService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.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/SpringServiceProxy.java
syncope/trunk/console/ (props changed)
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
syncope/trunk/console/src/main/resources/applicationContext.xml
syncope/trunk/core/ (props changed)
syncope/trunk/core/pom.xml
syncope/trunk/core/src/main/resources/restContext.xml
syncope/trunk/core/src/main/webapp/WEB-INF/web.xml
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AuthenticationTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
syncope/trunk/core/src/test/resources/restClientContext.xml
syncope/trunk/pom.xml
syncope/trunk/standalone/ (props changed)
Propchange: syncope/trunk/archetype/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 18 13:51:53 2013
@@ -1,3 +1,4 @@
*.project
*.settings
target
+.pmd
Propchange: syncope/trunk/client/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 18 13:51:53 2013
@@ -5,3 +5,5 @@
maven-eclipse.xml
nb-configuration.xml
target
+*.checkstyle
+.pmd
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConfigurationTO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConfigurationTO.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConfigurationTO.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ConfigurationTO.java Fri Jan 18 13:51:53 2013
@@ -18,8 +18,13 @@
*/
package org.apache.syncope.client.to;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
import org.apache.syncope.client.AbstractBaseBean;
+@XmlRootElement(name = "configuration")
+@XmlType
public class ConfigurationTO extends AbstractBaseBean {
private static final long serialVersionUID = -3825039700228595590L;
@@ -32,7 +37,7 @@ public class ConfigurationTO extends Abs
return key;
}
- public void setKey(String key) {
+ public void setKey(final String key) {
this.key = key;
}
@@ -40,7 +45,7 @@ public class ConfigurationTO extends Abs
return value;
}
- public void setValue(String value) {
+ public void setValue(final String value) {
this.value = value;
}
}
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/to/EntitlementTO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/EntitlementTO.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/to/EntitlementTO.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/to/EntitlementTO.java Fri Jan 18 13:51:53 2013
@@ -18,73 +18,36 @@
*/
package org.apache.syncope.client.to;
-import java.io.Serializable;
-
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-@XmlRootElement
+import org.apache.syncope.client.AbstractBaseBean;
+
+@XmlRootElement(name = "entitlement")
@XmlType
-public class EntitlementTO implements Serializable {
+public class EntitlementTO extends AbstractBaseBean {
- private static final long serialVersionUID = 7233619557177034458L;
+ private static final long serialVersionUID = 7133614577172038452L;
private String name;
- public EntitlementTO() {
- }
-
- public EntitlementTO(String name) {
- this.name = name;
+ public static EntitlementTO instance(final String name) {
+ EntitlementTO instance = new EntitlementTO();
+ instance.setName(name);
+ return instance;
}
/**
* @return the name
*/
- @XmlValue
public String getName() {
return name;
}
/**
- * @param name
- * the name to set
+ * @param name the name to set
*/
- public void setName(String name) {
+ public void setName(final String name) {
this.name = name;
}
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null)
- ? 0
- : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof EntitlementTO))
- return false;
- EntitlementTO other = (EntitlementTO) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "EntitlementTO [" + name + "]";
- }
-
}
Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/to/MailTemplateTO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/MailTemplateTO.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/to/MailTemplateTO.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/to/MailTemplateTO.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.to;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.syncope.client.AbstractBaseBean;
+
+@XmlRootElement(name = "mailTemplate")
+@XmlType
+public class MailTemplateTO extends AbstractBaseBean {
+
+ private static final long serialVersionUID = 7232619557172031478L;
+
+ private String name;
+
+ public static MailTemplateTO instance(final String name) {
+ MailTemplateTO templateTO = new MailTemplateTO();
+ templateTO.setName(name);
+ return templateTO;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ValidatorTO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ValidatorTO.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ValidatorTO.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/to/ValidatorTO.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.to;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.syncope.client.AbstractBaseBean;
+
+@XmlRootElement
+@XmlType
+public class ValidatorTO extends AbstractBaseBean {
+
+ private static final long serialVersionUID = 7233619557177034453L;
+
+ private String name;
+
+ public static ValidatorTO instance(final String name) {
+ ValidatorTO instance = new ValidatorTO();
+ instance.setName(name);
+ return instance;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Added: syncope/trunk/client/src/main/java/org/apache/syncope/client/util/CollectionWrapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/util/CollectionWrapper.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/client/util/CollectionWrapper.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/client/util/CollectionWrapper.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,111 @@
+/*
+ * 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.client.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.syncope.client.to.EntitlementTO;
+import org.apache.syncope.client.to.MailTemplateTO;
+import org.apache.syncope.client.to.ValidatorTO;
+import org.springframework.web.servlet.ModelAndView;
+
+public final class CollectionWrapper {
+
+ private CollectionWrapper() {
+ }
+
+ public static Set<EntitlementTO> wrap(final Set<String> collection) {
+ Set<EntitlementTO> respons = new HashSet<EntitlementTO>();
+ for (String e : collection) {
+ respons.add(EntitlementTO.instance(e));
+ }
+ return respons;
+ }
+
+ public static List<EntitlementTO> wrap(final List<String> collection) {
+ List<EntitlementTO> respons = new ArrayList<EntitlementTO>();
+ for (String e : collection) {
+ respons.add(EntitlementTO.instance(e));
+ }
+ return respons;
+ }
+
+ public static Set<String> unwrap(final Set<EntitlementTO> collection) {
+ Set<String> respons = new HashSet<String>();
+ for (EntitlementTO e : collection) {
+ respons.add(e.getName());
+ }
+ return respons;
+ }
+
+ public static List<String> unwrap(final List<EntitlementTO> collection) {
+ List<String> respons = new ArrayList<String>();
+ for (EntitlementTO e : collection) {
+ respons.add(e.getName());
+ }
+ return respons;
+ }
+
+ public static Set<MailTemplateTO> wrapMailTemplates(final ModelAndView mailTemplates) {
+ @SuppressWarnings("unchecked")
+ Set<String> collection = (Set<String>) mailTemplates.getModel().values().iterator().next();
+ return wrapMailTemplates(collection);
+ }
+
+ public static Set<MailTemplateTO> wrapMailTemplates(final Set<String> collection) {
+ Set<MailTemplateTO> respons = new HashSet<MailTemplateTO>();
+ for (String e : collection) {
+ respons.add(MailTemplateTO.instance(e));
+ }
+ return respons;
+ }
+
+ public static Set<ValidatorTO> wrapValidator(final ModelAndView validators) {
+ @SuppressWarnings("unchecked")
+ Set<String> collection = (Set<String>) validators.getModel().values().iterator().next();
+ return wrapValidator(collection);
+ }
+
+ public static List<String> unwrapValidator(final List<ValidatorTO> collection) {
+ List<String> respons = new ArrayList<String>();
+ for (ValidatorTO e : collection) {
+ respons.add(e.getName());
+ }
+ return respons;
+ }
+
+ public static List<String> unwrapMailTemplates(final List<MailTemplateTO> collection) {
+ List<String> respons = new ArrayList<String>();
+ for (MailTemplateTO e : collection) {
+ respons.add(e.getName());
+ }
+ return respons;
+ }
+
+ public static Set<ValidatorTO> wrapValidator(final Set<String> collection) {
+ Set<ValidatorTO> respons = new HashSet<ValidatorTO>();
+ for (String e : collection) {
+ respons.add(ValidatorTO.instance(e));
+ }
+ return respons;
+ }
+}
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=1435135&r1=1435134&r2=1435135&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 Fri Jan 18 13:51:53 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.services;
import java.util.List;
import java.util.Set;
+
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -29,13 +30,16 @@ 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;
+import org.apache.syncope.client.to.MailTemplateTO;
+import org.apache.syncope.client.to.ValidatorTO;
@Path("configurations")
public interface ConfigurationService {
@POST
- ConfigurationTO create(ConfigurationTO configurationTO);
+ Response create(ConfigurationTO configurationTO);
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@@ -43,15 +47,15 @@ public interface ConfigurationService {
@DELETE
@Path("{key}")
- ConfigurationTO delete(@PathParam("key") String key);
+ void delete(@PathParam("key") String key);
@GET
@Path("mailTemplates")
- Set<String> getMailTemplates();
+ Set<MailTemplateTO> getMailTemplates();
@GET
@Path("validators")
- Set<String> getValidators();
+ Set<ValidatorTO> getValidators();
@GET
List<ConfigurationTO> list();
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=1435135&r1=1435134&r2=1435135&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 Fri Jan 18 13:51:53 2013
@@ -19,16 +19,25 @@
package org.apache.syncope.services;
import java.util.Set;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import org.apache.syncope.client.to.EntitlementTO;
+
@Path("entitlements")
public interface EntitlementService {
+ /**
+ * @return Returns a collection of all known entitlements.
+ */
@GET
- Set<String> getAllEntitlements();
+ Set<EntitlementTO> getAllEntitlements();
+ /**
+ * @return Returns a collection of entitlements assigned to user making this request (Service Call).
+ */
@GET
@Path("own")
- Set<String> getMyEntitlements();
+ Set<EntitlementTO> getMyEntitlements();
}
Modified: 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=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/ConfigurationServiceProxy.java Fri Jan 18 13:51:53 2013
@@ -19,12 +19,18 @@
package org.apache.syncope.services.proxy;
import java.io.InputStream;
+import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import javax.ws.rs.core.Response;
+
import org.apache.syncope.client.to.ConfigurationTO;
+import org.apache.syncope.client.to.MailTemplateTO;
+import org.apache.syncope.client.to.ValidatorTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.services.ConfigurationService;
import org.springframework.web.client.RestTemplate;
@@ -35,14 +41,16 @@ public class ConfigurationServiceProxy e
}
@Override
- public ConfigurationTO create(final ConfigurationTO configurationTO) {
- return getRestTemplate().postForObject(
- baseUrl + "configuration/create", configurationTO, ConfigurationTO.class);
+ public Response create(final ConfigurationTO configurationTO) {
+ ConfigurationTO created = getRestTemplate().postForObject(baseUrl + "configuration/create",
+ configurationTO, ConfigurationTO.class);
+ URI location = URI.create(baseUrl + "configuration/read/" + created.getKey() + ".json");
+ return Response.created(location).entity(created).build();
}
@Override
- public ConfigurationTO delete(final String key) {
- return getRestTemplate().getForObject(baseUrl + "configuration/delete/{key}.json", ConfigurationTO.class, key);
+ public void delete(final String key) {
+ getRestTemplate().getForObject(baseUrl + "configuration/delete/{key}.json", ConfigurationTO.class, key);
}
@Override
@@ -58,20 +66,22 @@ public class ConfigurationServiceProxy e
@Override
public ConfigurationTO update(final String key, final ConfigurationTO configurationTO) {
- return getRestTemplate()
- .postForObject(baseUrl + "configuration/update", configurationTO, ConfigurationTO.class);
+ return getRestTemplate().postForObject(baseUrl + "configuration/update", configurationTO,
+ ConfigurationTO.class);
}
@Override
- public Set<String> getValidators() {
- return new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
+ public Set<ValidatorTO> getValidators() {
+ Set<String> response = new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
baseUrl + "configuration/validators.json", String[].class)));
+ return CollectionWrapper.wrapValidator(response);
}
@Override
- public Set<String> getMailTemplates() {
- return new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
+ public Set<MailTemplateTO> getMailTemplates() {
+ Set<String> response = new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
baseUrl + "configuration/mailTemplates.json", String[].class)));
+ return CollectionWrapper.wrapMailTemplates(response);
}
@Override
@@ -79,4 +89,5 @@ public class ConfigurationServiceProxy e
return Response.ok(getRestTemplate().getForObject(baseUrl + "configuration/dbexport", InputStream.class))
.build();
}
+
}
Modified: 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=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/EntitlementServiceProxy.java Fri Jan 18 13:51:53 2013
@@ -21,6 +21,8 @@ package org.apache.syncope.services.prox
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import org.apache.syncope.client.to.EntitlementTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.services.EntitlementService;
import org.springframework.web.client.RestTemplate;
@@ -31,14 +33,16 @@ public class EntitlementServiceProxy ext
}
@Override
- public Set<String> getAllEntitlements() {
- return new HashSet<String>(Arrays.asList(new RestTemplate().getForObject(baseUrl + "auth/allentitlements.json",
- String[].class)));
+ public Set<EntitlementTO> getAllEntitlements() {
+ Set<String> entitlements = new HashSet<String>(Arrays.asList(new RestTemplate().getForObject(
+ baseUrl + "auth/allentitlements.json", String[].class)));
+ return CollectionWrapper.wrap(entitlements);
}
@Override
- public Set<String> getMyEntitlements() {
- return new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(baseUrl + "auth/entitlements.json",
- String[].class)));
+ public Set<EntitlementTO> getMyEntitlements() {
+ Set<String> entitlements = new HashSet<String>(Arrays.asList(getRestTemplate().getForObject(
+ baseUrl + "auth/entitlements.json", String[].class)));
+ return CollectionWrapper.wrap(entitlements);
}
}
Modified: 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=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java (original)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/proxy/SpringServiceProxy.java Fri Jan 18 13:51:53 2013
@@ -36,7 +36,6 @@ public abstract class SpringServiceProxy
}
public RestTemplate getRestTemplate() {
- //return callback.getRestTemplate();
return restTemplate;
}
}
Propchange: syncope/trunk/console/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 18 13:51:53 2013
@@ -7,3 +7,5 @@ maven-eclipse.xml
nb-configuration.xml
nbactions.xml
target
+.checkstyle
+.pmd
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java Fri Jan 18 13:51:53 2013
@@ -21,13 +21,17 @@ package org.apache.syncope.console.pages
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
+
import org.apache.http.HttpResponse;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
+import org.apache.syncope.client.to.EntitlementTO;
import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.console.SyncopeSession;
import org.apache.syncope.console.wicket.markup.html.form.LinkPanel;
import org.apache.syncope.services.EntitlementService;
@@ -187,7 +191,8 @@ public class Login extends WebPage {
requestFactory.getAuthScope(), new UsernamePasswordCredentials(userId, password));
// 2. Search authorizations for user specified by credentials
- return SyncopeSession.get().getService(EntitlementService.class).getMyEntitlements().toArray(new String[0]);
+ Set<EntitlementTO> entitlements = SyncopeSession.get().getService(EntitlementService.class).getMyEntitlements();
+ return CollectionWrapper.unwrap(entitlements).toArray(new String[0]);
}
private boolean isSelfRegistrationAllowed() {
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/AuthRestClient.java Fri Jan 18 13:51:53 2013
@@ -20,7 +20,10 @@ package org.apache.syncope.console.rest;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import org.apache.syncope.client.to.EntitlementTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.services.EntitlementService;
import org.springframework.stereotype.Component;
@@ -38,7 +41,9 @@ public class AuthRestClient extends Base
* @return List<String>
*/
public List<String> getAllEntitlements() {
- return new ArrayList<String>(getService(EntitlementService.class).getAllEntitlements());
+ List<EntitlementTO> entitlemens = new ArrayList<EntitlementTO>(getService(EntitlementService.class)
+ .getAllEntitlements());
+ return CollectionWrapper.unwrap(entitlemens);
}
/**
@@ -47,6 +52,8 @@ public class AuthRestClient extends Base
* @return List<String>
*/
public List<String> getOwnedEntitlements() {
- return new ArrayList<String>(getService(EntitlementService.class).getMyEntitlements());
+ List<EntitlementTO> entitlemens = new ArrayList<EntitlementTO>(getService(EntitlementService.class)
+ .getMyEntitlements());
+ return CollectionWrapper.unwrap(entitlemens);
}
}
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConfigurationRestClient.java Fri Jan 18 13:51:53 2013
@@ -64,6 +64,8 @@ public class ConfigurationRestClient ext
* Delete a configuration by key.
*/
public ConfigurationTO deleteConfiguration(final String key) {
- return getService(ConfigurationService.class).delete(key);
+ ConfigurationTO response = getService(ConfigurationService.class).read(key);
+ getService(ConfigurationService.class).delete(key);
+ return response;
}
}
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/NotificationRestClient.java Fri Jan 18 13:51:53 2013
@@ -20,7 +20,10 @@ package org.apache.syncope.console.rest;
import java.util.ArrayList;
import java.util.List;
+import org.apache.syncope.client.to.MailTemplateTO;
import org.apache.syncope.client.to.NotificationTO;
+import org.apache.syncope.client.to.ValidatorTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.services.ConfigurationService;
import org.apache.syncope.services.NotificationService;
@@ -53,7 +56,8 @@ public class NotificationRestClient exte
}
public List<String> getMailTemplates() throws SyncopeClientCompositeErrorException {
- return new ArrayList<String>(getService(ConfigurationService.class).getMailTemplates());
+ return CollectionWrapper.unwrapMailTemplates(new ArrayList<MailTemplateTO>(getService(
+ ConfigurationService.class).getMailTemplates()));
}
public List<String> getEvents() throws SyncopeClientCompositeErrorException {
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java Fri Jan 18 13:51:53 2013
@@ -23,7 +23,9 @@ import java.util.List;
import org.apache.syncope.client.to.DerivedSchemaTO;
import org.apache.syncope.client.to.SchemaTO;
+import org.apache.syncope.client.to.ValidatorTO;
import org.apache.syncope.client.to.VirtualSchemaTO;
+import org.apache.syncope.client.util.CollectionWrapper;
import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.services.ConfigurationService;
import org.apache.syncope.services.SchemaService;
@@ -104,7 +106,8 @@ public class SchemaRestClient extends Ba
final List<String> userDerivedSchemasNames = new ArrayList<String>();
try {
- final List<DerivedSchemaTO> userDerivedSchemas = getService(SchemaService.class).list(type, SchemaType.DERIVED);
+ final List<DerivedSchemaTO> userDerivedSchemas = getService(SchemaService.class).list(type,
+ SchemaType.DERIVED);
for (DerivedSchemaTO schemaTO : userDerivedSchemas) {
userDerivedSchemasNames.add(schemaTO.getName());
@@ -143,7 +146,8 @@ public class SchemaRestClient extends Ba
final List<String> userVirtualSchemasNames = new ArrayList<String>();
try {
- final List<VirtualSchemaTO> userVirtualSchemas = getService(SchemaService.class).list(type, SchemaType.VIRTUAL);
+ final List<VirtualSchemaTO> userVirtualSchemas = getService(SchemaService.class).list(type,
+ SchemaType.VIRTUAL);
for (VirtualSchemaTO schemaTO : userVirtualSchemas) {
userVirtualSchemasNames.add(schemaTO.getName());
}
@@ -273,13 +277,15 @@ public class SchemaRestClient extends Ba
* Populator for Validator Schema DropDown components.
*/
public List<String> getAllValidatorClasses() {
- List<String> validators = null;
+ List<String> response = null;
try {
- validators = new ArrayList<String>(getService(ConfigurationService.class).getValidators());
+ List<ValidatorTO> validators = new ArrayList<ValidatorTO>(getService(ConfigurationService.class)
+ .getValidators());
+ response = CollectionWrapper.unwrapValidator(validators);
} catch (SyncopeClientCompositeErrorException e) {
LOG.error("While getting all validators", e);
}
- return validators;
+ return response;
}
}
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java Fri Jan 18 13:51:53 2013
@@ -58,11 +58,11 @@ public class UserRestClient extends Abst
return getService(UserService.class).list(page, size);
}
- public UserTO create(final UserTO userTO) throws SyncopeClientCompositeErrorException {
+ public UserTO create(final UserTO userTO) {
return getService(UserService.class).create(userTO);
}
- public UserTO update(UserMod userModTO) throws SyncopeClientCompositeErrorException {
+ public UserTO update(final UserMod userModTO) {
return getService(UserService.class).update(userModTO.getId(), userModTO);
}
@@ -101,27 +101,24 @@ public class UserRestClient extends Abst
}
@Override
- public List<UserTO> search(final NodeCond searchCond, final int page, final int size)
- throws SyncopeClientCompositeErrorException {
+ public List<UserTO> search(final NodeCond searchCond, final int page, final int size) {
return getService(UserService.class).search(searchCond, page, size);
}
@Override
- public ConnObjectTO getRemoteObject(final String resourceName, final String objectId)
- throws SyncopeClientCompositeErrorException {
+ public ConnObjectTO getRemoteObject(final String resourceName, final String objectId) {
return getService(ResourceService.class).getConnector(resourceName, AttributableType.USER, objectId);
}
- public UserTO reactivate(long userId, List<StatusBean> statuses) throws SyncopeClientCompositeErrorException {
+ public UserTO reactivate(final long userId, final List<StatusBean> statuses) {
return enable(userId, statuses, true);
}
- public UserTO suspend(long userId, List<StatusBean> statuses) throws SyncopeClientCompositeErrorException {
+ public UserTO suspend(final long userId, final List<StatusBean> statuses) {
return enable(userId, statuses, false);
}
- private UserTO enable(final long userId, final List<StatusBean> statuses, final boolean enable)
- throws SyncopeClientCompositeErrorException {
+ private UserTO enable(final long userId, final List<StatusBean> statuses, final boolean enable) {
StatusMod statusMod = new StatusMod();
statusMod.setId(userId);
Modified: syncope/trunk/console/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/applicationContext.xml?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/applicationContext.xml (original)
+++ syncope/trunk/console/src/main/resources/applicationContext.xml Fri Jan 18 13:51:53 2013
@@ -18,14 +18,11 @@ specific language governing permissions
under the License.
-->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:oxm="http://www.springframework.org/schema/oxm"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:context="http://www.springframework.org/schema/context" xmlns:oxm="http://www.springframework.org/schema/oxm"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
@@ -34,89 +31,92 @@ under the License.
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd">
+ http://www.springframework.org/schema/aop/spring-aop.xsd"
+>
- <context:component-scan base-package="org.apache.syncope.console.rest"/>
+ <context:component-scan base-package="org.apache.syncope.console.rest" />
- <bean id="systemPropertyConfigurer"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="order" value="1"/>
- <property name="location" value="file:#{(systemProperties['syncope.console.configuration'])}"/>
- <property name="ignoreResourceNotFound" value="true"/>
- <property name="ignoreUnresolvablePlaceholders" value="true"/>
- </bean>
- <bean id="defaultPropertyConfigurer"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>classpath:configuration.properties</value>
- </list>
- </property>
- </bean>
-
- <bean id="baseURL" class="java.lang.String">
- <constructor-arg value="${scheme}://${host}:${port}${rootPath}"/>
- </bean>
-
- <bean id="version" class="java.lang.String">
- <constructor-arg value="${version}"/>
- </bean>
-
- <bean id="authorizations" class="java.lang.String">
- <constructor-arg value="authorizations.xml"/>
- </bean>
-
- <bean id="syncopeApplication" class="org.apache.syncope.console.SyncopeApplication"/>
-
- <bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper"/>
-
- <bean id="mappingJacksonHttpMessageConverter"
- class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
- <property name="objectMapper" ref="jacksonObjectMapper"/>
- </bean>
-
- <bean id="httpClientConnManager" class="org.apache.http.impl.conn.PoolingClientConnectionManager"/>
-
- <bean id="httpClientParams" class="org.apache.syncope.client.http.HttpClientParams">
- <property name="parameterMap">
- <map key-type="java.lang.String">
- <entry>
- <key>
- <value>http.protocol.handle-authentication</value>
- </key>
- <value type="java.lang.Boolean">false</value>
- </entry>
- <entry>
- <key>
- <value>http.auth.credential-charset</value>
- </key>
- <value type="java.lang.String">UTF-8</value>
- </entry>
- </map>
- </property>
- </bean>
-
- <bean id="httpClientFactory" class="org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory" scope="prototype">
- <constructor-arg value="${host}"/>
- <constructor-arg value="${port}"/>
- <constructor-arg value="${scheme}"/>
- <constructor-arg ref="httpClientConnManager"/>
- <constructor-arg ref="httpClientParams"/>
- </bean>
-
- <bean id="restTemplate" class="org.springframework.web.client.RestTemplate" scope="prototype">
- <constructor-arg ref="httpClientFactory"/>
-
- <property name="errorHandler">
- <bean id="syncopeClientErrorHandler"
- class="org.apache.syncope.client.validation.SyncopeClientErrorHandler"/>
- </property>
- </bean>
+ <bean id="systemPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="order" value="1" />
+ <property name="location" value="file:#{(systemProperties['syncope.console.configuration'])}" />
+ <property name="ignoreResourceNotFound" value="true" />
+ <property name="ignoreUnresolvablePlaceholders" value="true" />
+ </bean>
+ <bean id="defaultPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <value>classpath:configuration.properties</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="baseURL" class="java.lang.String">
+ <constructor-arg value="${scheme}://${host}:${port}${rootPath}" />
+ </bean>
+
+ <bean id="version" class="java.lang.String">
+ <constructor-arg value="${version}" />
+ </bean>
+
+ <bean id="authorizations" class="java.lang.String">
+ <constructor-arg value="authorizations.xml" />
+ </bean>
+
+ <bean id="syncopeApplication" class="org.apache.syncope.console.SyncopeApplication" />
+
+ <bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" />
+
+ <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
+ <property name="objectMapper" ref="jacksonObjectMapper" />
+ </bean>
+
+ <bean id="httpClientConnManager" class="org.apache.http.impl.conn.PoolingClientConnectionManager" />
+
+ <bean id="httpClientParams" class="org.apache.syncope.client.http.HttpClientParams">
+ <property name="parameterMap">
+ <map key-type="java.lang.String">
+ <entry>
+ <key>
+ <value>http.protocol.handle-authentication</value>
+ </key>
+ <value type="java.lang.Boolean">false</value>
+ </entry>
+ <entry>
+ <key>
+ <value>http.auth.credential-charset</value>
+ </key>
+ <value type="java.lang.String">UTF-8</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <bean id="httpClientFactory" class="org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory"
+ scope="prototype"
+ >
+ <constructor-arg value="${host}" />
+ <constructor-arg value="${port}" />
+ <constructor-arg value="${scheme}" />
+ <constructor-arg ref="httpClientConnManager" />
+ <constructor-arg ref="httpClientParams" />
+ </bean>
+
+ <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
+ <constructor-arg ref="httpClientFactory" />
+ <property name="messageConverters">
+ <list>
+ <ref bean="mappingJacksonHttpMessageConverter" />
+ </list>
+ </property>
+ <property name="errorHandler">
+ <bean id="syncopeClientErrorHandler" class="org.apache.syncope.client.validation.SyncopeClientErrorHandler" />
+ </property>
+ </bean>
- <bean id="preferenceManager" class="org.apache.syncope.console.commons.PreferenceManager"/>
+ <bean id="preferenceManager" class="org.apache.syncope.console.commons.PreferenceManager" />
- <bean id="xmlRolesReader" class="org.apache.syncope.console.commons.XMLRolesReader"/>
+ <bean id="xmlRolesReader" class="org.apache.syncope.console.commons.XMLRolesReader" />
- <bean id="roleTreeBuilder" class="org.apache.syncope.console.commons.RoleTreeBuilder"/>
+ <bean id="roleTreeBuilder" class="org.apache.syncope.console.commons.RoleTreeBuilder" />
</beans>
Propchange: syncope/trunk/core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 18 13:51:53 2013
@@ -1,3 +1,5 @@
+*.checkstyle
+*.pmd
.classpath
.externalToolBuilders
.pom.xml.swp
@@ -8,3 +10,4 @@ maven.log
nb-configuration.xml
nbactions.xml
target
+log.directory_IS_UNDEFINED
Modified: syncope/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/pom.xml?rev=1435135&r1=1435134&r2=1435135&view=diff
==============================================================================
--- syncope/trunk/core/pom.xml (original)
+++ syncope/trunk/core/pom.xml Fri Jan 18 13:51:53 2013
@@ -93,6 +93,23 @@ under the License.
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-search</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -172,6 +189,11 @@ under the License.
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ </dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/QueryResourceInfoComperator.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/QueryResourceInfoComperator.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/QueryResourceInfoComperator.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/QueryResourceInfoComperator.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.jaxrs.ext.ResourceComparator;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
+import org.apache.cxf.jaxrs.model.Parameter;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Message;
+
+public class QueryResourceInfoComperator extends OperationResourceInfoComparator implements ResourceComparator {
+
+ public QueryResourceInfoComperator() {
+ super(null, null);
+ }
+
+ @Override
+ public int compare(final ClassResourceInfo cri1, final ClassResourceInfo cri2, final Message message) {
+ // Leave Class selection to CXF
+ return 0;
+ }
+
+ @Override
+ public int compare(final OperationResourceInfo oper1, final OperationResourceInfo oper2, final Message message) {
+
+ // Check if CXF can make a decision
+ int cxfResult = super.compare(oper1, oper2);
+ if (cxfResult != 0) {
+ return cxfResult;
+ }
+
+ int op1Counter = getMatchingRate(oper1, message);
+ int op2Counter = getMatchingRate(oper2, message);
+
+ return op1Counter == op2Counter
+ ? 0
+ : op1Counter < op2Counter
+ ? 1
+ : -1;
+ }
+
+ /**
+ * This method calculates a number indicating a good or bad match between values provided within the request and
+ * expected method parameters. A higher number means a better match.
+ *
+ * @param operation The operation to be rated, based on contained parameterInfo values.
+ * @param message A message containing query and header values from user request
+ * @return A positive or negative number, indicating a good match between query and method
+ */
+ protected int getMatchingRate(final OperationResourceInfo operation, final Message message) {
+
+ List<Parameter> params = operation.getParameters();
+ if (params == null || params.isEmpty()) {
+ return 0;
+ }
+
+ // Get Request QueryParams
+ String query = (String) message.get(Message.QUERY_STRING);
+ String path = (String) message.get(Message.REQUEST_URI);
+ Map<String, List<String>> qParams = JAXRSUtils.getStructuredParams(query, "&", true, false);
+ Map<String, List<String>> mParams = JAXRSUtils.getMatrixParams(path, true);
+ // Get Request Headers
+ Map<?, ?> qHeader = (java.util.Map<?, ?>) message.get(Message.PROTOCOL_HEADERS);
+
+ int rate = 0;
+ for (Parameter p : params) {
+ switch (p.getType()) {
+ case QUERY:
+ if (qParams.containsKey(p.getName())) {
+ rate += 2;
+ } else if (p.getDefaultValue() == null) {
+ rate -= 1;
+ }
+ break;
+ case MATRIX:
+ if (mParams.containsKey(p.getName())) {
+ rate += 2;
+ } else if (p.getDefaultValue() == null) {
+ rate -= 1;
+ }
+ break;
+ case HEADER:
+ if (qHeader.containsKey(p.getName())) {
+ rate += 2;
+ } else if (p.getDefaultValue() == null) {
+ rate -= 1;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return rate;
+ }
+}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/RestServiceExceptionMapper.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/RestServiceExceptionMapper.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/RestServiceExceptionMapper.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/RestServiceExceptionMapper.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest;
+
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.persistence.PersistenceException;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
+import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.client.validation.SyncopeClientErrorHandler;
+import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.core.persistence.dao.InvalidSearchConditionException;
+import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
+import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
+import org.apache.syncope.core.propagation.PropagationException;
+import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
+import org.apache.syncope.core.util.NotFoundException;
+import org.apache.syncope.core.workflow.WorkflowException;
+import org.apache.syncope.types.EntityViolationType;
+import org.apache.syncope.types.SyncopeClientExceptionType;
+import org.identityconnectors.framework.common.exceptions.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.orm.jpa.JpaSystemException;
+
+@Provider
+public class RestServiceExceptionMapper implements ExceptionMapper<Exception>, ResponseExceptionMapper<Exception> {
+
+ private static final String BASIC_REALM_UNAUTHORIZED = "Basic realm=\"Spring Security Application\"";
+ private static final Logger LOG = LoggerFactory.getLogger(RestServiceExceptionMapper.class);
+ public static final String EXCEPTION_TYPE_HEADER = "ExceptionType";
+
+ @Override
+ public Response toResponse(final Exception ex) {
+
+ LOG.error("Exception thrown by REST methods: " + ex.getMessage(), ex);
+
+ // 1. Process SyncopeClientCompositeErrorException
+ Response response = processCompositeExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 2. Process Bad Requests
+ response = processBadRequestExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 3. Process Unauthorized
+ response = processUnauthorizedExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 4. Process Forbidden
+ response = processForbiddenExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 4. Process NotFound
+ response = processNotFoundExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 5. Process Conflict
+ response = processConflictExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 5. Process InternalServerError
+ response = processServerErrorExceptions(ex);
+ if (response != null) {
+ return response;
+ }
+
+ // 6. Rest is interpreted as InternalServerError
+ ResponseBuilder responseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+ responseBuilder.header(SyncopeClientExceptionType.Unknown.getElementHeaderName(), ex.getCause() == null
+ ? ex.getMessage()
+ : ex.getCause().getMessage());
+
+ return responseBuilder.build();
+ }
+
+ @Override
+ public Exception fromResponse(final Response r) {
+ throw new UnsupportedOperationException(
+ "Call of fromResponse() method is not expected in RestServiceExceptionMapper");
+ }
+
+ private Response processCompositeExceptions(Exception ex) {
+ Response response = null;
+
+ if (ex instanceof SyncopeClientCompositeErrorException) {
+ ResponseBuilder responseBuilder = Response.status(((SyncopeClientCompositeErrorException) ex)
+ .getStatusCode().value());
+ for (SyncopeClientException sce : ((SyncopeClientCompositeErrorException) ex).getExceptions()) {
+ responseBuilder.header(EXCEPTION_TYPE_HEADER, sce.getType().getHeaderValue());
+
+ for (String attributeName : sce.getElements()) {
+ responseBuilder.header(sce.getType().getElementHeaderName(), attributeName);
+ }
+ }
+ response = responseBuilder.build();
+ }
+ return response;
+ }
+
+ private Response processForbiddenExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.FORBIDDEN);
+
+ if (ex instanceof UnauthorizedRoleException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.UnauthorizedRole.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.UnauthorizedRole.getElementHeaderName(), ex.getMessage());
+ response = responseBuilder.build();
+ }
+ return response;
+ }
+
+ private Response processUnauthorizedExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.UNAUTHORIZED);
+
+ if (ex instanceof org.springframework.security.access.AccessDeniedException) {
+ response = responseBuilder.header(HttpHeaders.WWW_AUTHENTICATE, BASIC_REALM_UNAUTHORIZED).build();
+ }
+ return response;
+ }
+
+ private Response processConflictExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.CONFLICT);
+
+ if (ex instanceof DataIntegrityViolationException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.DataIntegrityViolation.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.DataIntegrityViolation.getElementHeaderName(),
+ ex.getCause() == null
+ ? ex.getMessage()
+ : ex.getCause().getMessage());
+ response = responseBuilder.build();
+ }
+ return response;
+ }
+
+ private Response processServerErrorExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
+
+ if (ex instanceof org.apache.ibatis.exceptions.PersistenceException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.Workflow.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.Workflow.getElementHeaderName(),
+ "Currently unavailable. Please try later.");
+ response = responseBuilder.build();
+
+ } else if (ex instanceof JpaSystemException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.DataIntegrityViolation.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.DataIntegrityViolation.getElementHeaderName(),
+ ex.getCause() == null
+ ? ex.getMessage()
+ : ex.getCause().getMessage());
+ response = responseBuilder.build();
+
+ } else if (ex instanceof PersistenceException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.GenericPersistence.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.GenericPersistence.getElementHeaderName(),
+ ex.getCause() == null
+ ? ex.getMessage()
+ : ex.getCause().getMessage());
+ response = responseBuilder.build();
+
+ } else if (ex instanceof ConfigurationException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.InvalidExternalResource.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.InvalidExternalResource.getElementHeaderName(),
+ ex.getCause() == null
+ ? ex.getMessage()
+ : ex.getCause().getMessage());
+ response = responseBuilder.build();
+ }
+
+ return response;
+ }
+
+ private Response processNotFoundExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.NOT_FOUND);
+
+ if (ex instanceof NotFoundException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.NotFound.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.NotFound.getElementHeaderName(), ex.getMessage());
+ response = responseBuilder.build();
+
+ } else if (ex instanceof MissingConfKeyException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.NotFound.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.NotFound.getElementHeaderName(),
+ ((MissingConfKeyException) ex).getConfKey());
+ response = responseBuilder.build();
+ }
+
+ return response;
+ }
+
+ private Response processBadRequestExceptions(Exception ex) {
+ Response response = null;
+ ResponseBuilder responseBuilder = Response.status(Response.Status.BAD_REQUEST);
+
+ if (ex instanceof InvalidEntityException) {
+ SyncopeClientExceptionType exType = SyncopeClientExceptionType.valueOf("Invalid"
+ + ((InvalidEntityException) ex).getEntityClassSimpleName());
+
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER, exType.getHeaderValue());
+
+ for (@SuppressWarnings("rawtypes")
+ Entry<Class, Set<EntityViolationType>> violation : ((InvalidEntityException) ex).getViolations().entrySet()) {
+
+ for (EntityViolationType violationType : violation.getValue()) {
+ responseBuilder.header(exType.getElementHeaderName(), violation.getClass().getSimpleName() + ": "
+ + violationType);
+ }
+ }
+ response = responseBuilder.build();
+
+ } else if (ex instanceof WorkflowException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.Workflow.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.Workflow.getElementHeaderName(), ex.getCause()
+ .getMessage());
+ response = responseBuilder.build();
+
+ } else if (ex instanceof PropagationException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.Propagation.getHeaderValue());
+ responseBuilder.header(SyncopeClientExceptionType.Propagation.getElementHeaderName(),
+ ((PropagationException) ex).getResourceName());
+ response = responseBuilder.build();
+
+ } else if (ex instanceof InvalidSearchConditionException) {
+ responseBuilder.header(SyncopeClientErrorHandler.EXCEPTION_TYPE_HEADER,
+ SyncopeClientExceptionType.InvalidSearchCondition.getHeaderValue());
+ response = responseBuilder.build();
+ }
+
+ return response;
+ }
+
+}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.syncope.client.to.ConfigurationTO;
+import org.apache.syncope.client.to.MailTemplateTO;
+import org.apache.syncope.client.to.ValidatorTO;
+import org.apache.syncope.client.util.CollectionWrapper;
+import org.apache.syncope.core.persistence.dao.MissingConfKeyException;
+import org.apache.syncope.core.rest.controller.ConfigurationController;
+import org.apache.syncope.services.ConfigurationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ConfigurationServiceImpl implements ConfigurationService, ContextAware {
+
+ @Autowired
+ private ConfigurationController configurationController;
+ private UriInfo uriInfo;
+
+ @Override
+ public Response create(final ConfigurationTO configurationTO) {
+ ConfigurationTO created = configurationController.create(new DummyHTTPServletResponse(), configurationTO);
+ URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
+ return Response.created(location).entity(created).build();
+ }
+
+ @Override
+ public Response dbExport() {
+ configurationController.dbExport(new DummyHTTPServletResponse());
+ // TODO catch output-stream and forward it to response
+ return null;
+ }
+
+ @Override
+ public void delete(final String key) {
+ try {
+ configurationController.delete(key);
+ } catch (MissingConfKeyException e) {
+ throw new NotFoundException(e);
+ }
+ }
+
+ @Override
+ public Set<MailTemplateTO> getMailTemplates() {
+ return CollectionWrapper.wrapMailTemplates(configurationController.getMailTemplates());
+ }
+
+ @Override
+ public Set<ValidatorTO> getValidators() {
+ return CollectionWrapper.wrapValidator(configurationController.getValidators());
+ }
+
+ @Override
+ public List<ConfigurationTO> list() {
+ return configurationController.list(null);
+ }
+
+ @Override
+ public ConfigurationTO read(String key) {
+ try {
+ return configurationController.read(null, key);
+ } catch (MissingConfKeyException e) {
+ throw new NotFoundException(e);
+ }
+ }
+
+ @Override
+ public ConfigurationTO update(String key, ConfigurationTO configurationTO) {
+ try {
+ return configurationController.update(null, configurationTO);
+ } catch (MissingConfKeyException e) {
+ throw new NotFoundException(e);
+ }
+ }
+
+ @Override
+ public void setUriInfo(UriInfo ui) {
+ this.uriInfo = ui;
+ }
+}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ContextAware.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+public interface ContextAware {
+
+ @Context
+ void setUriInfo(UriInfo ui);
+}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/DummyHTTPServletResponse.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+public class DummyHTTPServletResponse implements HttpServletResponse {
+
+ @Override
+ public void flushBuffer() throws IOException {
+ }
+
+ @Override
+ public int getBufferSize() {
+ return 0;
+ }
+
+ @Override
+ public String getCharacterEncoding() {
+ return null;
+ }
+
+ @Override
+ public String getContentType() {
+ return null;
+ }
+
+ @Override
+ public Locale getLocale() {
+ return null;
+ }
+
+ @Override
+ public ServletOutputStream getOutputStream() throws IOException {
+ return null;
+ }
+
+ @Override
+ public PrintWriter getWriter() throws IOException {
+ return null;
+ }
+
+ @Override
+ public boolean isCommitted() {
+ return false;
+ }
+
+ @Override
+ public void reset() {
+ }
+
+ @Override
+ public void resetBuffer() {
+ }
+
+ @Override
+ public void setBufferSize(int arg0) {
+ }
+
+ @Override
+ public void setCharacterEncoding(String arg0) {
+ }
+
+ @Override
+ public void setContentLength(int arg0) {
+ }
+
+ @Override
+ public void setContentType(String arg0) {
+ }
+
+ @Override
+ public void setLocale(Locale arg0) {
+ }
+
+ @Override
+ public void addCookie(Cookie arg0) {
+ }
+
+ @Override
+ public void addDateHeader(String arg0, long arg1) {
+ }
+
+ @Override
+ public void addHeader(String arg0, String arg1) {
+ }
+
+ @Override
+ public void addIntHeader(String arg0, int arg1) {
+ }
+
+ @Override
+ public boolean containsHeader(String arg0) {
+ return false;
+ }
+
+ @Override
+ public String encodeRedirectURL(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String encodeRedirectUrl(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String encodeURL(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String encodeUrl(String arg0) {
+ return null;
+ }
+
+ @Override
+ public void sendError(int arg0) throws IOException {
+ }
+
+ @Override
+ public void sendError(int arg0, String arg1) throws IOException {
+ }
+
+ @Override
+ public void sendRedirect(String arg0) throws IOException {
+ }
+
+ @Override
+ public void setDateHeader(String arg0, long arg1) {
+ }
+
+ @Override
+ public void setHeader(String arg0, String arg1) {
+ }
+
+ @Override
+ public void setIntHeader(String arg0, int arg1) {
+ }
+
+ @Override
+ public void setStatus(int arg0) {
+ }
+
+ @Override
+ public void setStatus(int arg0, String arg1) {
+ }
+
+}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java?rev=1435135&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/EntitlementServiceImpl.java Fri Jan 18 13:51:53 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.services;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.syncope.client.to.EntitlementTO;
+import org.apache.syncope.client.util.CollectionWrapper;
+import org.apache.syncope.core.rest.controller.AuthenticationController;
+import org.apache.syncope.services.EntitlementService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class EntitlementServiceImpl implements EntitlementService {
+
+ @Autowired
+ private AuthenticationController authenticationController;
+
+ @Override
+ public Set<EntitlementTO> getAllEntitlements() {
+ Set<String> entitlements = new HashSet<String>(authenticationController.listEntitlements());
+ return CollectionWrapper.wrap(entitlements);
+ }
+
+ @Override
+ public Set<EntitlementTO> getMyEntitlements() {
+ Set<String> entitlements = authenticationController.getEntitlements();
+ return CollectionWrapper.wrap(entitlements);
+ }
+}