feature_23113 #4

Merged
francesco.mangiacrapa merged 58 commits from feature_23113 into master 2022-04-06 09:59:06 +02:00
2 changed files with 30 additions and 7 deletions
Showing only changes of commit fd9a10be6c - Show all commits

View File

@ -31,18 +31,17 @@ public class UriResolverDocs {
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("/{any: .*}")
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException {
logger.info(UriResolverDocs.class.getSimpleName() + " called");
public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException {
logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called");
String pathInfo = req.getPathInfo();
logger.info("pathInfo {}", pathInfo);
try {
if (pathInfo.equals("docs"))
pathInfo += "/index.html";
if (pathInfo.equals("/docs/"))
pathInfo += "index.html";
logger.info("redirecting to {}", pathInfo);
logger.info("request URI {}", req.getRequestURI());
String realPath = req.getServletContext().getRealPath(pathInfo);
return new FileInputStream(new File(realPath));
@ -58,5 +57,29 @@ public class UriResolverDocs {
throw (WebApplicationException) e;
}
}
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("")
public InputStream index(@Context HttpServletRequest req) throws WebApplicationException {
logger.info(UriResolverDocs.class.getSimpleName() + " index called");
String pathInfo = "/docs/index.html";
try {
String realPath = req.getServletContext().getRealPath(pathInfo);
return new FileInputStream(new File(realPath));
} catch (Exception e) {
if (!(e instanceof WebApplicationException)) {
// UNEXPECTED EXCEPTION managing it as WebApplicationException
String error = pathInfo + " not found. Please, contact the support!";
throw ExceptionManager.internalErrorException(req, error, this.getClass(), null);
}
// ALREADY MANAGED AS WebApplicationException
logger.error("Exception:", e);
throw (WebApplicationException) e;
}
}
}

View File

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