Improve logging.
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 20 May 2015 13:21:05 +0000 (13:21 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 20 May 2015 13:21:05 +0000 (13:21 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8121 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java
org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java
org.argeo.cms/src/org/argeo/cms/util/SimpleErgonomics.java

index 02e08f2af94c32d6561b94f0945a61513b1600ae..00db13443b0cb44d6845f288471c4d53014e45eb 100644 (file)
@@ -67,8 +67,8 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint
                        new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_USER, subject)
                                        .login();
                } catch (LoginException e) {
-                       if (log.isTraceEnabled())
-                               log.trace("Cannot authenticate user", e);
+                       // if (log.isTraceEnabled())
+                       // log.trace("Cannot authenticate user", e);
                        try {
                                new ArgeoLoginContext(KernelHeader.LOGIN_CONTEXT_ANONYMOUS,
                                                subject).login();
index 9d0bac5dc79dbe95c35b2ff3a4b4a343a6e64f20..7739670f177b0ec1c57f40d701e6b135e853da09 100644 (file)
@@ -76,8 +76,7 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                try {
                        httpService.registerFilter("/", rootFilter, null, null);
                } catch (Exception e) {
-                       throw new CmsException(
-                                       "Could not register root filter", e);
+                       throw new CmsException("Could not register root filter", e);
                }
        }
 
@@ -136,11 +135,11 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                httpService.registerServlet(path, (Servlet) remotingServlet, ip, null);
        }
 
-//     private Boolean isSessionAuthenticated(HttpSession httpSession) {
-//             SecurityContext contextFromSession = (SecurityContext) httpSession
-//                             .getAttribute(SPRING_SECURITY_CONTEXT_KEY);
-//             return contextFromSession != null;
-//     }
+       // private Boolean isSessionAuthenticated(HttpSession httpSession) {
+       // SecurityContext contextFromSession = (SecurityContext) httpSession
+       // .getAttribute(SPRING_SECURITY_CONTEXT_KEY);
+       // return contextFromSession != null;
+       // }
 
        private void requestBasicAuth(HttpSession httpSession,
                        HttpServletResponse response) {
@@ -189,8 +188,12 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                public void doFilter(HttpSession httpSession,
                                HttpServletRequest request, HttpServletResponse response,
                                FilterChain filterChain) throws IOException, ServletException {
-                       if (log.isTraceEnabled())
-                               logRequest(request);
+                       if (log.isTraceEnabled()) {
+                               log.trace(request.getRequestURL().append(
+                                               request.getQueryString() != null ? "?"
+                                                               + request.getQueryString() : ""));
+                               // logRequest(request);
+                       }
 
                        String servletPath = request.getServletPath();
 
@@ -220,7 +223,7 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                        int pathLength = path.length();
                        if (pathLength != 0 && (path.charAt(0) == '/')
                                        && !servletPath.endsWith("rwt-resources")
-                                       && path.lastIndexOf('/')!=0) {
+                                       && path.lastIndexOf('/') != 0) {
                                String newLocation = request.getServletPath() + "#" + path;
                                response.setHeader("Location", newLocation);
                                response.setStatus(HttpServletResponse.SC_FOUND);
@@ -276,10 +279,10 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                                FilterChain filterChain) throws IOException, ServletException {
 
                        // Authenticate from session
-//                     if (isSessionAuthenticated(httpSession)) {
-//                             filterChain.doFilter(request, response);
-//                             return;
-//                     }
+                       // if (isSessionAuthenticated(httpSession)) {
+                       // filterChain.doFilter(request, response);
+                       // return;
+                       // }
 
                        KernelUtils.anonymousLogin(authenticationManager);
                        filterChain.doFilter(request, response);
@@ -306,9 +309,9 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants {
                                UsernamePasswordAuthenticationToken token = basicAuth(basicAuth);
                                Authentication auth = authenticationManager.authenticate(token);
                                SecurityContextHolder.getContext().setAuthentication(auth);
-//                             httpSession.setAttribute(SPRING_SECURITY_CONTEXT_KEY,
-//                                             SecurityContextHolder.getContext());
-//                             httpSession.setAttribute(ATTR_AUTH, Boolean.FALSE);
+                               // httpSession.setAttribute(SPRING_SECURITY_CONTEXT_KEY,
+                               // SecurityContextHolder.getContext());
+                               // httpSession.setAttribute(ATTR_AUTH, Boolean.FALSE);
                                filterChain.doFilter(request, response);
                                return;
                        }
index 4b871cbcf0b8f8429f35076c2919fed7395335bc..7835b7efa65985a833514627cc94b0f4e4d02b62 100644 (file)
@@ -5,6 +5,8 @@ import java.util.Map;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.cms.AbstractCmsEntryPoint;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.CmsImageManager;
@@ -20,6 +22,8 @@ import org.eclipse.swt.widgets.Control;
 
 /** Simple header/body ergonomics. */
 public class SimpleErgonomics extends AbstractCmsEntryPoint {
+       private final static Log log = LogFactory.getLog(SimpleErgonomics.class);
+
        private Composite headerArea;
        private Composite bodyArea;
        private final CmsUiProvider uiProvider;
@@ -59,6 +63,8 @@ public class SimpleErgonomics extends AbstractCmsEntryPoint {
        protected void refresh() {
                refreshHeader();
                refreshBody();
+               if (log.isTraceEnabled())
+                       log.trace("UI refreshed " + getNode());
        }
 
        protected void refreshHeader() {