Commit cfd309b6 authored by Matija Obreza's avatar Matija Obreza

Logging reduced

- LocaleWrappedServletResponse
- LocaleURLFilter
parent 54a2b807
......@@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
*/
package org.genesys2.server.servlet.filter;
......@@ -34,6 +34,9 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Handles the very important locale selection by URL
*/
public class LocaleURLFilter implements Filter {
private static final Logger LOG = LoggerFactory.getLogger(LocaleURLFilter.class);
......@@ -75,14 +78,11 @@ public class LocaleURLFilter implements Filter {
@Override
public void destroy() {
if (LOG.isDebugEnabled()) {
LOG.debug("Destroying LocaleURLFilter");
}
LOG.info("Destroying LocaleURLFilter");
}
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain)
throws IOException, ServletException {
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
final HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
final String url = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length());
......@@ -92,9 +92,7 @@ public class LocaleURLFilter implements Filter {
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Incoming URL: {}", url);
}
LOG.trace("Incoming URL: {}", url);
final Matcher matcher = localeUrlMatcher.matcher(url);
if (matcher.matches()) {
......@@ -132,33 +130,29 @@ public class LocaleURLFilter implements Filter {
httpRequest.setAttribute(REQUEST_LOCALE_ATTR, urlLocale);
httpRequest.setAttribute(REQUEST_INTERNAL_URL, getInternalUrl(remainingUrl, httpRequest.getQueryString()));
if (LOG.isDebugEnabled()) {
LOG.debug("URL matches! lang={} remaining={}", urlLanguage, remainingUrl);
LOG.debug("Country: {} Lang: {} locale={}", urlLocale.getCountry(), urlLocale.getLanguage(), urlLocale);
if (LOG.isTraceEnabled()) {
LOG.trace("URL matches! lang={} remaining={}", urlLanguage, remainingUrl);
LOG.trace("Country: {} Lang: {} locale={}", urlLocale.getCountry(), urlLocale.getLanguage(), urlLocale);
final Enumeration<String> attrNames = httpRequest.getAttributeNames();
while (attrNames.hasMoreElements()) {
final String attrName = attrNames.nextElement();
LOG.debug("Request attr {} = {}", attrName, httpRequest.getAttribute(attrName));
LOG.trace("Request attr {} = {}", attrName, httpRequest.getAttribute(attrName));
}
LOG.debug("Proxying request to remaining URL {}", remainingUrl);
LOG.trace("Proxying request to remaining URL {}", remainingUrl);
}
final LocaleWrappedServletResponse localeResponse = new LocaleWrappedServletResponse(httpResponse, localeUrlMatcher, urlLanguage,
defaultLocale.toLanguageTag());
final LocaleWrappedServletResponse localeResponse = new LocaleWrappedServletResponse(httpResponse, localeUrlMatcher, urlLanguage, defaultLocale.toLanguageTag());
final LocaleWrappedServletRequest localeRequest = new LocaleWrappedServletRequest(httpRequest, url, remainingUrl);
// request.getRequestDispatcher(remainingUrl == null ? "/" :
// remainingUrl).forward(servletRequest, localeResponse);
filterChain.doFilter(localeRequest, localeResponse);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("No match on url {}", url);
}
LOG.trace("No match on url {}", url);
httpRequest.setAttribute(REQUEST_INTERNAL_URL, getInternalUrl(url, httpRequest.getQueryString()));
final LocaleWrappedServletResponse localeResponse = new LocaleWrappedServletResponse(httpResponse, localeUrlMatcher, null,
defaultLocale.toLanguageTag());
final LocaleWrappedServletResponse localeResponse = new LocaleWrappedServletResponse(httpResponse, localeUrlMatcher, null, defaultLocale.toLanguageTag());
filterChain.doFilter(servletRequest, localeResponse);
}
}
......
......@@ -51,9 +51,7 @@ public class LocaleWrappedServletResponse extends HttpServletResponseWrapper {
return super.encodeURL(url);
} else {
String encodedURL = prefix + super.encodeURL(url);
if (LOG.isDebugEnabled()) {
LOG.debug("encodeURL {} to {}", url, encodedURL);
}
LOG.trace("encodeURL {} to {}", url, encodedURL);
return encodedURL;
}
}
......@@ -65,9 +63,7 @@ public class LocaleWrappedServletResponse extends HttpServletResponseWrapper {
return super.encodeUrl(url);
} else {
String encodedURL = prefix + super.encodeUrl(url);
if (LOG.isDebugEnabled()) {
LOG.debug("encodeUrl {} to {}", url, encodedURL);
}
LOG.trace("encodeUrl {} to {}", url, encodedURL);
return encodedURL;
}
}
......@@ -78,9 +74,7 @@ public class LocaleWrappedServletResponse extends HttpServletResponseWrapper {
return super.encodeRedirectURL(url);
} else {
String encodedURL = prefix + super.encodeRedirectURL(url);
if (LOG.isDebugEnabled()) {
LOG.debug("encodeRedirectURL {} to {}", url, encodedURL);
}
LOG.trace("encodeRedirectURL {} to {}", url, encodedURL);
return encodedURL;
}
}
......@@ -92,9 +86,7 @@ public class LocaleWrappedServletResponse extends HttpServletResponseWrapper {
return super.encodeRedirectUrl(url);
} else {
String encodedURL = prefix + super.encodeRedirectUrl(url);
if (LOG.isDebugEnabled()) {
LOG.debug("encodeRedirectUrl {} to {}", url, encodedURL);
}
LOG.trace("encodeRedirectUrl {} to {}", url, encodedURL);
return encodedURL;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment