Author: rgielen
Date: Thu Nov  5 23:46:50 2009
New Revision: 833239

URL: http://svn.apache.org/viewvc?rev=833239&view=rev
Log:
WW-3316:
- remove unconditional LOG.debug calls
- import fixes
- drop pre Java 5 constructs

Modified:
    
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
    
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java
    
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
    
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
    
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
    
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
 Thu Nov  5 23:46:50 2009
@@ -188,7 +188,7 @@
      */
     public void init(PortletConfig cfg) throws PortletException {
         super.init(cfg);
-        LOG.debug("Initializing portlet " + getPortletName());
+        if (LOG.isDebugEnabled()) LOG.debug("Initializing portlet " + 
getPortletName());
         
         Map<String,String> params = new HashMap<String,String>();
         for (Enumeration e = cfg.getInitParameterNames(); e.hasMoreElements(); 
) {
@@ -205,7 +205,7 @@
             factory = 
dispatcherUtils.getConfigurationManager().getConfiguration().getContainer().getInstance(ActionProxyFactory.class);
         }
         portletNamespace = cfg.getInitParameter("portletNamespace");
-        LOG.debug("PortletNamespace: " + portletNamespace);
+        if (LOG.isDebugEnabled()) LOG.debug("PortletNamespace: " + 
portletNamespace);
         parseModeConfig(actionMap, cfg, PortletMode.VIEW, "viewNamespace",
                 "defaultViewAction");
         parseModeConfig(actionMap, cfg, PortletMode.EDIT, "editNamespace",
@@ -292,13 +292,13 @@
      */
     public void processAction(ActionRequest request, ActionResponse response)
             throws PortletException, IOException {
-        LOG.debug("Entering processAction");
+        if (LOG.isDebugEnabled()) LOG.debug("Entering processAction");
         resetActionContext();
         try {
             serviceAction(request, response, getRequestMap(request), 
getParameterMap(request),
                     getSessionMap(request), getApplicationMap(),
                     portletNamespace, EVENT_PHASE);
-            LOG.debug("Leaving processAction");
+            if (LOG.isDebugEnabled()) LOG.debug("Leaving processAction");
         } finally {
             ActionContext.setContext(null);
         }
@@ -313,7 +313,7 @@
     public void render(RenderRequest request, RenderResponse response)
             throws PortletException, IOException {
 
-        LOG.debug("Entering render");
+        if (LOG.isDebugEnabled()) LOG.debug("Entering render");
         resetActionContext();
         response.setTitle(getTitle(request));
         if(!request.getWindowState().equals(WindowState.MINIMIZED)) {
@@ -322,7 +322,7 @@
             serviceAction(request, response, getRequestMap(request), 
getParameterMap(request),
                     getSessionMap(request), getApplicationMap(),
                     portletNamespace, RENDER_PHASE);
-            LOG.debug("Leaving render");
+            if (LOG.isDebugEnabled()) LOG.debug("Leaving render");
         } finally {
             resetActionContext();
         }
@@ -418,7 +418,7 @@
     public void serviceAction(PortletRequest request, PortletResponse 
response, Map<String, Object> requestMap, Map<String, String[]> parameterMap,
             Map<String, Object> sessionMap, Map<String, Object> 
applicationMap, String portletNamespace,
             Integer phase) throws PortletException {
-        LOG.debug("serviceAction");
+        if (LOG.isDebugEnabled()) LOG.debug("serviceAction");
         Dispatcher.setInstance(dispatcherUtils);
         String actionName = null;
         String namespace = null;

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptor.java
 Thu Nov  5 23:46:50 2009
@@ -73,7 +73,7 @@
                RenderRequest request = (RenderRequest) 
invocation.getInvocationContext().get(REQUEST);
                if (StringUtils.isNotEmpty(request.getParameter(EVENT_ACTION))) 
{
                        if(!isProperPrg(invocation)) {
-                               LOG.debug("Restoring value stack from event 
phase");
+                               if (LOG.isDebugEnabled()) LOG.debug("Restoring 
value stack from event phase");
                                ValueStack oldStack = (ValueStack) 
invocation.getInvocationContext().getSession().get(
                                STACK_FROM_EVENT_PHASE);
                                if (oldStack != null) {
@@ -81,11 +81,11 @@
                                        ValueStack currentStack = 
invocation.getStack();
                                        CompoundRoot root = 
currentStack.getRoot();
                                        root.addAll(0, oldRoot);
-                                       LOG.debug("Restored stack");
+                                       if (LOG.isDebugEnabled()) 
LOG.debug("Restored stack");
                                }
                        }
                        else {
-                               LOG.debug("Won't restore stack from event phase 
since it's a proper PRG request");
+                               if (LOG.isDebugEnabled()) LOG.debug("Won't 
restore stack from event phase since it's a proper PRG request");
                        }
                }
        }

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
 Thu Nov  5 23:46:50 2009
@@ -264,6 +264,6 @@
 
     public void handle(ReflectionException ex) {
         // Only log as debug as they are probably parameters to be appended to 
the url
-        LOG.debug(ex.getMessage(), ex);
+        if (LOG.isDebugEnabled()) LOG.debug(ex.getMessage(), ex);
     }
 }

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletResult.java
 Thu Nov  5 23:46:50 2009
@@ -126,10 +126,10 @@
         * @param invocation
         */
        protected void executeActionResult(String finalLocation, 
ActionInvocation invocation) throws Exception {
-               LOG.debug("Executing result in Event phase");
+               if (LOG.isDebugEnabled()) LOG.debug("Executing result in Event 
phase");
                ActionResponse res = PortletActionContext.getActionResponse();
                Map sessionMap = invocation.getInvocationContext().getSession();
-               LOG.debug("Setting event render parameter: " + finalLocation);
+               if (LOG.isDebugEnabled()) LOG.debug("Setting event render 
parameter: " + finalLocation);
                if (finalLocation.indexOf('?') != -1) {
                        convertQueryParamsToRenderParams(res, 
finalLocation.substring(finalLocation.indexOf('?') + 1));
                        finalLocation = finalLocation.substring(0, 
finalLocation.indexOf('?'));
@@ -182,7 +182,7 @@
         * @throws IOException
         */
        protected void executeRenderResult(final String finalLocation) throws 
PortletException, IOException {
-               LOG.debug("Executing result in Render phase");
+               if (LOG.isDebugEnabled()) LOG.debug("Executing result in Render 
phase");
                PortletContext ctx = PortletActionContext.getPortletContext();
                RenderRequest req = PortletActionContext.getRenderRequest();
                RenderResponse res = PortletActionContext.getRenderResponse();
@@ -190,7 +190,7 @@
                if (StringUtils.isNotEmpty(title)) {
                        res.setTitle(title);
                }
-               LOG.debug("Location: " + finalLocation);
+               if (LOG.isDebugEnabled()) LOG.debug("Location: " + 
finalLocation);
                if (useDispatcherServlet) {
                        req.setAttribute(DISPATCH_TO, finalLocation);
                        PortletRequestDispatcher dispatcher = 
ctx.getNamedDispatcher(dispatcherServletName);

Modified: 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/main/java/org/apache/struts2/portlet/util/PortletUrlHelper.java
 Thu Nov  5 23:46:50 2009
@@ -21,6 +21,14 @@
 
 package org.apache.struts2.portlet.util;
 
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.commons.lang.xwork.StringUtils;
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.portlet.PortletActionConstants;
+import org.apache.struts2.portlet.context.PortletActionContext;
+
+import javax.portlet.*;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.Iterator;
@@ -28,22 +36,6 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import javax.portlet.PortletMode;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.PortletURL;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-
-import org.apache.commons.collections.iterators.EntrySetMapIterator;
-import org.apache.commons.lang.xwork.StringUtils;
-import org.apache.struts2.StrutsException;
-import org.apache.struts2.portlet.PortletActionConstants;
-import org.apache.struts2.portlet.context.PortletActionContext;
-
-import com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
-
 /**
  * Helper class for creating Portlet URLs. Portlet URLs are fundamentally 
different from regular
  * servlet URLs since they never target the application itself; all requests 
go through the portlet
@@ -116,15 +108,15 @@
         if(StringUtils.isNotEmpty(method)) {
                resultingAction.append("!").append(method);
         }
-        LOG.debug("Resulting actionPath: " + resultingAction);
+        if (LOG.isDebugEnabled()) LOG.debug("Resulting actionPath: " + 
resultingAction);
         params.put(PortletActionConstants.ACTION_PARAM, new String[] { 
resultingAction.toString() });
 
         PortletURL url = null;
         if ("action".equalsIgnoreCase(type)) {
-            LOG.debug("Creating action url");
+            if (LOG.isDebugEnabled()) LOG.debug("Creating action url");
             url = response.createActionURL();
         } else {
-            LOG.debug("Creating render url");
+            if (LOG.isDebugEnabled()) LOG.debug("Creating render url");
             url = response.createRenderURL();
         }
 
@@ -170,7 +162,7 @@
         }
         String portletNamespace = PortletActionContext.getPortletNamespace();
         String modeNamespace = 
(String)PortletActionContext.getModeNamespaceMap().get(mode);
-        LOG.debug("PortletNamespace: " + portletNamespace + ", modeNamespace: 
" + modeNamespace);
+        if (LOG.isDebugEnabled()) LOG.debug("PortletNamespace: " + 
portletNamespace + ", modeNamespace: " + modeNamespace);
         if(StringUtils.isNotEmpty(portletNamespace)) {
             sb.append(portletNamespace);
         }
@@ -186,7 +178,7 @@
             }
             sb.append(namespace);
         }
-        LOG.debug("Resulting namespace: " + sb);
+        if (LOG.isDebugEnabled()) LOG.debug("Resulting namespace: " + sb);
         return sb.toString();
     }
 
@@ -257,13 +249,12 @@
      * @param portletReq The RenderRequest.
      * @param windowState The WindowState as a String.
      * @return The WindowState that mathces the <tt>windowState</tt> String, 
or if
-     * the Sring is blank, the current WindowState.
+     * the String is blank, the current WindowState.
      */
     private static WindowState getWindowState(RenderRequest portletReq,
             String windowState) {
         WindowState state = portletReq.getWindowState();
         if (StringUtils.isNotEmpty(windowState)) {
-            state = portletReq.getWindowState();
             if ("maximized".equalsIgnoreCase(windowState)) {
                 state = WindowState.MAXIMIZED;
             } else if ("normal".equalsIgnoreCase(windowState)) {
@@ -284,14 +275,13 @@
      * @param portletReq The RenderRequest.
      * @param portletMode The PortletMode as a String.
      * @return The PortletMode that mathces the <tt>portletMode</tt> String, 
or if
-     * the Sring is blank, the current PortletMode.
+     * the String is blank, the current PortletMode.
      */
     private static PortletMode getPortletMode(RenderRequest portletReq,
             String portletMode) {
         PortletMode mode = portletReq.getPortletMode();
 
         if (StringUtils.isNotEmpty(portletMode)) {
-            mode = portletReq.getPortletMode();
             if ("edit".equalsIgnoreCase(portletMode)) {
                 mode = PortletMode.EDIT;
             } else if ("view".equalsIgnoreCase(portletMode)) {

Modified: 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java?rev=833239&r1=833238&r2=833239&view=diff
==============================================================================
--- 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/portlet/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
 Thu Nov  5 23:46:50 2009
@@ -21,24 +21,11 @@
 
 package org.apache.struts2.portlet.dispatcher;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletSession;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.portlet.PortletActionConstants;
@@ -46,17 +33,11 @@
 import org.jmock.Mock;
 import org.jmock.cglib.MockObjectTestCase;
 import org.jmock.core.Constraint;
-import org.springframework.mock.web.portlet.MockActionRequest;
-import org.springframework.mock.web.portlet.MockActionResponse;
 import org.springframework.mock.web.portlet.MockPortletConfig;
 import org.springframework.mock.web.portlet.MockPortletContext;
 
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.ActionProxy;
-import com.opensymphony.xwork2.ActionProxyFactory;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.portlet.*;
+import java.util.*;
 
 /**
  * Jsr168DispatcherTest. Insert description.
@@ -164,14 +145,14 @@
                requestParams.put(EVENT_ACTION, new String[] { "true" });
                requestParams.put(PortletActionConstants.MODE_PARAM, new 
String[] { mode.toString() });
 
-               Map sessionMap = new HashMap();
+               Map<String, Object> sessionMap = new HashMap<String, Object>();
 
                Map<String, String> initParams = new HashMap<String, String>();
                initParams.put("viewNamespace", "/view");
                
initParams.put(StrutsConstants.STRUTS_ALWAYS_SELECT_FULL_NAMESPACE, "true");
 
                initPortletConfig(initParams, new HashMap<String, Object>());
-               initRequest(requestParams, new HashMap(), sessionMap, new 
HashMap(), PortletMode.VIEW, WindowState.NORMAL,
+               initRequest(requestParams, new HashMap<String, Object>(), 
sessionMap, new HashMap<String, String[]>(), PortletMode.VIEW, 
WindowState.NORMAL,
                                false, null);
                setupActionFactory("/view", "testAction", "success", 
EasyMock.createNiceMock(ValueStack.class));
 
@@ -258,12 +239,10 @@
 
        private void setupParamStub(Map<String, String[]> requestParams, Mock 
mockRequest, String method) {
                Map<String, String> newMap = new HashMap<String, String>();
-               Iterator<String> it = requestParams.keySet().iterator();
-               while (it.hasNext()) {
-                       String key = it.next();
-                       String[] val = (String[]) requestParams.get(key);
-                       newMap.put(key, val[0]);
-               }
+        for ( String key : requestParams.keySet() ) {
+            String[] val = requestParams.get(key);
+            newMap.put(key, val[0]);
+        }
                setupStub(newMap, mockRequest, method);
 
        }
@@ -282,12 +261,10 @@
         *            The name of the method to stub.
         */
        private void setupStub(Map map, Mock mock, String method) {
-               Iterator it = map.keySet().iterator();
-               while (it.hasNext()) {
-                       Object key = it.next();
-                       Object val = map.get(key);
-                       
mock.stubs().method(method).with(eq(key)).will(returnValue(val));
-               }
+        for ( Object key : map.keySet() ) {
+            Object val = map.get(key);
+            mock.stubs().method(method).with(eq(key)).will(returnValue(val));
+        }
        }
 
        public void testModeChangeUsingPortletWidgets() throws Exception {


Reply via email to