isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1154722 - in /incubator/isis/trunk/framework/viewer/json: json-applib/src/main/java/org/apache/isis/viewer/json/applib/ json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ json-applib/src/main/java/org/apache/isis/viewer/j...
Date Sun, 07 Aug 2011 16:37:57 GMT
Author: danhaywood
Date: Sun Aug  7 16:37:57 2011
New Revision: 1154722

URL: http://svn.apache.org/viewvc?rev=1154722&view=rev
Log:
ISIS-109: representations now subclass from JsonRepresentation

Added:
    incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size_elementAt.java
      - copied, changed from r1154558, incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size.java
Removed:
    incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size.java
Modified:
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ServicesRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/ResourceRepresentationTest.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceImpl.java

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/JsonRepresentation.java
Sun Aug  7 16:37:57 2011
@@ -3,7 +3,6 @@ package org.apache.isis.viewer.json.appl
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.math.BigDecimal;
 
 import net.sf.json.JSON;
 import net.sf.json.JSONSerializer;
@@ -41,11 +40,20 @@ public class JsonRepresentation {
 
     public int size() {
         if (!jsonNode.isArray()) {
-            throw new IllegalStateException("Is an array");
+            throw new IllegalStateException("Is not an array");
         }
         return jsonNode.size();
     }
 
+    public JsonRepresentation elementAt(int i) {
+        if (!jsonNode.isArray()) {
+            throw new IllegalStateException("Is not an array");
+        }
+        if(i >= size()) {
+            throw new IndexOutOfBoundsException("array has " + size() + " elements"); 
+        }
+        return new JsonRepresentation(jsonNode.get(i));
+    }
 
     public boolean isArray() {
         return jsonNode.isArray();
@@ -59,7 +67,7 @@ public class JsonRepresentation {
         return !isArray() && !isValue();
     }
 
-    public Link getLink(String path) throws JsonMappingException {
+    public Link getLink(String path) {
         JsonNode node = getNode(path);
         if (node == null || node.isMissingNode()) {
             return null;
@@ -220,4 +228,5 @@ public class JsonRepresentation {
         return jsonNode.toString();
     }
 
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ServicesRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ServicesRepresentation.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ServicesRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domain/ServicesRepresentation.java
Sun Aug  7 16:37:57 2011
@@ -1,10 +1,14 @@
 package org.apache.isis.viewer.json.applib.domain;
 
-import java.util.ArrayList;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonNode;
 
 
-public class ServicesRepresentation extends ArrayList<DomainObjectRepresentation> {
+public class ServicesRepresentation extends JsonRepresentation {
 
-    private static final long serialVersionUID = 1L;
+    public ServicesRepresentation(JsonNode jsonNode) {
+        super(jsonNode);
+        // TODO Auto-generated constructor stub
+    }
     
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/homepage/HomePageRepresentation.java
Sun Aug  7 16:37:57 2011
@@ -1,27 +1,20 @@
 package org.apache.isis.viewer.json.applib.homepage;
 
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.blocks.Link;
+import org.codehaus.jackson.JsonNode;
 
-public class HomePageRepresentation {
+public class HomePageRepresentation extends JsonRepresentation {
 
-    private Link user;
-    private Link services;
-    public Link getUser() {
-        return user;
+    public HomePageRepresentation(JsonNode jsonNode) {
+        super(jsonNode);
     }
-    public void setUser(Link user) {
-        this.user = user;
+
+    public Link getUser() {
+        return getLink("user");
     }
     public Link getServices() {
-        return services;
-    }
-    public void setServices(Link services) {
-        this.services = services;
-    }
-    
-    @Override
-    public String toString() {
-        return "HomePage [user=" + user + ", services=" + services + "]";
+        return getLink("services");
     }
     
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/util/JsonMapper.java
Sun Aug  7 16:37:57 2011
@@ -1,5 +1,7 @@
 package org.apache.isis.viewer.json.applib.util;
 import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -13,22 +15,75 @@ import org.codehaus.jackson.JsonNode;
 import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.JsonParser;
 import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.BeanDescription;
+import org.codehaus.jackson.map.BeanProperty;
 import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.DeserializationContext;
-import org.codehaus.jackson.map.DeserializerFactory;
 import org.codehaus.jackson.map.DeserializerProvider;
 import org.codehaus.jackson.map.Deserializers;
 import org.codehaus.jackson.map.JsonDeserializer;
 import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.KeyDeserializer;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.TypeDeserializer;
+import org.codehaus.jackson.map.deser.BeanDeserializerFactory;
 import org.codehaus.jackson.map.deser.JsonNodeDeserializer;
 import org.codehaus.jackson.map.deser.StdDeserializerProvider;
+import org.codehaus.jackson.map.introspect.BasicBeanDescription;
 import org.codehaus.jackson.map.module.SimpleDeserializers;
+import org.codehaus.jackson.map.type.ArrayType;
+import org.codehaus.jackson.map.type.CollectionLikeType;
+import org.codehaus.jackson.map.type.CollectionType;
+import org.codehaus.jackson.map.type.MapLikeType;
+import org.codehaus.jackson.map.type.MapType;
+import org.codehaus.jackson.type.JavaType;
 
 
 public final class JsonMapper {
     
+    @SuppressWarnings("deprecation")
+    private static final class JsonRepresentationDeserializerFactory extends BeanDeserializerFactory
{
+
+
+        @Override
+        public JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig
config, DeserializerProvider p, JavaType type, BeanProperty property) throws JsonMappingException
{
+            Class<?> rawClass = type.getRawClass();
+            if (JsonRepresentation.class.isAssignableFrom(rawClass)) {
+                try {
+                    // ensure has a constructor taking a JsonNode
+                    Constructor<?> rawClassConstructor = rawClass.getConstructor(JsonNode.class);
+                    return new JsonRepresentationDeserializer(rawClassConstructor);
+                } catch (SecurityException e) {
+                    // fall through
+                } catch (NoSuchMethodException e) {
+                    // fall through
+                }
+            } 
+            return super.createBeanDeserializer(config, p, type, property);
+        }
+    }
+
+    private static final class JsonRepresentationDeserializer extends JsonDeserializer<Object>
{
+        private JsonDeserializer<? extends JsonNode> jsonNodeDeser = 
+            JsonNodeDeserializer.getDeserializer(JsonNode.class);
+        
+        private final Constructor<?> rawClassConstructor;
+        public JsonRepresentationDeserializer(Constructor<?> rawClassConstructor) {
+            this.rawClassConstructor = rawClassConstructor;
+        }
+
+        @Override
+        public JsonRepresentation deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
+            JsonNode jsonNode = jsonNodeDeser.deserialize(jp, ctxt);
+            try {
+                return (JsonRepresentation) rawClassConstructor.newInstance(jsonNode);
+            } catch (Exception e) {
+                throw new IllegalStateException(e); 
+            }
+        }
+    }
+
     private static JsonMapper instance = new JsonMapper();
 
     // threadsafe
@@ -39,19 +94,7 @@ public final class JsonMapper {
     private final ObjectMapper objectMapper;
 
     private JsonMapper() {
-        DeserializerProvider deserializerProvider = new StdDeserializerProvider();
-        SimpleDeserializers d = new SimpleDeserializers();
-        d.addDeserializer(JsonRepresentation.class, new JsonDeserializer<JsonRepresentation>()
{
-            
-            private JsonDeserializer<? extends JsonNode> jsonNodeDeser = 
-                JsonNodeDeserializer.getDeserializer(JsonNode.class);
-            
-            @Override
-            public JsonRepresentation deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
-                return new JsonRepresentation(jsonNodeDeser.deserialize(jp, ctxt));
-            }
-        });
-        deserializerProvider.withAdditionalDeserializers(d);
+        DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
         objectMapper = new ObjectMapper(null, null, deserializerProvider);
         objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
         objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
false);

Copied: incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size_elementAt.java
(from r1154558, incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size_elementAt.java?p2=incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size_elementAt.java&p1=incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size.java&r1=1154558&r2=1154722&rev=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/test/java/org/apache/isis/viewer/json/applib/JsonRepresentationTest_size_elementAt.java
Sun Aug  7 16:37:57 2011
@@ -1,6 +1,7 @@
 package org.apache.isis.viewer.json.applib;
 
 import static org.apache.isis.viewer.json.applib.JsonUtils.readJson;
+import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
@@ -11,30 +12,44 @@ import org.codehaus.jackson.map.JsonMapp
 import org.junit.Before;
 import org.junit.Test;
 
-public class JsonRepresentationTest_size {
+public class JsonRepresentationTest_size_elementAt {
 
     private JsonRepresentation jsonRepresentation;
 
-    @Before
-    public void setUp() throws Exception {
-    }
-
     @Test
     public void size_forEmptyList() throws JsonParseException, JsonMappingException, IOException
{
         jsonRepresentation = new JsonRepresentation(readJson("emptyList.json"));
         assertThat(jsonRepresentation.size(), is(0));
     }
 
+    @Test(expected=IndexOutOfBoundsException.class)
+    public void elementAt_outOfBounds() throws JsonParseException, JsonMappingException,
IOException {
+        jsonRepresentation = new JsonRepresentation(readJson("emptyList.json"));
+        jsonRepresentation.elementAt(0);
+    }
+
     @Test
     public void size_forNonEmptyList() throws JsonParseException, JsonMappingException, IOException
{
         jsonRepresentation = new JsonRepresentation(readJson("list.json"));
         assertThat(jsonRepresentation.size(), is(2));
     }
 
+    @Test
+    public void elementAt_forNonEmptyList() throws JsonParseException, JsonMappingException,
IOException {
+        jsonRepresentation = new JsonRepresentation(readJson("list.json"));
+        assertThat(jsonRepresentation.elementAt(0), is(not(nullValue())));
+    }
+
     @Test(expected=IllegalStateException.class)
     public void size_forMap() throws JsonParseException, JsonMappingException, IOException
{
         jsonRepresentation = new JsonRepresentation(readJson("emptyMap.json"));
         jsonRepresentation.size();
     }
 
+    @Test(expected=IllegalStateException.class)
+    public void elementAt_forMap() throws JsonParseException, JsonMappingException, IOException
{
+        jsonRepresentation = new JsonRepresentation(readJson("emptyMap.json"));
+        jsonRepresentation.elementAt(0);
+    }
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/ResourceRepresentationTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/ResourceRepresentationTest.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/ResourceRepresentationTest.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/ResourceRepresentationTest.java
Sun Aug  7 16:37:57 2011
@@ -7,9 +7,11 @@ import static org.junit.Assert.assertTha
 import javax.ws.rs.core.Response;
 
 import org.apache.isis.runtimes.dflt.webserver.WebServer;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RestfulClient;
 import org.apache.isis.viewer.json.applib.blocks.Method;
 import org.apache.isis.viewer.json.applib.domain.DomainObjectRepresentation;
+import org.apache.isis.viewer.json.applib.domain.DomainObjectResource;
 import org.apache.isis.viewer.json.applib.domain.ServicesRepresentation;
 import org.apache.isis.viewer.json.applib.domain.ServicesResource;
 import org.apache.isis.viewer.json.applib.homepage.HomePageRepresentation;
@@ -56,12 +58,12 @@ public class ResourceRepresentationTest 
         // then
         assertThat(homePageJsonResp.getStatus(), is(HttpStatusCode.OK));
         
-        HomePageRepresentation homePageRep = homePageJsonResp.getEntity();
-        assertThat(homePageRep, is(not(nullValue())));
-        assertThat(homePageRep.getUser().getMethod(), is(Method.GET));
+        HomePageRepresentation homePageRepr = homePageJsonResp.getEntity();
+        assertThat(homePageRepr, is(not(nullValue())));
+        assertThat(homePageRepr.getUser().getMethod(), is(Method.GET));
         
-        assertThat(homePageRep.getServices(), is(not(nullValue())));
-        assertThat(homePageRep.getServices().getMethod(), is(Method.GET));
+        assertThat(homePageRepr.getServices(), is(not(nullValue())));
+        assertThat(homePageRepr.getServices().getMethod(), is(Method.GET));
     }
 
     @Test
@@ -84,7 +86,7 @@ public class ResourceRepresentationTest 
         // then
         ServicesRepresentation servicesRepr = servicesJsonResp.getEntity();
         
-        DomainObjectRepresentation applibValuesEntityRepoRep = servicesRepr.get(0);
+        JsonRepresentation applibValuesEntityRepoRep = servicesRepr.elementAt(0);
         assertThat(applibValuesEntityRepoRep, is(not(nullValue())));
     }
 
@@ -98,11 +100,91 @@ public class ResourceRepresentationTest 
         JsonResponse<ServicesRepresentation> servicesJsonResp = JsonResponse.of(servicesResp,
ServicesRepresentation.class);
         
         // then
-        ServicesRepresentation servicesRep = servicesJsonResp.getEntity();
+        ServicesRepresentation servicesRepr = servicesJsonResp.getEntity();
         
-        DomainObjectRepresentation applibValuesEntityRepoRep = servicesRep.get(0);
+        JsonRepresentation applibValuesEntityRepoRep = servicesRepr.elementAt(0);
         assertThat(applibValuesEntityRepoRep, is(not(nullValue())));
     }
 
+    @Test
+    public void domainObjectResource_returnsDomainObjectRepresentation() throws Exception
{
+        // given
+        DomainObjectResource domainObjectResource = client.getDomainObjectResource();
+        
+        // when
+        Response domainObjectResp = domainObjectResource.object("OID:1");
+        JsonResponse<DomainObjectRepresentation> domainObjectJsonResp = JsonResponse.of(domainObjectResp,
DomainObjectRepresentation.class);
+        
+        // then
+        DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
+    }
 
+    
+    
+    
 }
+//{
+//    "_self" : {
+//      "link" : {
+//        "rel" : "object",
+//        "href" : "http://localhost:8080/objects/OID:1",
+//        "method" : "GET"
+//      },
+//      "type" : {
+//        "rel" : "type",
+//        "href" : "http://localhost:8080/types/application/vnd.org.apache.isis.tck.objstore.dflt.scalars.ApplibValuesEntityRepositoryDefault+json",
+//        "method" : "GET"
+//      },
+//      "title" : "ApplibValues",
+//      "icon" : {
+//        "rel" : "icon",
+//        "href" : "http://localhost:8080/images/null.png",
+//        "method" : "GET"
+//      }
+//    },
+//    "id" : {
+//      "type" : {
+//        "rel" : "type",
+//        "href" : "http://localhost:8080/types/application/vnd.string+json",
+//        "method" : "GET"
+//      },
+//      "memberType" : "property",
+//      "value" : "org.apache.isis.tck.objstore.dflt.scalars.ApplibValuesEntityRepositoryDefault",
+//      "disabledReason" : "Always disabled; Derived",
+//      "details" : {
+//        "rel" : "property",
+//        "href" : "http://localhost:8080/objects/OID:1/properties/id",
+//        "method" : "GET"
+//      }
+//    },
+//    "list" : {
+//      "type" : {
+//        "rel" : "type",
+//        "href" : "http://localhost:8080/types/application/vnd.java.util.List+json",
+//        "method" : "GET"
+//      },
+//      "memberType" : "action",
+//      "actionType" : "USER",
+//      "numParameters" : 0,
+//      "details" : {
+//        "rel" : "action",
+//        "href" : "http://localhost:8080/objects/OID:1/actions/list",
+//        "method" : "GET"
+//      }
+//    },
+//    "newEntity" : {
+//      "type" : {
+//        "rel" : "type",
+//        "href" : "http://localhost:8080/types/application/vnd.java.lang.Object+json",
+//        "method" : "GET"
+//      },
+//      "memberType" : "action",
+//      "actionType" : "USER",
+//      "numParameters" : 0,
+//      "details" : {
+//        "rel" : "action",
+//        "href" : "http://localhost:8080/objects/OID:1/actions/newEntity",
+//        "method" : "GET"
+//      }
+//    }
+//  }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceImpl.java?rev=1154722&r1=1154721&r2=1154722&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceImpl.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceImpl.java
Sun Aug  7 16:37:57 2011
@@ -41,14 +41,14 @@ public class HomePageResourceImpl extend
         init();
         
         Representation representation = new Representation();
-        representation.put("user", linkTo("user"));
-        representation.put("services", linkTo("services"));
+        representation.put("user", linkTo("user", "user"));
+        representation.put("services", linkTo("services", "services"));
         
         return responseOfOk(asJson(representation));
     }
 
-    protected Representation linkTo(String url) {
-        return LinkRepBuilder.newBuilder(getResourceContext().repContext(url), null, url).build();
+    protected Representation linkTo(String url, String rel) {
+        return LinkRepBuilder.newBuilder(getResourceContext().repContext(url), rel, url).build();
     }
 
 



Mime
View raw message