added index.jsp
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174036 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e956a6221a
commit
26d3704575
10
pom.xml
10
pom.xml
|
@ -103,11 +103,11 @@
|
|||
</dependency>
|
||||
|
||||
<!-- jersey -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.ext</groupId>
|
||||
<artifactId>jersey-mvc-jsp</artifactId>
|
||||
<version>2.13</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.glassfish.jersey.ext</groupId> -->
|
||||
<!-- <artifactId>jersey-mvc-jsp</artifactId> -->
|
||||
<!-- <version>2.13</version> -->
|
||||
<!-- </dependency> -->
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.datatransfer.resolver;
|
|||
import javax.ws.rs.Path;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;
|
||||
|
||||
@Path("uri-resolver")
|
||||
public class UriResolver extends ResourceConfig {
|
||||
|
@ -11,8 +10,8 @@ public class UriResolver extends ResourceConfig {
|
|||
public UriResolver() {
|
||||
// Register all resources present under the package.
|
||||
packages("org.gcube.datatransfer.resolver.services","org.gcube.datatransfer.resolver.requesthandler");
|
||||
property(JspMvcFeature.TEMPLATES_BASE_PATH, "/WEB-INF/jsp");
|
||||
register(JspMvcFeature.class);
|
||||
// register(JspMvcFeature.class);
|
||||
// property(MvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,237 +0,0 @@
|
|||
///**
|
||||
// *
|
||||
// */
|
||||
//package org.gcube.datatransfer.resolver;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.HashSet;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import javax.servlet.Filter;
|
||||
//import javax.servlet.FilterChain;
|
||||
//import javax.servlet.FilterConfig;
|
||||
//import javax.servlet.ServletException;
|
||||
//import javax.servlet.ServletRequest;
|
||||
//import javax.servlet.ServletResponse;
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
//import org.gcube.datatransfer.resolver.catalogue.CatalogueRequestParameter;
|
||||
//import org.gcube.datatransfer.resolver.catalogue.UrlEncoderUtil;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * The Class UriResolverRewriteFilter.
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Dec 5, 2016
|
||||
// */
|
||||
//public class UriResolverRewriteFilter implements Filter{
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// public static final String SERVLET_URI_RESOLVER = "/uri-resolver";
|
||||
//
|
||||
// private static final String PATH_SEPARATOR = "/";
|
||||
// public static final String SERVLET_GEONETWORK = "/geonetwork";
|
||||
// public static final String REQUEST_PARAMETER_SEPARATOR = "#";
|
||||
//
|
||||
// public static final String PARAMETER_SMP_ID = "smp-id";
|
||||
// public static final String SERVLET_STORAGE_ID = "id";
|
||||
//
|
||||
// public static final String PARAMETER_ENC_CATALOGUE_LINK = "cl";
|
||||
// public static final String PARAMETER_DIRECT_CATALOGUE_LINK = "dl";
|
||||
// public static final String SERVLET_CATALOGUE = "/catalogue";
|
||||
//
|
||||
// protected static final Logger logger = LoggerFactory.getLogger(UriResolverRewriteFilter.class);
|
||||
// private FilterConfig config;
|
||||
//
|
||||
// private static final Set<String> resourceCataloguesCodes = new HashSet<String>(ResourceCatalogueCodes.codes());
|
||||
//
|
||||
// //private ApplicationProfileReaderForCatalogueResolver appPrfCatResolver = new ApplicationProfileReaderForCatalogueResolver(scope, useRootScope)
|
||||
//
|
||||
// /**
|
||||
// * Gets the config.
|
||||
// *
|
||||
// * @return the config
|
||||
// */
|
||||
// public FilterConfig getConfig() {
|
||||
//
|
||||
// return config;
|
||||
// }
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#destroy()
|
||||
// */
|
||||
// @Override
|
||||
// public void destroy() {
|
||||
// logger.trace("run destroy");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
||||
// */
|
||||
// @Override
|
||||
// public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
// /* wrap the request in order to read the inputstream multiple times */
|
||||
// MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest((HttpServletRequest) req);
|
||||
// String requestURI = multiReadRequest.getRequestURI();
|
||||
// String queryString = multiReadRequest.getQueryString();
|
||||
// String servletPath = multiReadRequest.getServletPath();
|
||||
// logger.debug("Request URI: " + requestURI + ", QueryString: " +queryString+ ", Servlet path: "+servletPath);
|
||||
//
|
||||
// try{
|
||||
// //IS A REQUEST FOR GEONETWORK AUTHENTICATION? (CKAN HARVESTING?)
|
||||
// if(servletPath.startsWith(SERVLET_GEONETWORK) || servletPath.startsWith(SERVLET_URI_RESOLVER+SERVLET_GEONETWORK)){
|
||||
// logger.debug("It is a request to geonetwork");
|
||||
// GeonetworkRequestDecoder grd = new GeonetworkRequestDecoder(servletPath, queryString);
|
||||
// logger.debug("forward to: "+grd.getGeonetworkResolverURIRequest());
|
||||
// multiReadRequest.getRequestDispatcher(grd.getGeonetworkResolverURIRequest()).forward(multiReadRequest, response);
|
||||
//
|
||||
// }else{
|
||||
// logger.debug("checking if it is a request to catologue...");
|
||||
// boolean isCatalogueServletReference = servletPath.startsWith(SERVLET_CATALOGUE);
|
||||
//
|
||||
// String idCodeCatalogue = null;
|
||||
// boolean isIdCodeCatalogue = false;
|
||||
// String splittedServletPath[] = servletPath.split(PATH_SEPARATOR);
|
||||
// if(!isCatalogueServletReference){
|
||||
// idCodeCatalogue = splittedServletPath[1];
|
||||
// logger.trace("checking if the code: "+idCodeCatalogue+" belongs to a catalogue code");
|
||||
// isIdCodeCatalogue = resourceCataloguesCodes.contains(idCodeCatalogue);
|
||||
// logger.debug("\tIs it a catalogue code? "+isIdCodeCatalogue);
|
||||
// }
|
||||
//
|
||||
// if(isCatalogueServletReference || isIdCodeCatalogue){
|
||||
//
|
||||
// //int startIndex = requestURI.indexOf(SERVLET_CATALOGUE))+SERVLET_CATALOGUE.length();
|
||||
// //String vreName = requestURI.substring(beginIndex)
|
||||
// HttpServletRequest request = (HttpServletRequest) req;
|
||||
// logger.trace("method is: "+request.getMethod());
|
||||
//
|
||||
// if(request.getMethod().compareToIgnoreCase("POST")==0){
|
||||
// logger.debug("Managing as Catalogue POST request..");
|
||||
// logger.debug("forward to: " + SERVLET_CATALOGUE);
|
||||
// multiReadRequest.getRequestDispatcher(SERVLET_CATALOGUE).forward(multiReadRequest, response);
|
||||
// }else{
|
||||
// logger.debug("Managing as Catalogue GET request..");
|
||||
// String newURI = SERVLET_CATALOGUE;
|
||||
// //String[] pathSplit = newServletPath.split(PATH_SEPARATOR);
|
||||
// if(isIdCodeCatalogue){
|
||||
// //TO BUILD A COMPLETE URL
|
||||
// // logger.debug("is a catalogue code, rebuilding complete url...");
|
||||
// // ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfId(idCodeCatalogue);
|
||||
// // newServletPath = SERVLET_CATALOGUE+splittedServletPath[2]+PATH_SEPARATOR+rcc.getValue()+PATH_SEPARATOR+splittedServletPath[3];
|
||||
// // logger.debug("rebuilded complete url: "+newServletPath);
|
||||
// logger.debug("is a catalogue code, resolving a short url in clear ...");
|
||||
// ResourceCatalogueCodes rcc = ResourceCatalogueCodes.valueOfCodeId(idCodeCatalogue);
|
||||
// logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
// String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
// String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+rcc.getValue();
|
||||
// logger.debug("found id code: "+idCodeCatalogue+", resolving it with context name: "+eC);
|
||||
// String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[3];
|
||||
// logger.debug("found entity name: "+eN);
|
||||
// String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
|
||||
// newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
|
||||
// }else
|
||||
// if(splittedServletPath.length==5){
|
||||
// logger.info("resolving a complete URL in clear...");
|
||||
// logger.debug("found VRE name: "+splittedServletPath[2]);
|
||||
// String gcubeScope = CatalogueRequestParameter.GCUBE_SCOPE.getKey() +"="+splittedServletPath[2];
|
||||
// String eC = CatalogueRequestParameter.ENTITY_CONTEXT.getKey() +"="+splittedServletPath[3];
|
||||
// logger.debug("found context name: "+eC);
|
||||
// String eN = CatalogueRequestParameter.ENTITY_NAME.getKey() +"="+splittedServletPath[4];
|
||||
// logger.debug("found entity name: "+eN);
|
||||
// String encodedQuery = UrlEncoderUtil.encodeQuery(gcubeScope,eC,eN);
|
||||
// newURI+= "?" + PARAMETER_DIRECT_CATALOGUE_LINK + "=" + encodedQuery;
|
||||
// }else{
|
||||
//
|
||||
// logger.info("Resolving an encrypted URL to catalogue...");
|
||||
// int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
|
||||
// String toCatalogueLink = requestURI.substring(lastSlash + 1, requestURI.length());
|
||||
// newURI+= "?" + PARAMETER_ENC_CATALOGUE_LINK + "=" + toCatalogueLink;
|
||||
// }
|
||||
//
|
||||
// logger.debug("forward to: " + newURI);
|
||||
// multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
|
||||
// }
|
||||
//
|
||||
// //chain.doFilter(multiReadRequest, response);
|
||||
// }else{
|
||||
// logger.debug("It is a request to workspace/storage");
|
||||
// //LAST CASE, IS WORKSPACE REQUEST?
|
||||
// if (queryString == null) { // IS A /XXXXX
|
||||
// logger.debug("QueryString is null, is It a new SMP public uri by ID?");
|
||||
// int lastSlash = requestURI.lastIndexOf(PATH_SEPARATOR);
|
||||
// if (lastSlash + 1 == requestURI.length()) {
|
||||
// logger.debug("'/' is last index, doFilter Request");
|
||||
// // req.getRequestDispatcher("/").forward(req, res);
|
||||
// chain.doFilter(multiReadRequest, response);
|
||||
// }
|
||||
// else {
|
||||
// String toStorageID = requestURI.substring(lastSlash + 1, requestURI.length());
|
||||
// // String newURI = requestURI.replace(toReplace,
|
||||
// // SERVLET_RESOLVER_BY_ID+"?"+SMP_ID+"="+toReplace);
|
||||
// String newURI = SERVLET_STORAGE_ID + "?" + PARAMETER_SMP_ID + "=" + toStorageID;
|
||||
// logger.debug("forward to: " + newURI);
|
||||
// multiReadRequest.getRequestDispatcher(newURI).forward(multiReadRequest, response);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// logger.debug("It is NOT a SMP public uri by ID, doFilter Request");
|
||||
// chain.doFilter(multiReadRequest, response);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }catch(BadRequestException bre){
|
||||
// if (response instanceof HttpServletResponse){
|
||||
// HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||
// httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, bre.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Gets the scope.
|
||||
// *
|
||||
// * @param scope the scope
|
||||
// * @return the scope
|
||||
// */
|
||||
// private static String getScope(String scope){
|
||||
// logger.debug("Read scope path: "+scope);
|
||||
//// String scope = servletPath.substring(servletPath.indexOf("/"), servletPath.length());
|
||||
// return PATH_SEPARATOR+scope.replaceAll("_", PATH_SEPARATOR);
|
||||
// }
|
||||
//
|
||||
// /* (non-Javadoc)
|
||||
// * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
||||
// */
|
||||
// @Override
|
||||
// public void init(FilterConfig config) throws ServletException {
|
||||
// logger.trace("run init");
|
||||
// this.config = config;
|
||||
// }
|
||||
//
|
||||
// /*public static void main(String[] args) {
|
||||
//
|
||||
// String split = "/catalogue/NextNext/dataset/sarda-sarda";
|
||||
//
|
||||
// String[] array = split.split("/");
|
||||
//
|
||||
// System.out.println(array.length);
|
||||
//
|
||||
// for (int i = 0; i < array.length; i++) {
|
||||
// System.out.println(i+" "+array[i]);
|
||||
// }
|
||||
//
|
||||
// System.out.println(array[2]);
|
||||
//
|
||||
// }*/
|
||||
//}
|
|
@ -3,29 +3,49 @@
|
|||
*/
|
||||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
///**
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Oct 22, 2018
|
||||
// */
|
||||
//@Path("/")
|
||||
//public class UriResolverIndex {
|
||||
//
|
||||
// private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class);
|
||||
//
|
||||
// @GET
|
||||
// @Produces(MediaType.TEXT_HTML)
|
||||
// @Path("index")
|
||||
// public Viewable index(@Context HttpServletRequest req, @PathParam("index") String info){
|
||||
//
|
||||
// try{
|
||||
// logger.info("UriResolverIndex called");
|
||||
// return new Viewable("/index");
|
||||
// }catch(Exception e){
|
||||
// logger.error("Error on getting index.jsp", e);
|
||||
// throw new InternalServerException(req, Status.NOT_FOUND, "Index.jsp not found", UriResolverIndex.class, null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Oct 22, 2018
|
||||
*/
|
||||
@Path("")
|
||||
public class UriResolverIndex {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class);
|
||||
|
||||
@GET
|
||||
@Produces({MediaType.TEXT_HTML})
|
||||
@Path("{toInfo:(index|info)?")
|
||||
public InputStream index(@Context HttpServletRequest req, @PathParam("toInfo") String info){
|
||||
|
||||
String indexFile = "/WEB-INF/jsp/index.jsp";
|
||||
|
||||
try{
|
||||
logger.info("UriResolverIndex called");
|
||||
String realPath = req.getServletContext().getRealPath(indexFile);
|
||||
return new FileInputStream(new File(realPath));
|
||||
}catch(Exception e){
|
||||
logger.error("Error on getting "+indexFile, e);
|
||||
throw new InternalServerException(req, Status.NOT_FOUND, "Index.jsp not found", UriResolverIndex.class, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
<name>URIResolver</name>
|
||||
<group>DataTransfer</group>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<description>Storage Hub webapp</description>
|
||||
<description>URIResolver RESTful</description>
|
||||
<exclude handlers='request-validation context-retriever'>/*</exclude>
|
||||
</application>
|
|
@ -1,22 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<!-- <head> -->
|
||||
<!-- <meta charset="UTF-8"> -->
|
||||
<!-- <meta http-equiv="refresh" content="0; url=https://dev4.d4science.org/ckan"> -->
|
||||
<!-- <script type="text/javascript"> window.location.href = "https://dev4.d4science.org/ckan" -->
|
||||
<!-- </script> -->
|
||||
<!-- <title>Page Redirection</title> -->
|
||||
<!-- </head> -->
|
||||
<!-- <body> -->
|
||||
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
|
||||
<!-- If you are not redirected automatically, follow the <a href='https://dev4.d4science.org/ckan'>link to example</a> -->
|
||||
<!-- </body> -->
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #f8f6f2;
|
||||
color: #225f97;
|
||||
font-family: 'Droid Sans', arial, sans-serif;
|
||||
}
|
||||
|
||||
.mydiv {
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 30em;
|
||||
height: 18em;
|
||||
margin-top: -9em; /*set to a negative number 1/2 of your height*/
|
||||
margin-left: -15em; /*set to a negative number 1/2 of your width*/
|
||||
/* border: 1px solid #ccc; */
|
||||
/* background-color: #9b9b9b; */
|
||||
position: fixed;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.myTitle {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>The URI resolver</h2>
|
||||
<div class="mydiv">
|
||||
<img alt=""
|
||||
src="https://www.d4science.org/image/layout_set_logo?img_id=12630" />
|
||||
<div class="myTitle">The URI Resolver</div>
|
||||
<p>
|
||||
See wiki page: <a
|
||||
href="https://gcube.wiki.gcube-system.org/gcube/index.php/URI_Resolver">URI
|
||||
Resolver gCube Wiki</a>
|
||||
See wiki page at <a
|
||||
href="https://gcube.wiki.gcube-system.org/gcube/index.php/URI_Resolver" target="_blank">gCube Wiki URI
|
||||
Resolver</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -3,18 +3,18 @@
|
|||
|
||||
<context-param>
|
||||
<param-name>root-app-token</param-name>
|
||||
<param-value>e22a46ac-418c-49f2-ad3f-99a5b9689825-98187548</param-value>
|
||||
<param-value>e22a46ac-418c-49f2-ad3f-99a5b9689825-98187548
|
||||
</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>root-scope</param-name>
|
||||
<param-value>/gcube</param-value>
|
||||
</context-param>
|
||||
root-scope
|
||||
|
||||
<servlet>
|
||||
<servlet-name>org.gcube.datatransfer.resolver.UriResolver</servlet-name>
|
||||
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>org.gcube.datatransfer.resolver.UriResolver</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<!-- <head> -->
|
||||
<!-- <meta charset="UTF-8"> -->
|
||||
<!-- <meta http-equiv="refresh" content="0; url=https://dev4.d4science.org/ckan"> -->
|
||||
<!-- <script type="text/javascript"> window.location.href = "https://dev4.d4science.org/ckan" -->
|
||||
<!-- </script> -->
|
||||
<!-- <title>Page Redirection</title> -->
|
||||
<!-- </head> -->
|
||||
<!-- <body> -->
|
||||
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
|
||||
<!-- If you are not redirected automatically, follow the <a href='https://dev4.d4science.org/ckan'>link to example</a> -->
|
||||
<!-- </body> -->
|
||||
<body>
|
||||
<h2>The URI resolver</h2>
|
||||
<p>
|
||||
See wiki page: <a
|
||||
href="https://gcube.wiki.gcube-system.org/gcube/index.php/URI_Resolver">URI
|
||||
Resolver gCube Wiki</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue