You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2021/04/16 16:28:25 UTC

[unomi] branch UNOMI-467-allowSomeObjectsInGETParam created (now 76c4574)

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

jkevan pushed a change to branch UNOMI-467-allowSomeObjectsInGETParam
in repository https://gitbox.apache.org/repos/asf/unomi.git.


      at 76c4574  UNOMI-467: fix ContextRequest and EventCollectorRequest objects deserialization on GET request with 'payload' parameter, also refactor a bit the structure of the packages to have better visibility on classes and there roles inside the rest bundle

This branch includes the following new commits:

     new 76c4574  UNOMI-467: fix ContextRequest and EventCollectorRequest objects deserialization on GET request with 'payload' parameter, also refactor a bit the structure of the packages to have better visibility on classes and there roles inside the rest bundle

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.


[unomi] 01/01: UNOMI-467: fix ContextRequest and EventCollectorRequest objects deserialization on GET request with 'payload' parameter, also refactor a bit the structure of the packages to have better visibility on classes and there roles inside the rest bundle

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

jkevan pushed a commit to branch UNOMI-467-allowSomeObjectsInGETParam
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 76c4574076bf039dde2a2a5b3198bc510897b612
Author: Kevan <ke...@jahia.com>
AuthorDate: Fri Apr 16 18:28:11 2021 +0200

    UNOMI-467: fix ContextRequest and EventCollectorRequest objects deserialization on GET request with 'payload' parameter, also refactor a bit the structure of the packages to have better visibility on classes and there roles inside the rest bundle
---
 .../org/apache/unomi/itests/InputValidationIT.java | 24 +++----
 .../impl/DefaultRestAuthenticationConfig.java      | 20 +++---
 .../{ => endpoints}/CampaignsServiceEndPoint.java  |  2 +-
 .../unomi/rest/{ => endpoints}/ClientEndpoint.java |  2 +-
 .../{ => endpoints}/ClusterServiceEndPoint.java    |  2 +-
 .../rest/{ => endpoints}/ContextJsonEndpoint.java  | 25 ++++---
 .../DefinitionsServiceEndPoint.java                |  6 +-
 .../rest/{ => endpoints}/EventServiceEndpoint.java |  2 +-
 .../{ => endpoints}/EventsCollectorEndpoint.java   |  7 +-
 .../rest/{ => endpoints}/GoalsServiceEndPoint.java |  2 +-
 .../rest/{ => endpoints}/PatchServiceEndPoint.java |  2 +-
 .../{ => endpoints}/ProfileServiceEndPoint.java    |  3 +-
 .../rest/{ => endpoints}/QueryServiceEndPoint.java |  3 +-
 .../rest/{ => endpoints}/RulesServiceEndPoint.java |  2 +-
 .../{ => endpoints}/ScoringServiceEndPoint.java    |  2 +-
 .../{ => endpoints}/SegmentServiceEndPoint.java    |  2 +-
 .../{ => endpoints}/UserListServiceEndPoint.java   |  2 +-
 .../{ => exception}/RuntimeExceptionMapper.java    |  2 +-
 .../rest/{ => models}/EventCollectorResponse.java  |  2 +-
 .../unomi/rest/{ => models}/RESTActionType.java    |  2 +-
 .../unomi/rest/{ => models}/RESTConditionType.java |  2 +-
 .../unomi/rest/{ => models}/RESTParameter.java     |  2 +-
 .../unomi/rest/{ => models}/RESTValueType.java     |  2 +-
 .../apache/unomi/rest/{ => server}/RestServer.java |  9 ++-
 .../unomi/rest/{ => server}/RestServerBus.java     |  2 +-
 .../RetroCompatibilityParamConverterProvider.java  | 78 ++++++++++++++++++++++
 .../{ => service/impl}/LocalizationHelper.java     |  6 +-
 .../{ => service/impl}/ResourceBundleHelper.java   |  2 +-
 28 files changed, 151 insertions(+), 66 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
