You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2018/02/15 14:16:57 UTC

incubator-unomi git commit: UNOMI-156 add test on entry point existingProperties and return bad request if missing mandatory query parameters

Repository: incubator-unomi
Updated Branches:
  refs/heads/master b356c2ff9 -> 2fba338c1


UNOMI-156 add test on entry point existingProperties and return bad request if missing mandatory query parameters


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/2fba338c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/2fba338c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/2fba338c

Branch: refs/heads/master
Commit: 2fba338c14d2ee009826110a3c92b5caca1921b1
Parents: b356c2f
Author: dgaillard <dg...@jahia.com>
Authored: Thu Feb 15 15:13:51 2018 +0100
Committer: dgaillard <dg...@jahia.com>
Committed: Thu Feb 15 15:13:51 2018 +0100

----------------------------------------------------------------------
 rest/pom.xml                                              |  5 +++++
 .../org/apache/unomi/rest/ProfileServiceEndPoint.java     | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/2fba338c/rest/pom.xml
----------------------------------------------------------------------
diff --git a/rest/pom.xml b/rest/pom.xml
index 6096b9a..50232bf 100644
--- a/rest/pom.xml
+++ b/rest/pom.xml
@@ -87,6 +87,11 @@
             <version>1.3.0-incubating-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
         <!--<dependency>
             <groupId>io.swagger</groupId>
             <artifactId>swagger-core</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/2fba338c/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
----------------------------------------------------------------------
diff --git a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
index 34ac552..eb3bf33 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
@@ -17,6 +17,7 @@
 
 package org.apache.unomi.rest;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.*;
 import org.apache.unomi.api.conditions.Condition;
@@ -30,7 +31,9 @@ import org.slf4j.LoggerFactory;
 
 import javax.jws.WebMethod;
 import javax.jws.WebService;
+import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
@@ -451,7 +454,12 @@ public class ProfileServiceEndPoint {
      */
     @GET
     @Path("/existingProperties")
-    public Collection<PropertyType> getExistingProperties(@QueryParam("tag") String tag, @QueryParam("isSystemTag") boolean isSystemTag, @QueryParam("itemType") String itemType, @HeaderParam("Accept-Language") String language) {
+    public Collection<PropertyType> getExistingProperties(@QueryParam("tag") String tag, @QueryParam("isSystemTag") boolean isSystemTag, @QueryParam("itemType") String itemType, @HeaderParam("Accept-Language") String language, @Context final HttpServletResponse response) {
+        if (StringUtils.isBlank(tag) || StringUtils.isBlank(itemType)) {
+            logger.error("Missing mandatory query parameters when requesting /cxs/profiles/existingProperties, mandatory query parameters are tag and itemType");
+            response.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
+            return null;
+        }
         Set<PropertyType> properties;
         if (isSystemTag) {
             properties = profileService.getExistingProperties(tag, itemType, isSystemTag);