diff --git a/enunciate.xml b/enunciate.xml new file mode 100644 index 0000000..274c424 --- /dev/null +++ b/enunciate.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gcube/extra-resources/WEB-INF/gcube-app.xml b/gcube/extra-resources/WEB-INF/gcube-app.xml new file mode 100644 index 0000000..4f4797e --- /dev/null +++ b/gcube/extra-resources/WEB-INF/gcube-app.xml @@ -0,0 +1,9 @@ + + + + ${project.artifactId} + ${project.groupId} + ${project.version} + ${project.description} + /docs/* + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 684c6db..cbeb458 100644 --- a/pom.xml +++ b/pom.xml @@ -11,9 +11,11 @@ org.gcube.common authorization-bridge 1.0.0-SNAPSHOT + war UTF-8 + 2.14.0 @@ -64,6 +66,21 @@ jersey-media-multipart + + + org.geotoolkit + geotk-xml-base + 3.20-geoapi-3.0 + provided + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + junit @@ -78,4 +95,51 @@ + + + + + + com.webcohesion.enunciate + enunciate-maven-plugin + ${enunciate.version} + + + assemble + + assemble + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-enunciate-docs + process-resources + + copy-resources + + + target + + + ${project.build.directory}/${project.artifactId}-${project.version}/docs + ${project.build.directory}/docs + true + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/common/authorization/rest/Docs.java b/src/main/java/org/gcube/common/authorization/rest/Docs.java new file mode 100644 index 0000000..ff8997b --- /dev/null +++ b/src/main/java/org/gcube/common/authorization/rest/Docs.java @@ -0,0 +1,52 @@ +package org.gcube.common.authorization.rest; + +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.InternalServerErrorException; +import javax.ws.rs.Path; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Francesco Mangiacrapa (ISTI-CNR) + * @author Luca Frosini (ISTI-CNR) + */ +@Path("docs") +public class Docs { + + private static Logger logger = LoggerFactory.getLogger(Docs.class); + + @GET + @Path("{any: .*}") + public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { + + String pathInfo = req.getPathInfo(); + try { + + if (pathInfo.endsWith("/docs")) { + pathInfo += "/index.html"; + } + + if (pathInfo.endsWith("/docs/")) { + pathInfo += "index.html"; + } + + logger.info("redirecting to {}", pathInfo); + + String realPath = req.getServletContext().getRealPath(pathInfo); + return new FileInputStream(new File(realPath)); + + } catch (Exception e) { + throw new InternalServerErrorException(e); + } + } + +} + diff --git a/src/main/webapp/WEB-INF/.gitignore b/src/main/webapp/WEB-INF/.gitignore new file mode 100644 index 0000000..a252987 --- /dev/null +++ b/src/main/webapp/WEB-INF/.gitignore @@ -0,0 +1,5 @@ +/LICENSE.md +/README.md +/changelog.xml +/gcube-app.xml +/CHANGELOG.md diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..25f90d1 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,11 @@ + + + + + org.gcube.org.gcube.common.authorization.ResourceInitializer + + + org.gcube.org.gcube.common.authorization.ResourceInitializer + /* + + \ No newline at end of file