syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/4] syncope git commit: [SYNCOPE-152] Support for attributes and excludedAttributes for read, list and search operations
Date Sat, 09 Dec 2017 15:31:38 GMT
[SYNCOPE-152] Support for attributes and excludedAttributes for read, list and search operations


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/15295e58
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/15295e58
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/15295e58

Branch: refs/heads/2_0_X
Commit: 15295e5800c726496f236db2bbf33b00212909b4
Parents: 568b4ed
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Sat Dec 9 15:45:06 2017 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Sat Dec 9 15:45:06 2017 +0100

----------------------------------------------------------------------
 .../syncope/core/logic/SCIMDataBinder.java      | 202 ++++++++++++-------
 .../apache/syncope/core/logic/SCIMLogic.java    |   2 +-
 .../ext/scimv2/api/service/GroupService.java    |   8 +-
 .../ext/scimv2/api/service/ReadService.java     |  60 ++++++
 .../ext/scimv2/api/service/SCIMService.java     |   3 +-
 .../ext/scimv2/api/service/SearchService.java   |  52 -----
 .../ext/scimv2/api/service/UserService.java     |   8 +-
 .../ext/scimv2/cxf/service/AbstractService.java |  38 +---
 .../scimv2/cxf/service/GroupServiceImpl.java    |  36 ++--
 .../ext/scimv2/cxf/service/UserServiceImpl.java |  36 ++--
 .../org/apache/syncope/fit/core/SCIMITCase.java |  20 +-
 11 files changed, 264 insertions(+), 201 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
index 3dd3615..39f6b0f 100644
--- a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
+++ b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
@@ -99,7 +99,32 @@ public class SCIMDataBinder {
         }
     }
 
