fixing paths
This commit is contained in:
parent
2683d601b0
commit
fd9a10be6c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue