diff --git a/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherFactory.java b/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherFactory.java index 03670e6..c9d4488 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherFactory.java +++ b/src/fr/devinsy/kiss4web/dispatcher/KissDispatcherFactory.java @@ -121,6 +121,73 @@ public class KissDispatcherFactory } } + /** + * Checks if is available class. + * + * @param className + * the class name + * @return true, if is available class + */ + private boolean isAvailableClass(final String className) + { + boolean result; + + try + { + Class servletClass = (Class) Class.forName(className); + result = true; + } + catch (java.lang.ClassNotFoundException exception) + { + result = false; + } + + // + return result; + } + + /** + * Checks if is availableget path. + * + * @param servletConfig + * the servlet config + * @param request + * the request + * @param response + * the response + * @param urlPath + * the url path + * @return true, if is availableget path + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws ServletException + * the servlet exception + */ + public boolean isAvailablePath(final String urlPath) + { + boolean result; + + if (this.cache.containsKey(urlPath)) + { + result = true; + } + else + { + String className = "website." + translateToClassName(urlPath); + if (isAvailableClass(className) || isAvailableClass(className.replaceAll("Xhtml$", "Page"))) + { + result = true; + } + else + { + result = false; + } + } + + // + return result; + } + /** * Instance. * diff --git a/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java index 0977fa6..f6f415f 100644 --- a/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java +++ b/src/fr/devinsy/kiss4web/dispatcher/hooks/ShortURLHook.java @@ -56,7 +56,14 @@ public class ShortURLHook extends HookCore String urlPath = request.getPathInfo(); - result = ShortURLRewriter.matches(urlPath); + if ((ShortURLRewriter.matches(urlPath)) && (!KissDispatcherFactory.instance().isAvailablePath(urlPath))) + { + result = true; + } + else + { + result = false; + } // return result; @@ -77,7 +84,5 @@ public class ShortURLHook extends HookCore logger.info("rewritedURLPath={}", rewritedURLPath); KissDispatcherFactory.instance().dispatchPathToServlet(servletConfig, request, response, rewritedURLPath); - // KissDispatcherFactory.instance().dispatchPathToServlet(servletConfig, - // request, response, urlPath, rewritedURLPath); } }