@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (PortalUtil.isMultipartRequest(request)) { UploadServletRequest uploadServletRequest = new UploadServletRequestImpl(request); request = uploadServletRequest; } String path = GetterUtil.getString(request.getPathInfo()); if ((!path.equals(StringPool.BLANK) && !path.equals(StringPool.SLASH)) || (request.getParameter("discover") != null)) { Locale locale = PortalUtil.getLocale(request, response, true); LocaleThreadLocal.setThemeDisplayLocale(locale); super.service(request, response); return; } if (_log.isDebugEnabled()) { _log.debug("Servlet context " + request.getContextPath()); } String apiPath = PortalUtil.getPathMain() + "/portal/api/jsonws"; HttpSession session = request.getSession(); ServletContext servletContext = session.getServletContext(); boolean remoteAccess = AccessControlThreadLocal.isRemoteAccess(); try { AccessControlThreadLocal.setRemoteAccess(true); String contextPath = PortalContextLoaderListener.getPortalServletContextPath(); if (servletContext.getContext(contextPath) != null) { if (!contextPath.equals(StringPool.SLASH) && apiPath.startsWith(contextPath)) { apiPath = apiPath.substring(contextPath.length()); } RequestDispatcher requestDispatcher = request.getRequestDispatcher(apiPath); requestDispatcher.forward(request, response); } else { String servletContextPath = ContextPathUtil.getContextPath(servletContext); String redirectPath = "/api/jsonws?contextPath=" + HttpUtil.encodeURL(servletContextPath); response.sendRedirect(redirectPath); } } finally { AccessControlThreadLocal.setRemoteAccess(remoteAccess); } }
@Override public void destroy() { _jsonWebServiceServiceAction.destroy(); super.destroy(); }