You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/07/25 07:52:03 UTC

isis git commit: ISIS-1177: fix for deserializing into RO applib using jackson.

Repository: isis
Updated Branches:
  refs/heads/master b86aa5506 -> 95d5a4e50


ISIS-1177: fix for deserializing into RO applib using jackson.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/95d5a4e5
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/95d5a4e5
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/95d5a4e5

Branch: refs/heads/master
Commit: 95d5a4e50d3bce0e2eba80456d3f76f3653dcbe2
Parents: b86aa55
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sat Jul 25 06:34:47 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sat Jul 25 06:34:47 2015 +0100

----------------------------------------------------------------------
 .../applib/client/RestfulResponse.java          | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/95d5a4e5/core/viewer-restfulobjects-applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/client/RestfulResponse.java
----------------------------------------------------------------------
diff --git a/core/viewer-restfulobjects-applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/client/RestfulResponse.java b/core/viewer-restfulobjects-applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/client/RestfulResponse.java
index 29e9e26..11a77e6 100644
--- a/core/viewer-restfulobjects-applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/client/RestfulResponse.java
+++ b/core/viewer-restfulobjects-applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/client/RestfulResponse.java
@@ -19,6 +19,8 @@
 package org.apache.isis.viewer.restfulobjects.applib.client;
 
 import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Date;
 import java.util.Map;
 
@@ -30,15 +32,16 @@ import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.Response.Status.Family;
 import javax.ws.rs.core.Response.StatusType;
 
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Maps;
+
 import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
 import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
 import org.apache.isis.viewer.restfulobjects.applib.util.JsonMapper;
 import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.google.common.collect.Maps;
-
 public class RestfulResponse<T> {
 
     public final static class HttpStatusCode {
@@ -321,7 +324,17 @@ public class RestfulResponse<T> {
 
     public T getEntity() throws JsonParseException, JsonMappingException, IOException {
         if(entity == null) {
-            entity = JsonMapper.instance().read(response, returnType);
+            // previously this was good enough, but no longer it seems
+            //entity = JsonMapper.instance().read(response, returnType);
+
+            // instead, we do it manually
+            final JsonNode jsonNode = JsonMapper.instance().read(response, JsonNode.class);
+            try {
+                final Constructor<T> constructor = returnType.getConstructor(JsonNode.class);
+                entity = constructor.newInstance(jsonNode);
+            } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
+                throw new RuntimeException(e);
+            }
         }
         return entity;
     }