index a9a1d98..071dbe1 100644
--- a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
@@ -54,49 +54,43 @@ public class InputValidationIT extends BaseIT {
     @Test
     public void test_param_EventsNotEmpty() throws IOException {
         doPOSTRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_emptyEvents.json", 400);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_emptyEvents.json", 400);
+        doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_emptyEvents.json", 400);
     }
 
     @Test
     public void test_param_SessionIDPattern() throws IOException {
         doPOSTRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_invalidSessionId.json", 400);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_invalidSessionId.json", 400);
+        doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_invalidSessionId.json", 400);
     }
 
     @Test
     public void test_eventCollector_valid() throws IOException {
         doPOSTRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_valid.json", 200);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_valid.json", 200);
+        doGETRequestTest(URL + EVENT_COLLECTOR_URL, null, "/validation/eventcollector_valid.json", 200);
     }
 
     @Test
     public void test_contextRequest_SessionIDPattern() throws IOException {
         doPOSTRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
         doPOSTRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
-        // doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
+        doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
+        doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidSessionId.json", 400);
     }
 
     @Test
     public void test_contextRequest_ProfileIDPattern() throws IOException {
         doPOSTRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
         doPOSTRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
-        // doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
+        doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
+        doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_invalidProfileId.json", 400);
     }
 
     @Test
     public void test_contextRequest_valid() throws IOException {
         doPOSTRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_valid.json", 200);
         doPOSTRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_valid.json", 200);
-        // TODO uncomment after fix: https://issues.apache.org/jira/browse/UNOMI-467
-        // doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_valid.json", 200);
-        // doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_valid.json", 200);
+        doGETRequestTest(URL + CONTEXT_JSON_URL, null, "/validation/contextRequest_valid.json", 200);
+        doGETRequestTest(URL + CONTEXT_JS_URL, null, "/validation/contextRequest_valid.json", 200);
     }
 
     @Test
