aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorttsanton2014-02-07 16:18:00 (EST)
committerttsanton2014-02-07 16:18:00 (EST)
commitc1ab4a6f1fc8778ec529a448514fdad4cd4d9479 (patch)
tree841140e86f4857e431ae6ce8b57fed045b35e226
parent9d22c9047ffcfd88c1c711e27cf824d334cde2f3 (diff)
downloadorg.eclipse.lyo.rio-c1ab4a6f1fc8778ec529a448514fdad4cd4d9479.zip
org.eclipse.lyo.rio-c1ab4a6f1fc8778ec529a448514fdad4cd4d9479.tar.gz
org.eclipse.lyo.rio-c1ab4a6f1fc8778ec529a448514fdad4cd4d9479.tar.bz2
Bug 393803 - Add compact representations to the Automation RIO refs/changes/02/21702/1
Change-Id: I8e245e29f2c30ae53411078ae630ff3f2a06aa3c Signed-off-by: ttsanton <ttsanton@us.ibm.com>
-rw-r--r--org.eclipse.lyo.oslc4j.automation/src/main/java/org/eclipse/lyo/oslc4j/automation/resources/BaseAutoResource.java35
-rw-r--r--org.eclipse.lyo.oslc4j.automation/src/main/webapp/web/autoresource_preview_large.jsp39
2 files changed, 73 insertions, 1 deletions
diff --git a/org.eclipse.lyo.oslc4j.automation/src/main/java/org/eclipse/lyo/oslc4j/automation/resources/BaseAutoResource.java b/org.eclipse.lyo.oslc4j.automation/src/main/java/org/eclipse/lyo/oslc4j/automation/resources/BaseAutoResource.java
index 61012d9..b1d8617 100644
--- a/org.eclipse.lyo.oslc4j.automation/src/main/java/org/eclipse/lyo/oslc4j/automation/resources/BaseAutoResource.java
+++ b/org.eclipse.lyo.oslc4j.automation/src/main/java/org/eclipse/lyo/oslc4j/automation/resources/BaseAutoResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corporation.
+ * Copyright (c) 2012, 2014 IBM Corporation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -16,6 +16,7 @@
*******************************************************************************/
package org.eclipse.lyo.oslc4j.automation.resources;
+import java.io.IOException;
import java.lang.reflect.Array;
import java.net.URI;
import java.net.URISyntaxException;
@@ -24,6 +25,7 @@ import java.util.Date;
import java.util.List;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
@@ -43,6 +45,7 @@ import org.eclipse.lyo.oslc4j.automation.Persistence;
import org.eclipse.lyo.oslc4j.automation.servlet.ServiceProviderSingleton;
import org.eclipse.lyo.oslc4j.core.model.Compact;
import org.eclipse.lyo.oslc4j.core.model.OslcMediaType;
+import org.eclipse.lyo.oslc4j.core.model.Preview;
public class BaseAutoResource<T extends AutomationResource>
{
@@ -135,12 +138,42 @@ public class BaseAutoResource<T extends AutomationResource>
compact.setIcon(iconURI);
+ //Create and set attributes for preview resource
+ final Preview largePreview = new Preview();
+ largePreview.setHintHeight("20em");
+ largePreview.setHintWidth("35em");
+ largePreview.setDocument(new URI(compact.getAbout().toString() + "/largePreview"));
+ compact.setLargePreview(largePreview);
+
return compact;
}
throw new WebApplicationException(Status.NOT_FOUND);
}
+ @GET
+ @Path("{resourceId}/largePreview")
+ @Produces({ MediaType.TEXT_HTML })
+ public void getLargePreview(@Context final HttpServletRequest httpServletRequest,
+ @Context final HttpServletResponse httpServletResponse,
+ @PathParam("resourceId") final String resourceId) throws ServletException, IOException, URISyntaxException
+ {
+ final T autoResource = Persistence.getAutoResource(resourceId, resourceType);
+
+ if (autoResource != null)
+ {
+
+ httpServletRequest.setAttribute("autoResource", autoResource);
+
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("/web/autoresource_preview_large.jsp");
+ rd.forward(httpServletRequest, httpServletResponse);
+
+ }
+
+ throw new WebApplicationException(Status.NOT_FOUND);
+
+ }
+
@GET
@Path("selector")
@Produces({MediaType.TEXT_HTML, MediaType.WILDCARD})
diff --git a/org.eclipse.lyo.oslc4j.automation/src/main/webapp/web/autoresource_preview_large.jsp b/org.eclipse.lyo.oslc4j.automation/src/main/webapp/web/autoresource_preview_large.jsp
new file mode 100644
index 0000000..b5d0c7d
--- /dev/null
+++ b/org.eclipse.lyo.oslc4j.automation/src/main/webapp/web/autoresource_preview_large.jsp
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<%--
+ Copyright (c) 2011, 2014 IBM Corporation.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ and Eclipse Distribution License v. 1.0 which accompanies this distribution.
+
+ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ and the Eclipse Distribution License is available at
+ http://www.eclipse.org/org/documents/edl-v10.php.
+
+ Contributors:
+
+ Sam Padgett - initial API and implementation
+ Michael Fiedler - adapt for OSLC4J
+--%>
+<%@ page contentType="text/html" language="java" pageEncoding="UTF-8" %>
+<%@ page import="java.net.*,java.util.*" %>
+<%@ page import="org.eclipse.lyo.oslc4j.automation.AutomationResource" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%
+AutomationResource autoResource = (AutomationResource) request.getAttribute("autoResource");
+%>
+<html>
+<head>
+<title>Automation Resource: <c:out value="${autoResource.title}"/> (<c:out value="${autoResource.identifier}"/>)</title>
+</head>
+<body>
+Large Compact Preview<hr/>
+Resource Type: <%= autoResource.getClass().getSimpleName()%><br/>
+URI: <a href="<%= autoResource.getAbout().toString()%>"><%= autoResource.getAbout().toString()%></a> <br/>
+Title: <c:out value="${autoResource.title}"/><br/>
+Description: <c:out value="${autoResource.description}">No Description Available</c:out><br/>
+Identifier: <c:out value="${autoResource.identifier}"/><br/>
+Created: <%= autoResource.getCreated().toLocaleString()%><br/>
+Last Modified: <%= autoResource.getModified().toLocaleString()%><br/>
+</body>
+</html> \ No newline at end of file