summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-08-02 17:23:19 (EDT)
committer David Terry2013-08-06 11:34:45 (EDT)
commit78ecf313819944c6adfb855ca4ae138d9064fefb (patch)
treed24a560839f7993cc66cec77b53f0f7ca530333d
parent9c7ed585c30cb16269dcfc81afef41718f06be47 (diff)
downloadorg.eclipse.lyo.rio-78ecf313819944c6adfb855ca4ae138d9064fefb.zip
org.eclipse.lyo.rio-78ecf313819944c6adfb855ca4ae138d9064fefb.tar.gz
org.eclipse.lyo.rio-78ecf313819944c6adfb855ca4ae138d9064fefb.tar.bz2
[414341] TRS Reference Application should return turtle format byrefs/changes/08/15108/2
default Change-Id: I1840688d068368d72652396dc5fdefd7ddf4f834 Signed-off-by: David Terry <dgterry@us.ibm.com>
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java8
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js25
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/index.html14
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/webapp/result.html19
4 files changed, 59 insertions, 7 deletions
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java
index 41cb073..fb41b40 100644
--- a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/resources/BaseResource.java
@@ -81,8 +81,14 @@ public class BaseResource {
URI requestURI = uriInfo.getRequestUri();
boolean endsWithSlash = requestURI.getPath().endsWith("/");
+ String redirectUrl = (endsWithSlash ? "" : "base/") + "1";
- throw new WebApplicationException(Response.temporaryRedirect(requestURI.resolve((endsWithSlash ? "" : "base/") + "1")).build());
+ // Reapply any query params before redirecting
+ if (requestURI.getQuery() != null) {
+ redirectUrl = redirectUrl + "?" + requestURI.getQuery();
+ }
+
+ throw new WebApplicationException(Response.temporaryRedirect(requestURI.resolve(redirectUrl)).build());
}
/**
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js b/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js
index 1b77794..1d42a78 100644
--- a/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/TestApp.js
@@ -154,3 +154,28 @@ function deleteResource(resUrl, currentUrl){
}
}
}
+
+function getTurtle(url) {
+ var resourceUrl = new String(url);
+ var mainUrl = resourceUrl.split('result.html')[0];
+ resourceUrl = resourceUrl.split('=')[1];
+ xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", resourceUrl, true);
+ xmlhttp.setRequestHeader("Accept", "text/turtle");
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState==4 && (xmlhttp.status==200)) {
+ // Add the turtle as a new child node under the result div tag on
+ // our html page. The div tag is encapsulated in a <pre> tag so the
+ // turtle should display nicely to the user.
+ var n = document.getElementById("result");
+ n.innerHTML = '';
+ n.appendChild(document.createTextNode(xmlhttp.responseText));
+
+ // Display the URI of the resource for the user (which differs from this result page)
+ document.getElementById("resourceuri").innerHTML = "URI of retrieved resource: " + mainUrl + resourceUrl;
+
+ document.getElementById("mainurl").innerHTML = '<a href="' + mainUrl + '">Back to main TRS Reference Application URL</a>';
+ }
+ };
+ xmlhttp.send(null);
+}
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/index.html b/org.eclipse.lyo.rio.trs/src/main/webapp/index.html
index cbee785..5199cf8 100644
--- a/org.eclipse.lyo.rio.trs/src/main/webapp/index.html
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/index.html
@@ -6,17 +6,20 @@
<!-- -->
<html>
+<head>
+<title>TRS Reference Application</title>
+</head>
<body>
<font face="Arial">
<h1>TRS Reference Application</h1>
<p>Here are the REST resource endpoints for the base resource and the tracked resource set:</p>
<ul>
- <li><a href="rest/trs/base">Base Resources</a></li>
- <li><a href="rest/trs">Tracked Resource Set</a></li>
+ <li><a href="result.html?url=rest/trs/base">Base Resources</a></li>
+ <li><a href="result.html?url=rest/trs">Tracked Resource Set</a></li>
- <li><a href="restx/trs/base">Generic Base Resources</a></li>
- <li><a href="restx/trs">Generic Tracked Resource Set</a></li>
+ <li><a href="result.html?url=restx/trs/base">Generic Base Resources</a></li>
+ <li><a href="result.html?url=restx/trs">Generic Tracked Resource Set</a></li>
<li>EXPERIMENTAL - <a href="CutOffEvent_modify.jsp">Modify Cutoff Event</a></li>
</ul>
<br>
@@ -27,9 +30,8 @@
<li><a href="rest/changeRequests/populate">Populate Test Data</a> - kick off creation of some sample Change Requests</li>
</ul>
-
-
<p>View TRS Reference Application <a href="rest">REST Services document</a></p>
+
</font>
</body>
</html> \ No newline at end of file
diff --git a/org.eclipse.lyo.rio.trs/src/main/webapp/result.html b/org.eclipse.lyo.rio.trs/src/main/webapp/result.html
new file mode 100644
index 0000000..cda101b
--- /dev/null
+++ b/org.eclipse.lyo.rio.trs/src/main/webapp/result.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+
+<!-- Licensed Materials - Use restricted, please refer to the "Samples Gallery" terms and conditions in the IBM International Program License Agreement (IPLA). -->
+<!-- © Copyright IBM Corporation 2013. All Rights Reserved. -->
+<!-- U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
+<!-- -->
+<html>
+ <head>
+ <script type="text/javascript" src= 'TestApp.js'></script>
+ </head>
+ <body onload="getTurtle(window.location)">
+ <h1>Resource GET Results</h1>
+ <p id="resourceuri">URI of retrieved resource: </p>
+ <pre>
+ <div id="result"></div>
+ </pre>
+ <div id="mainurl"></div>
+ </body>
+</html> \ No newline at end of file