diff --git a/rest/src/main/java/org/apache/unomi/rest/authentication/impl/DefaultRestAuthenticationConfig.java b/rest/src/main/java/org/apache/unomi/rest/authentication/impl/DefaultRestAuthenticationConfig.java
index d6b06be..cf487fc 100644
--- a/rest/src/main/java/org/apache/unomi/rest/authentication/impl/DefaultRestAuthenticationConfig.java
+++ b/rest/src/main/java/org/apache/unomi/rest/authentication/impl/DefaultRestAuthenticationConfig.java
@@ -42,16 +42,16 @@ public class DefaultRestAuthenticationConfig implements RestAuthenticationConfig
 
     static {
         Map<String, String> roles = new HashMap<>();
-        roles.put("org.apache.unomi.rest.ContextJsonEndpoint.contextJSAsGet", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ContextJsonEndpoint.contextJSAsPost", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ContextJsonEndpoint.contextJSONAsGet", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ContextJsonEndpoint.contextJSONAsPost", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ContextJsonEndpoint.options", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.EventsCollectorEndpoint.collectAsGet", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.EventsCollectorEndpoint.collectAsPost", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.EventsCollectorEndpoint.options", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ClientEndpoint.getClient", GUEST_ROLES);
-        roles.put("org.apache.unomi.rest.ClientEndpoint.options", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ContextJsonEndpoint.contextJSAsGet", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ContextJsonEndpoint.contextJSAsPost", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ContextJsonEndpoint.contextJSONAsGet", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ContextJsonEndpoint.contextJSONAsPost", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ContextJsonEndpoint.options", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.EventsCollectorEndpoint.collectAsGet", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.EventsCollectorEndpoint.collectAsPost", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.EventsCollectorEndpoint.options", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ClientEndpoint.getClient", GUEST_ROLES);
+        roles.put("org.apache.unomi.rest.endpoints.ClientEndpoint.options", GUEST_ROLES);
         ROLES_MAPPING = Collections.unmodifiableMap(roles);
     }
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/CampaignsServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/CampaignsServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/CampaignsServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/CampaignsServiceEndPoint.java
index 5dbace2..f01d153 100644
--- a/rest/src/main/java/org/apache/unomi/rest/CampaignsServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/CampaignsServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Metadata;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ClientEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ClientEndpoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/ClientEndpoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/ClientEndpoint.java
index 7662792..4f7fb12 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ClientEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ClientEndpoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ClusterServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ClusterServiceEndPoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/ClusterServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/ClusterServiceEndPoint.java
index 9f26c7d..9cfeae9 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ClusterServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ClusterServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ContextJsonEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/ContextJsonEndpoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
index 5c6e2a8..e2df705 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ContextJsonEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import org.apache.commons.lang3.StringUtils;
@@ -52,14 +52,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import javax.validation.constraints.Pattern;
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.OPTIONS;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -106,11 +99,17 @@ public class ContextJsonEndpoint {
     private RestServiceUtils restServiceUtils;
 
     @OPTIONS
-    @Path("/context.json")
-    public Response options() {
+    @Path("/context.js")
+    public Response contextJSAsOptions() {
         return Response.status(Response.Status.NO_CONTENT).header("Access-Control-Allow-Origin", "*").build();
     }
 
+    @OPTIONS
+    @Path("/context.json")
+    public Response contextJSONAsOptions() {
+        return contextJSAsOptions();
+    }
+
     @POST
     @Produces(MediaType.TEXT_PLAIN)
     @Path("/context.js")
@@ -125,7 +124,7 @@ public class ContextJsonEndpoint {
     @GET
     @Produces(MediaType.TEXT_PLAIN)
     @Path("/context.js")
-    public Response contextJSAsGet(@Valid ContextRequest contextRequest,
+    public Response contextJSAsGet(@QueryParam("payload") @Valid ContextRequest contextRequest,
             @QueryParam("personaId") @Pattern(regexp = ValidationPattern.TEXT_VALID_CHARACTERS_PATTERN) String personaId,
             @QueryParam("sessionId") @Pattern(regexp = ValidationPattern.TEXT_VALID_CHARACTERS_PATTERN) String sessionId,
             @QueryParam("timestamp") Long timestampAsLong, @QueryParam("invalidateProfile") boolean invalidateProfile,
@@ -142,7 +141,7 @@ public class ContextJsonEndpoint {
     @GET
     @Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
     @Path("/context.json")
-    public ContextResponse contextJSONAsGet(@Valid ContextRequest contextRequest,
+    public ContextResponse contextJSONAsGet(@QueryParam("payload") @Valid ContextRequest contextRequest,
             @QueryParam("personaId") @Pattern(regexp = ValidationPattern.TEXT_VALID_CHARACTERS_PATTERN) String personaId,
             @QueryParam("sessionId") @Pattern(regexp = ValidationPattern.TEXT_VALID_CHARACTERS_PATTERN) String sessionId,
             @QueryParam("timestamp") Long timestampAsLong, @QueryParam("invalidateProfile") boolean invalidateProfile,
diff --git a/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/DefinitionsServiceEndPoint.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/DefinitionsServiceEndPoint.java
index 8b2c7c0..acd76ba 100644
--- a/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/DefinitionsServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.PluginType;
@@ -24,6 +24,10 @@ import org.apache.unomi.api.ValueType;
 import org.apache.unomi.api.actions.ActionType;
 import org.apache.unomi.api.conditions.ConditionType;
 import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.rest.models.RESTActionType;
+import org.apache.unomi.rest.models.RESTConditionType;
+import org.apache.unomi.rest.models.RESTValueType;
+import org.apache.unomi.rest.service.impl.LocalizationHelper;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
diff --git a/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventServiceEndpoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/EventServiceEndpoint.java
index fdfdabd..710ba11 100644
--- a/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventServiceEndpoint.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Event;
diff --git a/rest/src/main/java/org/apache/unomi/rest/EventsCollectorEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
similarity index 96%
rename from rest/src/main/java/org/apache/unomi/rest/EventsCollectorEndpoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
index 3a905f0..28d312a 100644
--- a/rest/src/main/java/org/apache/unomi/rest/EventsCollectorEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
@@ -28,6 +28,7 @@ import org.apache.unomi.api.services.ConfigSharingService;
 import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.PrivacyService;
 import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.rest.models.EventCollectorResponse;
 import org.apache.unomi.rest.service.RestServiceUtils;
 import org.apache.unomi.utils.Changes;
 import org.osgi.service.component.annotations.Component;
@@ -87,8 +88,8 @@ public class EventsCollectorEndpoint {
 
     @GET
     @Path("/eventcollector")
-    public EventCollectorResponse collectAsGet(@NotNull @Valid EventsCollectorRequest eventsCollectorRequest,
-            @QueryParam("timestamp") Long timestampAsString) {
+    public EventCollectorResponse collectAsGet(@QueryParam("payload") @NotNull @Valid EventsCollectorRequest eventsCollectorRequest,
+                                               @QueryParam("timestamp") Long timestampAsString) {
         return doEvent(eventsCollectorRequest, timestampAsString);
     }
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/GoalsServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/GoalsServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/GoalsServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/GoalsServiceEndPoint.java
index 0063640..936986a 100644
--- a/rest/src/main/java/org/apache/unomi/rest/GoalsServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/GoalsServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Metadata;
diff --git a/rest/src/main/java/org/apache/unomi/rest/PatchServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/PatchServiceEndPoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/PatchServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/PatchServiceEndPoint.java
index 715923e..338bf41 100644
--- a/rest/src/main/java/org/apache/unomi/rest/PatchServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/PatchServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Patch;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ProfileServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/ProfileServiceEndPoint.java
index 477aafd..db6aa93 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ProfileServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
@@ -26,6 +26,7 @@ import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.ProfileService;
 import org.apache.unomi.api.services.SegmentService;
 import org.apache.unomi.persistence.spi.CustomObjectMapper;
+import org.apache.unomi.rest.service.impl.LocalizationHelper;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
diff --git a/rest/src/main/java/org/apache/unomi/rest/QueryServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/QueryServiceEndPoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/QueryServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/QueryServiceEndPoint.java
index c533e7d..83a656e 100644
--- a/rest/src/main/java/org/apache/unomi/rest/QueryServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/QueryServiceEndPoint.java
@@ -15,13 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Item;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.query.AggregateQuery;
 import org.apache.unomi.api.services.QueryService;
+import org.apache.unomi.rest.service.impl.LocalizationHelper;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
diff --git a/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/RulesServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/RulesServiceEndPoint.java
index b52ed79..91298ee 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/RulesServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Metadata;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ScoringServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/ScoringServiceEndPoint.java
index fc0ca72..bf3176a 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ScoringServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Item;
diff --git a/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/SegmentServiceEndPoint.java
similarity index 99%
rename from rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/SegmentServiceEndPoint.java
index 0c7f9c9..3cd5475 100644
--- a/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/SegmentServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 import org.apache.cxf.rs.security.cors.CrossOriginResourceSharing;
 import org.apache.unomi.api.Metadata;
diff --git a/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/UserListServiceEndPoint.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java
rename to rest/src/main/java/org/apache/unomi/rest/endpoints/UserListServiceEndPoint.java
index 33484ff..468e28e 100644
--- a/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/UserListServiceEndPoint.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.endpoints;
 
 /**
  * Created by amidani on 24/03/2017.
diff --git a/rest/src/main/java/org/apache/unomi/rest/RuntimeExceptionMapper.java b/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/RuntimeExceptionMapper.java
rename to rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
index 00e1732..9bdce40 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RuntimeExceptionMapper.java
+++ b/rest/src/main/java/org/apache/unomi/rest/exception/RuntimeExceptionMapper.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.exception;
 
 import org.osgi.service.component.annotations.Component;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/EventCollectorResponse.java b/rest/src/main/java/org/apache/unomi/rest/models/EventCollectorResponse.java
similarity index 96%
rename from rest/src/main/java/org/apache/unomi/rest/EventCollectorResponse.java
rename to rest/src/main/java/org/apache/unomi/rest/models/EventCollectorResponse.java
index f5f712b..b53b25d 100644
--- a/rest/src/main/java/org/apache/unomi/rest/EventCollectorResponse.java
+++ b/rest/src/main/java/org/apache/unomi/rest/models/EventCollectorResponse.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.models;
 
 import java.io.Serializable;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/RESTActionType.java b/rest/src/main/java/org/apache/unomi/rest/models/RESTActionType.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/RESTActionType.java
rename to rest/src/main/java/org/apache/unomi/rest/models/RESTActionType.java
index f29f229..97d2c16 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RESTActionType.java
+++ b/rest/src/main/java/org/apache/unomi/rest/models/RESTActionType.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.models;
 
 import org.apache.unomi.api.actions.ActionType;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/RESTConditionType.java b/rest/src/main/java/org/apache/unomi/rest/models/RESTConditionType.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/RESTConditionType.java
rename to rest/src/main/java/org/apache/unomi/rest/models/RESTConditionType.java
index 24d1332..47bbde2 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RESTConditionType.java
+++ b/rest/src/main/java/org/apache/unomi/rest/models/RESTConditionType.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.models;
 
 import org.apache.unomi.api.conditions.ConditionType;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/RESTParameter.java b/rest/src/main/java/org/apache/unomi/rest/models/RESTParameter.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/RESTParameter.java
rename to rest/src/main/java/org/apache/unomi/rest/models/RESTParameter.java
index 87d79be..bc7ab9a 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RESTParameter.java
+++ b/rest/src/main/java/org/apache/unomi/rest/models/RESTParameter.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.models;
 
 import org.apache.unomi.api.Parameter;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/RESTValueType.java b/rest/src/main/java/org/apache/unomi/rest/models/RESTValueType.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/RESTValueType.java
rename to rest/src/main/java/org/apache/unomi/rest/models/RESTValueType.java
index 3891a35..a501e8b 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RESTValueType.java
+++ b/rest/src/main/java/org/apache/unomi/rest/models/RESTValueType.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.models;
 
 import org.apache.unomi.api.ValueType;
 
diff --git a/rest/src/main/java/org/apache/unomi/rest/RestServer.java b/rest/src/main/java/org/apache/unomi/rest/server/RestServer.java
similarity index 95%
rename from rest/src/main/java/org/apache/unomi/rest/RestServer.java
rename to rest/src/main/java/org/apache/unomi/rest/server/RestServer.java
index 5ca3d47..a296823 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RestServer.java
+++ b/rest/src/main/java/org/apache/unomi/rest/server/RestServer.java
@@ -14,8 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.server;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Server;
@@ -28,6 +29,7 @@ import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationOutInterceptor;
 import org.apache.unomi.rest.authentication.AuthenticationFilter;
 import org.apache.unomi.rest.authentication.AuthorizingInterceptor;
 import org.apache.unomi.rest.authentication.RestAuthenticationConfig;
+import org.apache.unomi.rest.server.provider.RetroCompatibilityParamConverterProvider;
 import org.apache.unomi.rest.validation.JAXRSBeanValidationInInterceptorOverride;
 import org.apache.unomi.rest.validation.LocalBeanValidationProvider;
 import org.osgi.framework.BundleContext;
@@ -179,12 +181,13 @@ public class RestServer {
         logger.info("JAX RS Server: Configuring server...");
 
         // Build the server
+        ObjectMapper objectMapper = new org.apache.unomi.persistence.spi.CustomObjectMapper();
         JAXRSServerFactoryBean jaxrsServerFactoryBean = new JAXRSServerFactoryBean();
         jaxrsServerFactoryBean.setAddress("/");
         jaxrsServerFactoryBean.setBus(serverBus);
-        jaxrsServerFactoryBean.setProvider(new JacksonJaxbJsonProvider(new org.apache.unomi.persistence.spi.CustomObjectMapper(),
-                JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS));
+        jaxrsServerFactoryBean.setProvider(new JacksonJaxbJsonProvider(objectMapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS));
         jaxrsServerFactoryBean.setProvider(new org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter());
+        jaxrsServerFactoryBean.setProvider(new RetroCompatibilityParamConverterProvider(objectMapper));
 
         // Authentication filter (used for authenticating user from request)
         jaxrsServerFactoryBean.setProvider(new AuthenticationFilter(restAuthenticationConfig));
diff --git a/rest/src/main/java/org/apache/unomi/rest/RestServerBus.java b/rest/src/main/java/org/apache/unomi/rest/server/RestServerBus.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/RestServerBus.java
rename to rest/src/main/java/org/apache/unomi/rest/server/RestServerBus.java
index 6ceb6ed..ff87ba3 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RestServerBus.java
+++ b/rest/src/main/java/org/apache/unomi/rest/server/RestServerBus.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.server;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
diff --git a/rest/src/main/java/org/apache/unomi/rest/server/provider/RetroCompatibilityParamConverterProvider.java b/rest/src/main/java/org/apache/unomi/rest/server/provider/RetroCompatibilityParamConverterProvider.java
new file mode 100644
index 0000000..9dc6500
--- /dev/null
+++ b/rest/src/main/java/org/apache/unomi/rest/server/provider/RetroCompatibilityParamConverterProvider.java
@@ -0,0 +1,78 @@
+/*
+ * 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.unomi.rest.server.provider;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.unomi.api.ContextRequest;
+import org.apache.unomi.api.EventsCollectorRequest;
+
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.ext.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This is a custom param converter provider only to be able to deserialize correctly objects used by the old servlets.
+ * The old servlets was supporting JSON objects passed on GET requests using a parameter named "payload".
+ * This only concern:
+ *  GET /context.js
+ *  GET /context.json
+ *  GET /eventcollector
+ *
+ * And objects: ContextRequest, EventsCollectorRequest
+ */
+@Provider
+public class RetroCompatibilityParamConverterProvider implements ParamConverterProvider {
+
+    private final ObjectMapper objectMapper;
+    private final List<Class<?>> allowedConversionForTypes = new ArrayList<>();
+
+    public RetroCompatibilityParamConverterProvider(ObjectMapper objectMapper) {
+        this.objectMapper = objectMapper;
+
+        allowedConversionForTypes.add(ContextRequest.class);
+        allowedConversionForTypes.add(EventsCollectorRequest.class);
+    }
+
+    @Override
+    public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
+
+        if (allowedConversionForTypes.stream().anyMatch(rawType::isAssignableFrom)) {
+            return new ParamConverter<T>() {
+                @Override
+                public T fromString(final String value) {
+                    JsonFactory factory = objectMapper.getFactory();
+                    try {
+                        return objectMapper.readValue(factory.createParser(value), rawType);
+                    } catch (Exception e) {
+                        throw new ProcessingException(e);
+                    }
+                }
+
+                @Override
+                public String toString(final T value) {
+                    throw new UnsupportedOperationException();
+                }
+            };
+        }
+
+        return null;
+    }
+}
diff --git a/rest/src/main/java/org/apache/unomi/rest/LocalizationHelper.java b/rest/src/main/java/org/apache/unomi/rest/service/impl/LocalizationHelper.java
similarity index 97%
rename from rest/src/main/java/org/apache/unomi/rest/LocalizationHelper.java
rename to rest/src/main/java/org/apache/unomi/rest/service/impl/LocalizationHelper.java
index 148a425..b67ebd3 100644
--- a/rest/src/main/java/org/apache/unomi/rest/LocalizationHelper.java
+++ b/rest/src/main/java/org/apache/unomi/rest/service/impl/LocalizationHelper.java
@@ -15,12 +15,16 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.service.impl;
 
 import org.apache.unomi.api.Parameter;
 import org.apache.unomi.api.ValueType;
 import org.apache.unomi.api.actions.ActionType;
 import org.apache.unomi.api.conditions.ConditionType;
+import org.apache.unomi.rest.models.RESTActionType;
+import org.apache.unomi.rest.models.RESTConditionType;
+import org.apache.unomi.rest.models.RESTParameter;
+import org.apache.unomi.rest.models.RESTValueType;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.component.annotations.Activate;
diff --git a/rest/src/main/java/org/apache/unomi/rest/ResourceBundleHelper.java b/rest/src/main/java/org/apache/unomi/rest/service/impl/ResourceBundleHelper.java
similarity index 98%
rename from rest/src/main/java/org/apache/unomi/rest/ResourceBundleHelper.java
rename to rest/src/main/java/org/apache/unomi/rest/service/impl/ResourceBundleHelper.java
index abc375b..b68dd1f 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ResourceBundleHelper.java
+++ b/rest/src/main/java/org/apache/unomi/rest/service/impl/ResourceBundleHelper.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.unomi.rest;
+package org.apache.unomi.rest.service.impl;
 
 import org.apache.unomi.api.PluginType;
 import org.osgi.framework.Bundle;