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