changed UriResolverDocs

This commit is contained in:
Francesco Mangiacrapa 2022-03-24 15:37:54 +01:00
parent e53a5cc3ee
commit 94b3006b8a
3 changed files with 15 additions and 31 deletions

24
pom.xml
View File

@ -259,30 +259,6 @@
<scope>test</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>com.webcohesion.enunciate</groupId> -->
<!-- <artifactId>enunciate-core-annotations</artifactId> -->
<!-- <version>${enunciate.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>com.webcohesion.enunciate</groupId> -->
<!-- <artifactId>enunciate-rt-util</artifactId> -->
<!-- <version>${enunciate.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>javax.xml.bind</groupId> -->
<!-- <artifactId>jaxb-api</artifactId> -->
<!-- <version>${jaxb.version}</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>com.sun.xml.bind</groupId> -->
<!-- <artifactId>jaxb-core</artifactId> -->
<!-- <version>${jaxb-core.version}</version> -->
<!-- </dependency> -->
<!-- Required for Enunciate plugin -->
<dependency>
<groupId>org.geotoolkit</groupId>

View File

@ -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

View File

@ -44,7 +44,7 @@ body {
</p>
<p>
See API documentation at <a
href="docs/index.html"
href="docs"
target="_blank">URI Resolver API</a>
</p>
</div>