-    public SCIMUser toSCIMUser(final UserTO userTO, final String location) {
+    private boolean output(
+            final List<String> attributes,
+            final List<String> excludedAttributes,
+            final String schema) {
+
+        return (attributes.isEmpty() || attributes.contains(schema))
+                && (excludedAttributes.isEmpty() || !excludedAttributes.contains(schema));
+    }
+
+    private <T> T output(
+            final List<String> attributes,
+            final List<String> excludedAttributes,
+            final String schema,
+            final T value) {
+
+        return output(attributes, excludedAttributes, schema)
+                ? value
+                : null;
+    }
+
+    public SCIMUser toSCIMUser(
+            final UserTO userTO,
+            final String location,
+            final List<String> attributes,
+            final List<String> excludedAttributes) {
+
         SCIMConf conf = confManager.get();
 
         List<String> schemas = new ArrayList<>();
@@ -118,7 +143,7 @@ public class SCIMDataBinder {
                         ? userTO.getCreationDate() : userTO.getLastChangeDate(),
                         userTO.getETagValue(),
                         location),
-                userTO.getUsername(),
+                output(attributes, excludedAttributes, "userName", userTO.getUsername()),
                 !userTO.isSuspended());
 
         Map<String, AttrTO> attrs = new HashMap<>();
@@ -127,7 +152,7 @@ public class SCIMDataBinder {
         attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getVirAttrs()));
 
         if (conf.getUserConf() != null) {
-            if (conf.getUserConf().getName() != null) {
+            if (output(attributes, excludedAttributes, "name") && conf.getUserConf().getName()
!= null) {
                 SCIMUserName name = new SCIMUserName();
 
                 if (conf.getUserConf().getName().getFamilyName() != null
@@ -168,91 +193,111 @@ public class SCIMDataBinder {
                 }
             }
 
-            if (conf.getUserConf().getDisplayName() != null
+            if (output(attributes, excludedAttributes, "displayName")
+                    && conf.getUserConf().getDisplayName() != null
                     && attrs.containsKey(conf.getUserConf().getDisplayName())) {
 
                 user.setDisplayName(attrs.get(conf.getUserConf().getDisplayName()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getNickName() != null
+            if (output(attributes, excludedAttributes, "nickName")
+                    && conf.getUserConf().getNickName() != null
                     && attrs.containsKey(conf.getUserConf().getNickName())) {
 
                 user.setNickName(attrs.get(conf.getUserConf().getNickName()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getProfileUrl() != null
+            if (output(attributes, excludedAttributes, "profileUrl")
+                    && conf.getUserConf().getProfileUrl() != null
                     && attrs.containsKey(conf.getUserConf().getProfileUrl())) {
 
                 user.setProfileUrl(attrs.get(conf.getUserConf().getProfileUrl()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getTitle() != null
+            if (output(attributes, excludedAttributes, "title")
+                    && conf.getUserConf().getTitle() != null
                     && attrs.containsKey(conf.getUserConf().getTitle())) {
 
                 user.setTitle(attrs.get(conf.getUserConf().getTitle()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getUserType() != null
+            if (output(attributes, excludedAttributes, "userType")
+                    && conf.getUserConf().getUserType() != null
                     && attrs.containsKey(conf.getUserConf().getUserType())) {
 
                 user.setUserType(attrs.get(conf.getUserConf().getUserType()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getPreferredLanguage() != null
+            if (output(attributes, excludedAttributes, "preferredLanguage")
+                    && conf.getUserConf().getPreferredLanguage() != null
                     && attrs.containsKey(conf.getUserConf().getPreferredLanguage()))
{
 
                 user.setPreferredLanguage(attrs.get(conf.getUserConf().getPreferredLanguage()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getLocale() != null
+            if (output(attributes, excludedAttributes, "locale")
+                    && conf.getUserConf().getLocale() != null
                     && attrs.containsKey(conf.getUserConf().getLocale())) {
 
                 user.setLocale(attrs.get(conf.getUserConf().getLocale()).getValues().get(0));
             }
 
-            if (conf.getUserConf().getTimezone() != null
+            if (output(attributes, excludedAttributes, "timezone")
+                    && conf.getUserConf().getTimezone() != null
                     && attrs.containsKey(conf.getUserConf().getTimezone())) {
 
                 user.setTimezone(attrs.get(conf.getUserConf().getTimezone()).getValues().get(0));
             }
 
-            fill(attrs, conf.getUserConf().getEmails(), user.getEmails());
-            fill(attrs, conf.getUserConf().getPhoneNumbers(), user.getPhoneNumbers());
-            fill(attrs, conf.getUserConf().getIms(), user.getIms());
-            fill(attrs, conf.getUserConf().getPhotos(), user.getPhotos());
-            for (SCIMUserAddressConf addressConf : conf.getUserConf().getAddresses()) {
-                SCIMUserAddress address = new SCIMUserAddress();
+            if (output(attributes, excludedAttributes, "emails")) {
+                fill(attrs, conf.getUserConf().getEmails(), user.getEmails());
+            }
+            if (output(attributes, excludedAttributes, "phoneNumbers")) {
+                fill(attrs, conf.getUserConf().getPhoneNumbers(), user.getPhoneNumbers());
+            }
+            if (output(attributes, excludedAttributes, "ims")) {
+                fill(attrs, conf.getUserConf().getIms(), user.getIms());
+            }
+            if (output(attributes, excludedAttributes, "photos")) {
+                fill(attrs, conf.getUserConf().getPhotos(), user.getPhotos());
+            }
+            if (output(attributes, excludedAttributes, "addresses")) {
+                for (SCIMUserAddressConf addressConf : conf.getUserConf().getAddresses())
{
+                    SCIMUserAddress address = new SCIMUserAddress();
 
-                if (addressConf.getFormatted() != null && attrs.containsKey(addressConf.getFormatted()))
{
-                    address.setFormatted(attrs.get(addressConf.getFormatted()).getValues().get(0));
-                }
-                if (addressConf.getStreetAddress() != null && attrs.containsKey(addressConf.getStreetAddress()))
{
-                    address.setStreetAddress(attrs.get(addressConf.getStreetAddress()).getValues().get(0));
-                }
-                if (addressConf.getLocality() != null && attrs.containsKey(addressConf.getLocality()))
{
-                    address.setLocality(attrs.get(addressConf.getLocality()).getValues().get(0));
-                }
-                if (addressConf.getRegion() != null && attrs.containsKey(addressConf.getRegion()))
{
-                    address.setRegion(attrs.get(addressConf.getRegion()).getValues().get(0));
-                }
-                if (addressConf.getCountry() != null && attrs.containsKey(addressConf.getCountry()))
{
-                    address.setCountry(attrs.get(addressConf.getCountry()).getValues().get(0));
-                }
-                if (addressConf.getType() != null) {
-                    address.setType(addressConf.getType().name());
-                }
-                if (addressConf.isPrimary()) {
-                    address.setPrimary(true);
-                }
+                    if (addressConf.getFormatted() != null && attrs.containsKey(addressConf.getFormatted()))
{
+                        address.setFormatted(attrs.get(addressConf.getFormatted()).getValues().get(0));
+                    }
+                    if (addressConf.getStreetAddress() != null && attrs.containsKey(addressConf.getStreetAddress()))
{
+                        address.setStreetAddress(attrs.get(addressConf.getStreetAddress()).getValues().get(0));
+                    }
+                    if (addressConf.getLocality() != null && attrs.containsKey(addressConf.getLocality()))
{
+                        address.setLocality(attrs.get(addressConf.getLocality()).getValues().get(0));
+                    }
+                    if (addressConf.getRegion() != null && attrs.containsKey(addressConf.getRegion()))
{
+                        address.setRegion(attrs.get(addressConf.getRegion()).getValues().get(0));
+                    }
+                    if (addressConf.getCountry() != null && attrs.containsKey(addressConf.getCountry()))
{
+                        address.setCountry(attrs.get(addressConf.getCountry()).getValues().get(0));
+                    }
+                    if (addressConf.getType() != null) {
+                        address.setType(addressConf.getType().name());
+                    }
+                    if (addressConf.isPrimary()) {
+                        address.setPrimary(true);
+                    }
 
-                if (!address.isEmpty()) {
-                    user.getAddresses().add(address);
+                    if (!address.isEmpty()) {
+                        user.getAddresses().add(address);
+                    }
                 }
             }
 
-            for (String certificate : conf.getUserConf().getX509Certificates()) {
-                if (attrs.containsKey(certificate)) {
-                    user.getX509Certificates().add(new Value(attrs.get(certificate).getValues().get(0)));
+            if (output(attributes, excludedAttributes, "x509Certificates")) {
+                for (String certificate : conf.getUserConf().getX509Certificates()) {
+                    if (attrs.containsKey(certificate)) {
+                        user.getX509Certificates().add(new Value(attrs.get(certificate).getValues().get(0)));
+                    }
                 }
             }
         }
@@ -260,37 +305,44 @@ public class SCIMDataBinder {
         if (conf.getEnterpriseUserConf() != null) {
             SCIMEnterpriseInfo enterpriseInfo = new SCIMEnterpriseInfo();
 
-            if (conf.getEnterpriseUserConf().getEmployeeNumber() != null
+            if (output(attributes, excludedAttributes, "employeeNumber")
+                    && conf.getEnterpriseUserConf().getEmployeeNumber() != null
                     && attrs.containsKey(conf.getEnterpriseUserConf().getEmployeeNumber()))
{
 
                 enterpriseInfo.setEmployeeNumber(
                         attrs.get(conf.getEnterpriseUserConf().getEmployeeNumber()).getValues().get(0));
             }
-            if (conf.getEnterpriseUserConf().getCostCenter() != null
+            if (output(attributes, excludedAttributes, "costCenter")
+                    && conf.getEnterpriseUserConf().getCostCenter() != null
                     && attrs.containsKey(conf.getEnterpriseUserConf().getCostCenter()))
{
 
                 enterpriseInfo.setCostCenter(
                         attrs.get(conf.getEnterpriseUserConf().getCostCenter()).getValues().get(0));
             }
-            if (conf.getEnterpriseUserConf().getOrganization() != null
+            if (output(attributes, excludedAttributes, "organization")
+                    && conf.getEnterpriseUserConf().getOrganization() != null
                     && attrs.containsKey(conf.getEnterpriseUserConf().getOrganization()))
{
 
                 enterpriseInfo.setOrganization(
                         attrs.get(conf.getEnterpriseUserConf().getOrganization()).getValues().get(0));
             }
-            if (conf.getEnterpriseUserConf().getDivision() != null
+            if (output(attributes, excludedAttributes, "division")
+                    && conf.getEnterpriseUserConf().getDivision() != null
                     && attrs.containsKey(conf.getEnterpriseUserConf().getDivision()))
{
 
                 enterpriseInfo.setDivision(
                         attrs.get(conf.getEnterpriseUserConf().getDivision()).getValues().get(0));
             }
-            if (conf.getEnterpriseUserConf().getDepartment() != null
+            if (output(attributes, excludedAttributes, "department")
+                    && conf.getEnterpriseUserConf().getDepartment() != null
                     && attrs.containsKey(conf.getEnterpriseUserConf().getDepartment()))
{
 
                 enterpriseInfo.setDepartment(
                         attrs.get(conf.getEnterpriseUserConf().getDepartment()).getValues().get(0));
             }
-            if (conf.getEnterpriseUserConf().getManager() != null) {
+            if (output(attributes, excludedAttributes, "manager")
+                    && conf.getEnterpriseUserConf().getManager() != null) {
+
                 SCIMUserManager manager = new SCIMUserManager();
 
                 if (conf.getEnterpriseUserConf().getManager().getManager() != null
@@ -319,7 +371,7 @@ public class SCIMDataBinder {
                             }
                         }
                     } catch (Exception e) {
-                        LOG.error("Could not read attribute {}",
+                        LOG.error("Could not read user {}",
                                 conf.getEnterpriseUserConf().getManager().getManager(), e);
                     }
                 }
@@ -334,33 +386,45 @@ public class SCIMDataBinder {
             }
         }
 
-        for (MembershipTO membership : userTO.getMemberships()) {
-            user.getGroups().add(new Group(
-                    membership.getGroupKey(),
-                    StringUtils.substringBefore(location, "/Users") + "/Groups/" + membership.getGroupKey(),
-                    membership.getGroupName(),
-                    Function.direct));
-        }
-        for (MembershipTO membership : userTO.getDynMemberships()) {
-            user.getGroups().add(new Group(
-                    membership.getGroupKey(),
-                    StringUtils.substringBefore(location, "/Users") + "/Groups/" + membership.getGroupKey(),
-                    membership.getGroupName(),
-                    Function.indirect));
+        if (output(attributes, excludedAttributes, "groups")) {
+            for (MembershipTO membership : userTO.getMemberships()) {
+                user.getGroups().add(new Group(
+                        membership.getGroupKey(),
+                        StringUtils.substringBefore(location, "/Users") + "/Groups/" + membership.getGroupKey(),
+                        membership.getGroupName(),
+                        Function.direct));
+            }
+            for (MembershipTO membership : userTO.getDynMemberships()) {
+                user.getGroups().add(new Group(
+                        membership.getGroupKey(),
+                        StringUtils.substringBefore(location, "/Users") + "/Groups/" + membership.getGroupKey(),
+                        membership.getGroupName(),
+                        Function.indirect));
+            }
         }
 
-        for (SyncopeGrantedAuthority authority : authDataAccessor.getAuthorities(userTO.getUsername()))
{
-            user.getEntitlements().add(new Value(authority.getAuthority() + " on Realm(s)
" + authority.getRealms()));
+        if (output(attributes, excludedAttributes, "entitlements")) {
+            for (SyncopeGrantedAuthority authority : authDataAccessor.getAuthorities(userTO.getUsername()))
{
+                user.getEntitlements().add(
+                        new Value(authority.getAuthority() + " on Realm(s) " + authority.getRealms()));
+            }
         }
 
-        for (String role : userTO.getRoles()) {
-            user.getRoles().add(new Value(role));
+        if (output(attributes, excludedAttributes, "roles")) {
+            for (String role : userTO.getRoles()) {
+                user.getRoles().add(new Value(role));
+            }
         }
 
         return user;
     }
 
-    public SCIMGroup toSCIMGroup(final GroupTO groupTO, final String location) {
+    public SCIMGroup toSCIMGroup(
+            final GroupTO groupTO,
+            final String location,
+            final List<String> attributes,
+            final List<String> excludedAttributes) {
+
         SCIMGroup group = new SCIMGroup(
                 groupTO.getKey(),
                 new Meta(
@@ -370,7 +434,7 @@ public class SCIMDataBinder {
                         ? groupTO.getCreationDate() : groupTO.getLastChangeDate(),
                         groupTO.getETagValue(),
                         location),
-                groupTO.getName());
+                output(attributes, excludedAttributes, "name", groupTO.getName()));
 
         MembershipCond membCond = new MembershipCond();
         membCond.setGroup(groupTO.getKey());

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
index 11085fb..cfb48f9 100644
--- a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
+++ b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMLogic.java
@@ -103,7 +103,7 @@ public class SCIMLogic extends AbstractLogic<AbstractBaseBean> {
                                 conf.getETagValue(),
                                 uriBuilder.build().toASCIIString()),
                         new ConfigurationOption(true),
-                        new BulkConfigurationOption(true, conf.getBulkMaxOperations(), conf.getBulkMaxPayloadSize()),
+                        new BulkConfigurationOption(false, conf.getBulkMaxOperations(), conf.getBulkMaxPayloadSize()),
                         new FilterConfigurationOption(true, conf.getFilterMaxResults()),
                         new ConfigurationOption(true),
                         new ConfigurationOption(true),

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/GroupService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/GroupService.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/GroupService.java
index 196572e..ac7c0a0 100644
--- a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/GroupService.java
+++ b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/GroupService.java
@@ -21,7 +21,6 @@ package org.apache.syncope.ext.scimv2.api.service;
 import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -33,18 +32,13 @@ import org.apache.syncope.ext.scimv2.api.SCIMConstants;
 import org.apache.syncope.ext.scimv2.api.data.SCIMGroup;
 
 @Path("v2/Groups")
-public interface GroupService extends SearchService<SCIMGroup> {
+public interface GroupService extends ReadService<SCIMGroup> {
 
     @POST
     @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
     @Consumes({ SCIMConstants.APPLICATION_SCIM_JSON })
     Response create();
 
-    @GET
-    @Path("{id}")
-    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
-    SCIMGroup read(@NotNull @PathParam("id") String id);
-
     @PUT
     @Path("{id}")
     @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/ReadService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/ReadService.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/ReadService.java
new file mode 100644
index 0000000..4762dd3
--- /dev/null
+++ b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/ReadService.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ext.scimv2.api.service;
+
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import org.apache.syncope.ext.scimv2.api.SCIMConstants;
+import org.apache.syncope.ext.scimv2.api.data.ListResponse;
+import org.apache.syncope.ext.scimv2.api.data.SCIMResource;
+import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
+import org.apache.syncope.ext.scimv2.api.type.SortOrder;
+
+public interface ReadService<R extends SCIMResource> {
+
+    @GET
+    @Path("{id}")
+    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
+    R get(@NotNull @PathParam("id") String id,
+            @QueryParam("attributes") String attributes,
+            @QueryParam("excludedAttributes") String excludedAttributes);
+
+    @GET
+    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
+    ListResponse<R> search(
+            @QueryParam("attributes") String attributes,
+            @QueryParam("excludedAttributes") String excludedAttributes,
+            @QueryParam("filter") String filter,
+            @QueryParam("sortBy") String sortBy,
+            @QueryParam("sortOrder") SortOrder sortOrder,
+            @QueryParam("startIndex") Integer startIndex,
+            @QueryParam("count") Integer count);
+
+    @POST
+    @Path(".search")
+    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
+    @Consumes({ SCIMConstants.APPLICATION_SCIM_JSON })
+    ListResponse<R> search(SCIMSearchRequest request);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SCIMService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SCIMService.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SCIMService.java
index 6064747..06ad1d5 100644
--- a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SCIMService.java
+++ b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SCIMService.java
@@ -26,11 +26,10 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 import org.apache.syncope.ext.scimv2.api.SCIMConstants;
 import org.apache.syncope.ext.scimv2.api.data.ResourceType;
-import org.apache.syncope.ext.scimv2.api.data.SCIMResource;
 import org.apache.syncope.ext.scimv2.api.data.ServiceProviderConfig;
 
 @Path("v2")
-public interface SCIMService extends SearchService<SCIMResource> {
+public interface SCIMService {
 
     @GET
     @Path("ServiceProviderConfig")

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SearchService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SearchService.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SearchService.java
deleted file mode 100644
index d6cbaf5..0000000
--- a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/SearchService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.ext.scimv2.api.service;
-
-import java.util.List;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import org.apache.syncope.ext.scimv2.api.SCIMConstants;
-import org.apache.syncope.ext.scimv2.api.data.ListResponse;
-import org.apache.syncope.ext.scimv2.api.data.SCIMResource;
-import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
-import org.apache.syncope.ext.scimv2.api.type.SortOrder;
-
-public interface SearchService<R extends SCIMResource> {
-
-    @GET
-    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
-    ListResponse<R> search(
-            @QueryParam("attributes") List<String> attributes,
-            @QueryParam("excludedAttributes") List<String> excludedAttributes,
-            @QueryParam("filter") String filter,
-            @QueryParam("sortBy") String sortBy,
-            @QueryParam("sortOrder") SortOrder sortOrder,
-            @QueryParam("startIndex") Integer startIndex,
-            @QueryParam("count") Integer count);
-
-    @POST
-    @Path(".search")
-    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
-    @Consumes({ SCIMConstants.APPLICATION_SCIM_JSON })
-    ListResponse<R> search(SCIMSearchRequest request);
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/UserService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/UserService.java
b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/UserService.java
index 1135650..febb5e4 100644
--- a/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/UserService.java
+++ b/ext/scimv2/scim-rest-api/src/main/java/org/apache/syncope/ext/scimv2/api/service/UserService.java
@@ -21,7 +21,6 @@ package org.apache.syncope.ext.scimv2.api.service;
 import javax.validation.constraints.NotNull;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -33,18 +32,13 @@ import org.apache.syncope.ext.scimv2.api.SCIMConstants;
 import org.apache.syncope.ext.scimv2.api.data.SCIMUser;
 
 @Path("v2/Users")
-public interface UserService extends SearchService<SCIMUser> {
+public interface UserService extends ReadService<SCIMUser> {
 
     @POST
     @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
     @Consumes({ SCIMConstants.APPLICATION_SCIM_JSON })
     Response create();
 
-    @GET
-    @Path("{id}")
-    @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })
-    SCIMUser read(@NotNull @PathParam("id") String id);
-
     @PUT
     @Path("{id}")
     @Produces({ SCIMConstants.APPLICATION_SCIM_JSON })

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
index 4274041..a7c1904 100644
--- a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
+++ b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/AbstractService.java
@@ -41,12 +41,10 @@ import org.apache.syncope.ext.scimv2.api.data.ListResponse;
 import org.apache.syncope.ext.scimv2.api.data.SCIMResource;
 import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
 import org.apache.syncope.ext.scimv2.api.type.Resource;
-import org.apache.syncope.ext.scimv2.api.type.SortOrder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.syncope.ext.scimv2.api.service.SearchService;
 
-abstract class AbstractService<R extends SCIMResource> implements SearchService<R>
{
+abstract class AbstractService<R extends SCIMResource> {
 
     protected static final Logger LOG = LoggerFactory.getLogger(AbstractService.class);
 
@@ -131,11 +129,15 @@ abstract class AbstractService<R extends SCIMResource> implements
SearchService<
             if (anyTO instanceof UserTO) {
                 resource = binder().toSCIMUser(
                         (UserTO) anyTO,
-                        uriInfo.getAbsolutePathBuilder().path(anyTO.getKey()).build().toASCIIString());
+                        uriInfo.getAbsolutePathBuilder().path(anyTO.getKey()).build().toASCIIString(),
+                        request.getAttributes(),
+                        request.getExcludedAttributes());
             } else if (anyTO instanceof GroupTO) {
                 resource = binder().toSCIMGroup(
                         (GroupTO) anyTO,
-                        uriInfo.getAbsolutePathBuilder().path(anyTO.getKey()).build().toASCIIString());
+                        uriInfo.getAbsolutePathBuilder().path(anyTO.getKey()).build().toASCIIString(),
+                        request.getAttributes(),
+                        request.getExcludedAttributes());
             }
 
             if (resource != null) {
@@ -146,30 +148,4 @@ abstract class AbstractService<R extends SCIMResource> implements
SearchService<
         return response;
     }
 
-    @Override
-    public ListResponse<R> search(
-            final List<String> attributes,
-            final List<String> excludedAttributes,
-            final String filter,
-            final String sortBy,
-            final SortOrder sortOrder,
-            final Integer startIndex,
-            final Integer count) {
-
-        SCIMSearchRequest request = new SCIMSearchRequest(filter, sortBy, sortOrder, startIndex,
count);
-        if (attributes != null) {
-            request.getAttributes().addAll(attributes);
-        }
-        if (excludedAttributes != null) {
-            request.getExcludedAttributes().addAll(excludedAttributes);
-        }
-
-        return doSearch(null, request);
-    }
-
-    @Override
-    public ListResponse<R> search(final SCIMSearchRequest request) {
-        return doSearch(null, request);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/GroupServiceImpl.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/GroupServiceImpl.java
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/GroupServiceImpl.java
index fdc47aa..439d250 100644
--- a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/GroupServiceImpl.java
+++ b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/GroupServiceImpl.java
@@ -18,9 +18,10 @@
  */
 package org.apache.syncope.ext.scimv2.cxf.service;
 
-import java.util.List;
-import java.util.UUID;
+import java.util.Arrays;
 import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.ext.scimv2.api.data.ListResponse;
 import org.apache.syncope.ext.scimv2.api.data.SCIMGroup;
 import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
@@ -32,35 +33,40 @@ public class GroupServiceImpl extends AbstractService<SCIMGroup>
implements Grou
 
     @Override
     public Response create() {
-        return Response.
-                created(uriInfo.getAbsolutePathBuilder().path(UUID.randomUUID().toString()).build()).
-                build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
-    public SCIMGroup read(final String id) {
-        return binder().toSCIMGroup(groupLogic().read(id), uriInfo.getAbsolutePathBuilder().build().toASCIIString());
+    public SCIMGroup get(final String id,
+            final String attributes,
+            final String excludedAttributes) {
+
+        return binder().toSCIMGroup(
+                groupLogic().read(id),
+                uriInfo.getAbsolutePathBuilder().build().toASCIIString(),
+                Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(attributes, ','))),
+                Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(excludedAttributes,
','))));
     }
 
     @Override
     public Response replace(final String id) {
-        return Response.ok().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public Response delete(final String id) {
-        return Response.noContent().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public Response update(final String id) {
-        return Response.ok().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public ListResponse<SCIMGroup> search(
-            final List<String> attributes,
-            final List<String> excludedAttributes,
+            final String attributes,
+            final String excludedAttributes,
             final String filter,
             final String sortBy,
             final SortOrder sortOrder,
@@ -69,10 +75,12 @@ public class GroupServiceImpl extends AbstractService<SCIMGroup>
implements Grou
 
         SCIMSearchRequest request = new SCIMSearchRequest(filter, sortBy, sortOrder, startIndex,
count);
         if (attributes != null) {
-            request.getAttributes().addAll(attributes);
+            request.getAttributes().addAll(
+                    Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(attributes, ','))));
         }
         if (excludedAttributes != null) {
-            request.getExcludedAttributes().addAll(excludedAttributes);
+            request.getExcludedAttributes().addAll(
+                    Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(excludedAttributes,
','))));
         }
 
         return doSearch(Resource.Group, request);

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/UserServiceImpl.java
----------------------------------------------------------------------
diff --git a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/UserServiceImpl.java
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/UserServiceImpl.java
index 0f98362..6a9078f 100644
--- a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/UserServiceImpl.java
+++ b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/UserServiceImpl.java
@@ -18,9 +18,10 @@
  */
 package org.apache.syncope.ext.scimv2.cxf.service;
 
-import java.util.List;
-import java.util.UUID;
+import java.util.Arrays;
 import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.ext.scimv2.api.data.ListResponse;
 import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
 import org.apache.syncope.ext.scimv2.api.data.SCIMUser;
@@ -32,35 +33,40 @@ public class UserServiceImpl extends AbstractService<SCIMUser> implements
UserSe
 
     @Override
     public Response create() {
-        return Response.
-                created(uriInfo.getAbsolutePathBuilder().path(UUID.randomUUID().toString()).build()).
-                build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
-    public SCIMUser read(final String id) {
-        return binder().toSCIMUser(userLogic().read(id), uriInfo.getAbsolutePathBuilder().build().toASCIIString());
+    public SCIMUser get(final String id,
+            final String attributes,
+            final String excludedAttributes) {
+
+        return binder().toSCIMUser(
+                userLogic().read(id),
+                uriInfo.getAbsolutePathBuilder().build().toASCIIString(),
+                Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(attributes, ','))),
+                Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(excludedAttributes,
','))));
     }
 
     @Override
     public Response replace(final String id) {
-        return Response.ok().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public Response delete(final String id) {
-        return Response.noContent().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public Response update(final String id) {
-        return Response.ok().build();
+        return Response.status(Response.Status.NOT_IMPLEMENTED).build();
     }
 
     @Override
     public ListResponse<SCIMUser> search(
-            final List<String> attributes,
-            final List<String> excludedAttributes,
+            final String attributes,
+            final String excludedAttributes,
             final String filter,
             final String sortBy,
             final SortOrder sortOrder,
@@ -69,10 +75,12 @@ public class UserServiceImpl extends AbstractService<SCIMUser> implements
UserSe
 
         SCIMSearchRequest request = new SCIMSearchRequest(filter, sortBy, sortOrder, startIndex,
count);
         if (attributes != null) {
-            request.getAttributes().addAll(attributes);
+            request.getAttributes().addAll(
+                    Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(attributes, ','))));
         }
         if (excludedAttributes != null) {
-            request.getExcludedAttributes().addAll(excludedAttributes);
+            request.getExcludedAttributes().addAll(
+                    Arrays.asList(ArrayUtils.nullToEmpty(StringUtils.split(excludedAttributes,
','))));
         }
 
         return doSearch(Resource.User, request);

http://git-wip-us.apache.org/repos/asf/syncope/blob/15295e58/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
index ca15f05..653cd86 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
@@ -45,6 +45,7 @@ import org.apache.syncope.ext.scimv2.api.SCIMConstants;
 import org.apache.syncope.ext.scimv2.api.data.ListResponse;
 import org.apache.syncope.ext.scimv2.api.data.ResourceType;
 import org.apache.syncope.ext.scimv2.api.data.SCIMGroup;
+import org.apache.syncope.ext.scimv2.api.data.SCIMSearchRequest;
 import org.apache.syncope.ext.scimv2.api.data.SCIMUser;
 import org.apache.syncope.ext.scimv2.api.data.ServiceProviderConfig;
 import org.apache.syncope.ext.scimv2.api.type.Resource;
@@ -155,6 +156,20 @@ public class SCIMITCase extends AbstractITCase {
         assertEquals("rossini", user.getUserName());
         assertFalse(user.getGroups().isEmpty());
         assertFalse(user.getRoles().isEmpty());
+
+        response = webClient().path("Users").path("1417acbe-cbf6-4277-9372-e75e04f97000").
+                query("attributes", "groups").get();
+        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+        assertEquals(
+                SCIMConstants.APPLICATION_SCIM_JSON,
+                StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE),
";"));
+
+        user = response.readEntity(SCIMUser.class);
+        assertNotNull(user);
+        assertEquals("1417acbe-cbf6-4277-9372-e75e04f97000", user.getId());
+        assertNull(user.getUserName());
+        assertFalse(user.getGroups().isEmpty());
+        assertTrue(user.getRoles().isEmpty());
     }
 
     @Test
@@ -227,10 +242,7 @@ public class SCIMITCase extends AbstractITCase {
         assertEquals("additional", additional.getDisplayName());
 
         // eq via POST
-        String request = "{"
-                + "     \"schemas\": [\"urn:ietf:params:scim:api:messages:2.0:SearchRequest\"],"
-                + "     \"filter\": \"displayName eq \\\"additional\\\"\""
-                + "   }";
+        SCIMSearchRequest request = new SCIMSearchRequest("displayName eq \"additional\"",
null, null, null, null);
         response = webClient().path("Groups").path("/.search").post(request);
         assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
         assertEquals(


Mime
View raw message