You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2020/01/24 19:12:04 UTC

[directory-scimple] branch merge/psu-scim-2.22.4 created (now 74512e0)

This is an automated email from the ASF dual-hosted git repository.

smoyer1 pushed a change to branch merge/psu-scim-2.22.4
in repository https://gitbox.apache.org/repos/asf/directory-scimple.git.


      at 74512e0  Merges in changes from PennState/SCIMple 2.22.4

This branch includes the following new commits:

     new 74512e0  Merges in changes from PennState/SCIMple 2.22.4

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[directory-scimple] 01/01: Merges in changes from PennState/SCIMple 2.22.4

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

smoyer1 pushed a commit to branch merge/psu-scim-2.22.4
in repository https://gitbox.apache.org/repos/asf/directory-scimple.git

commit 74512e09a294bcd72b245c752902843174972a56
Author: Steve Moyer <sm...@psu.edu>
AuthorDate: Fri Jan 24 14:11:34 2020 -0500

    Merges in changes from PennState/SCIMple 2.22.4
---
 .../directory/scim/client/rest/BaseScimClient.java | 33 +++++++++++++++-------
 .../attribute/AttributeReferenceListWrapper.java   |  4 +++
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
index 7e79848..78d103f 100644
--- a/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
+++ b/scim-client/src/main/java/org/apache/directory/scim/client/rest/BaseScimClient.java
@@ -20,6 +20,7 @@
 package org.apache.directory.scim.client.rest;
 
 import java.util.Optional;
+import java.util.Set;
 import java.util.function.Function;
 
 import javax.ws.rs.ProcessingException;
@@ -227,8 +228,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
       Response response;
       Invocation request = BaseScimClient.this.target
           .path(id)
-          .queryParam(ATTRIBUTES_QUERY_PARAM, attributes)
-          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, excludedAttributes)
+          .queryParam(ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(attributes))
+          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(excludedAttributes))
           .request(getContentType())
           .buildGet();
 
@@ -245,8 +246,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
     public Response query(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes, FilterWrapper filter, AttributeReference sortBy, SortOrder sortOrder, Integer startIndex, Integer count) throws ScimException {
       Response response;
       Invocation request = BaseScimClient.this.target
-          .queryParam(ATTRIBUTES_QUERY_PARAM, attributes)
-          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, excludedAttributes)
+          .queryParam(ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(attributes))
+          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(excludedAttributes))
           .queryParam(FILTER_QUERY_PARAM, filter.getFilter())
           .queryParam(SORT_BY_QUERY_PARAM, sortBy)
           .queryParam(SORT_ORDER_QUERY_PARAM, sortOrder != null ? sortOrder.name() : null)
@@ -268,8 +269,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
     public Response create(T resource, AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) throws ScimException {
       Response response;
       Invocation request = BaseScimClient.this.target
-          .queryParam(ATTRIBUTES_QUERY_PARAM, attributes)
-          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, excludedAttributes)
+          .queryParam(ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(attributes))
+          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(excludedAttributes))
           .request(getContentType())
           .buildPost(Entity.entity(resource, getContentType()));
 
@@ -304,8 +305,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
       Response response;
       Invocation request = BaseScimClient.this.target
           .path(id)
-          .queryParam(ATTRIBUTES_QUERY_PARAM, attributes)
-          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, excludedAttributes)
+          .queryParam(ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(attributes))
+          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(excludedAttributes))
           .request(getContentType())
           .buildPut(Entity.entity(resource, getContentType()));
 
@@ -323,8 +324,8 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
       Response response;
       Invocation request = BaseScimClient.this.target
           .path(id)
-          .queryParam(ATTRIBUTES_QUERY_PARAM, attributes)
-          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, excludedAttributes)
+          .queryParam(ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(attributes))
+          .queryParam(EXCLUDED_ATTRIBUTES_QUERY_PARAM, nullOutQueryParamIfListIsNullOrEmpty(excludedAttributes))
           .request(getContentType())
           .build("PATCH", Entity.entity(patchRequest, getContentType()));
 
@@ -353,6 +354,18 @@ public abstract class BaseScimClient<T extends ScimResource> implements AutoClos
         throw toScimException(restClientException);
       }
     }
+    
+    private AttributeReferenceListWrapper nullOutQueryParamIfListIsNullOrEmpty(AttributeReferenceListWrapper wrapper) {
+      if (wrapper == null) {
+        return null;
+      }
+      Set<AttributeReference> attributeReferences = wrapper.getAttributeReferences();
+      if (attributeReferences == null || attributeReferences.isEmpty()) {
+        return null;
+      }
+      
+      return wrapper;
+    }
   }
 
   protected String getContentType() {
diff --git a/scim-spec/scim-spec-protocol/src/main/java/org/apache/directory/scim/spec/protocol/attribute/AttributeReferenceListWrapper.java b/scim-spec/scim-spec-protocol/src/main/java/org/apache/directory/scim/spec/protocol/attribute/AttributeReferenceListWrapper.java
index 38372f6..6d383f6 100644
--- a/scim-spec/scim-spec-protocol/src/main/java/org/apache/directory/scim/spec/protocol/attribute/AttributeReferenceListWrapper.java
+++ b/scim-spec/scim-spec-protocol/src/main/java/org/apache/directory/scim/spec/protocol/attribute/AttributeReferenceListWrapper.java
@@ -55,6 +55,10 @@ public class AttributeReferenceListWrapper {
   }
 
   public String toString() {
+    if (attributeReferences == null || attributeReferences.isEmpty()) {
+      return "";
+    }
+    
     return attributeReferences.stream().map(AttributeReference::toString).collect(Collectors.joining(","));
   }
 }