From 94b3006b8a83d183b9f0df28a41e664dfd705697 Mon Sep 17 00:00:00 2001
From: "francesco.mangiacrapa"
Date: Thu, 24 Mar 2022 15:37:54 +0100
Subject: [PATCH] changed UriResolverDocs
---
pom.xml | 24 -------------------
.../resolver/services/UriResolverDocs.java | 20 +++++++++++-----
src/main/webapp/WEB-INF/jsp/index.jsp | 2 +-
3 files changed, 15 insertions(+), 31 deletions(-)
diff --git a/pom.xml b/pom.xml
index 66f45e3..bcce5cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -259,30 +259,6 @@
test
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
org.geotoolkit
diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java
index c67695f..2e2d61c 100644
--- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java
+++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java
@@ -33,18 +33,26 @@ public class UriResolverDocs {
@Produces({MediaType.TEXT_HTML})
@Path("")
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{
-
- String indexFile = "/docs/index.html";
-
+ logger.info(UriResolverDocs.class.getSimpleName() +" called");
+
+ String requestURI = req.getRequestURI();
try{
- logger.info(UriResolverDocs.class.getSimpleName() +" called");
- String realPath = req.getServletContext().getRealPath(indexFile);
+
+
+ if(requestURI == null)
+ requestURI = "/index.html";
+
+ String pathInfo = req.getPathInfo();
+ logger.info("pathInfo {}",pathInfo);
+ logger.info("request URI {}", requestURI);
+
+ String realPath = req.getServletContext().getRealPath("/docs/"+requestURI);
return new FileInputStream(new File(realPath));
}catch (Exception e) {
if(!(e instanceof WebApplicationException)){
//UNEXPECTED EXCEPTION managing it as WebApplicationException
- String error = "Index.jsp not found. Please, contact the support!";
+ String error = requestURI+" not found. Please, contact the support!";
throw ExceptionManager.internalErrorException(req, error, this.getClass(), null);
}
//ALREADY MANAGED AS WebApplicationException
diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp
index 44d30cd..df8421c 100644
--- a/src/main/webapp/WEB-INF/jsp/index.jsp
+++ b/src/main/webapp/WEB-INF/jsp/index.jsp
@@ -44,7 +44,7 @@ body {
See API documentation at URI Resolver API