You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2020/04/28 06:19:30 UTC

[struts] branch action-context-boost updated (6c76275 -> 0cf39a9)

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch action-context-boost
in repository https://gitbox.apache.org/repos/asf/struts.git.


 discard 6c76275  WW-4789 WW-3788 Cleans up code & JavaDocs formatting
     new 0cf39a9  WW-4789 WW-3788 Cleans up code & JavaDocs formatting

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (6c76275)
            \
             N -- N -- N   refs/heads/action-context-boost (0cf39a9)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/struts2/views/jsp/ActionTagTest.java    | 21 +++++++------
 .../struts2/rest/RestWorkflowInterceptor.java      | 36 ++++++----------------
 2 files changed, 21 insertions(+), 36 deletions(-)


[struts] 01/01: WW-4789 WW-3788 Cleans up code & JavaDocs formatting

Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch action-context-boost
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 0cf39a97f0e965aa896de6cb59d92824f32097a8
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Tue Apr 28 08:14:45 2020 +0200

    WW-4789 WW-3788 Cleans up code & JavaDocs formatting
---
 .../org/apache/struts2/result/PlainTextResult.java | 17 +---------
 .../struts2/result/ServletRedirectResult.java      | 20 ++----------
 .../org/apache/struts2/result/StreamResult.java    | 28 +++++------------
 .../org/apache/struts2/views/util/ContextUtil.java | 35 ++++++++++-----------
 .../apache/struts2/views/jsp/ActionTagTest.java    | 21 +++++++------
 .../struts2/rest/RestWorkflowInterceptor.java      | 36 ++++++----------------
 6 files changed, 48 insertions(+), 109 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/result/PlainTextResult.java b/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
index c264817..7baaa05 100644
--- a/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
+++ b/core/src/main/java/org/apache/struts2/result/PlainTextResult.java
@@ -31,15 +31,8 @@ import java.io.PrintWriter;
 import java.nio.charset.Charset;
 
 /**
- * <!-- START SNIPPET: description -->
- * <p>
  * A result that send the content out as plain text. Useful typically when needed
  * to display the raw content of a JSP or Html file for example.
- * <p>
- * <!-- END SNIPPET: description -->
- * <p>
- * <p>
- * <!-- START SNIPPET: params -->
  *
  * <ul>
  *  <li>location (default) = location of the file (jsp/html) to be displayed as plain text.</li>
@@ -47,26 +40,18 @@ import java.nio.charset.Charset;
  *  response type (eg. Content-Type=text/plain; charset=UTF-8) and when reading
  *  using a Reader. Some example of charSet would be UTF-8, ISO-8859-1 etc.
  * </ul>
- * <p>
- * <!-- END SNIPPET: params -->
- *
- *
- * <pre>
- * <!-- START SNIPPET: example -->
  *
+ *  <pre>
  * &lt;action name="displayJspRawContent" &gt;
  *   &lt;result type="plainText"&gt;/myJspFile.jsp&lt;/result&gt;
  * &lt;/action&gt;
  *
- *
  * &lt;action name="displayJspRawContent" &gt;
  *   &lt;result type="plainText"&gt;
  *      &lt;param name="location"&gt;/myJspFile.jsp&lt;/param&gt;
  *      &lt;param name="charSet"&gt;UTF-8&lt;/param&gt;
  *   &lt;/result&gt;
  * &lt;/action&gt;
- *
- * <!-- END SNIPPET: example -->
  * </pre>
  */
 public class PlainTextResult extends StrutsResultSupport {
diff --git a/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
index 0973492..9d7b461 100644
--- a/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/result/ServletRedirectResult.java
@@ -46,8 +46,6 @@ import java.util.Map;
 import static javax.servlet.http.HttpServletResponse.SC_FOUND;
 
 /**
- * <!-- START SNIPPET: description -->
- * <p>
  * Calls the {@link HttpServletResponse#sendRedirect(String) sendRedirect}
  * method to the location specified. The response is told to redirect the
  * browser to the specified location (a new request from the client). The
@@ -56,33 +54,19 @@ import static javax.servlet.http.HttpServletResponse.SC_FOUND;
  * available. This is because actions are built on a single-thread model. The
  * only way to pass data is through the session or with web parameters
  * (url?name=value) which can be OGNL expressions.
- * </p>
- * <!-- END SNIPPET: description -->
- * <p>
+ *
  * <b>This result type takes the following parameters:</b>
- * </p>
- * <!-- START SNIPPET: params -->
  *
  * <ul>
- *
  * <li><b>location (default)</b> - the location to go to after execution.</li>
- *
  * <li><b>parse</b> - true by default. If set to false, the location param will
  * not be parsed for Ognl expressions.</li>
- *
  * <li><b>anchor</b> - Optional.  Also known as "fragment" or colloquially as
  * "hash".  You can specify an anchor for a result.</li>
  * </ul>
- *
- * <p>
  * This result follows the same rules from {@link StrutsResultSupport}.
- * </p>
- * <p>
- * <!-- END SNIPPET: params -->
- * <p>
- * <b>Example:</b>
- * </p>
  *
+ * <b>Example:</b>
  * <pre>
  * <!-- START SNIPPET: example -->
  * &lt;!--
diff --git a/core/src/main/java/org/apache/struts2/result/StreamResult.java b/core/src/main/java/org/apache/struts2/result/StreamResult.java
index 47dbc45..711929f 100644
--- a/core/src/main/java/org/apache/struts2/result/StreamResult.java
+++ b/core/src/main/java/org/apache/struts2/result/StreamResult.java
@@ -27,60 +27,46 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 /**
- * <!-- START SNIPPET: description -->
- * <p>
  * A custom Result type for sending raw data (via an InputStream) directly to the
  * HttpServletResponse. Very useful for allowing users to download content.
- * </p>
- * <!-- END SNIPPET: description -->
- * <p>
+ *
  * <b>This result type takes the following parameters:</b>
- * </p>
- * <!-- START SNIPPET: params -->
  *
  * <ul>
- *
  * <li><b>contentType</b> - the stream mime-type as sent to the web browser
  * (default = <code>text/plain</code>).</li>
- *
  * <li><b>contentLength</b> - the stream length in bytes (the browser displays a
  * progress bar).</li>
- *
  * <li><b>contentDisposition</b> - the content disposition header value for
  * specifing the file name (default = <code>inline</code>, values are typically
  * <i>attachment;filename="document.pdf"</i>.</li>
- *
  * <li><b>inputName</b> - the name of the InputStream property from the chained
  * action (default = <code>inputStream</code>).</li>
- *
  * <li><b>bufferSize</b> - the size of the buffer to copy from input to output
  * (default = <code>1024</code>).</li>
- *
  * <li><b>allowCaching</b> if set to 'false' it will set the headers 'Pragma' and 'Cache-Control'
  * to 'no-cahce', and prevent client from caching the content. (default = <code>true</code>)
- *
  * <li><b>contentCharSet</b> if set to a string, ';charset=value' will be added to the
  * content-type header, where value is the string set. If set to an expression, the result
  * of evaluating the expression will be used. If not set, then no charset will be set on
  * the header</li>
  * </ul>
  *
- * <p>These parameters can also be set by exposing a similarly named getter method on your Action.  For example, you can
- * provide <code>getContentType()</code> to override that parameter for the current action.</p>
  * <p>
- * <!-- END SNIPPET: params -->
- * <p>
- * <b>Example:</b>
+ * These parameters can also be set by exposing a similarly named getter method on your Action.  For example, you can
+ * provide <code>getContentType()</code> to override that parameter for the current action.
  * </p>
  *
- * <pre><!-- START SNIPPET: example -->
+ * <b>Example:</b>
+ *
+ * <pre>
  * &lt;result name="success" type="stream"&gt;
  *   &lt;param name="contentType"&gt;image/jpeg&lt;/param&gt;
  *   &lt;param name="inputName"&gt;imageStream&lt;/param&gt;
  *   &lt;param name="contentDisposition"&gt;attachment;filename="document.pdf"&lt;/param&gt;
  *   &lt;param name="bufferSize"&gt;1024&lt;/param&gt;
  * &lt;/result&gt;
- * <!-- END SNIPPET: example --></pre>
+ * </pre>
  */
 public class StreamResult extends StrutsResultSupport {
 
diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
index d213f5a..7cc1aab 100644
--- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
+++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
@@ -18,26 +18,20 @@
  */
 package org.apache.struts2.views.util;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.util.StrutsUtil;
 import org.apache.struts2.views.jsp.ui.OgnlTool;
 
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ValueStack;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Value Stack's Context related Utilities.
- *
  */
 public class ContextUtil {
     public static final String REQUEST = "request";
@@ -48,7 +42,7 @@ public class ContextUtil {
     public static final String OGNL = "ognl";
     public static final String STRUTS = "struts";
     public static final String ACTION = "action";
-    
+
     public static Map<String, Object> getStandardContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
         HashMap<String, Object> map = new HashMap<>();
         map.put(REQUEST, req);
@@ -68,6 +62,7 @@ public class ContextUtil {
 
     /**
      * Return true if either Configuration's altSyntax is on or the stack context's useAltSyntax is on
+     *
      * @param context stack's context
      * @return boolean
      */
@@ -76,18 +71,22 @@ public class ContextUtil {
         // plus the Configuration implementation should cache the properties, which the framework's
         // configuration implementation does
         String tagAltSytnax = ActionContext.of(context).getContainer().getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX);
-        return "true".equals(tagAltSytnax) ||(
-                (context.containsKey("useAltSyntax") &&
-                        context.get("useAltSyntax") != null &&
-                        "true".equals(context.get("useAltSyntax").toString())));
+
+        return "true".equals(tagAltSytnax) || (
+            (context.containsKey("useAltSyntax") &&
+                context.get("useAltSyntax") != null &&
+                "true".equals(context.get("useAltSyntax").toString()))
+        );
     }
 
     /**
      * Returns a String for overriding the default templateSuffix if templateSuffix is on the stack
+     *
      * @param context stack's context
      * @return String
      */
     public static String getTemplateSuffix(Map<String, Object> context) {
         return context.containsKey("templateSuffix") ? (String) context.get("templateSuffix") : null;
     }
+
 }
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
index 74765bf..8956390 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/ActionTagTest.java
@@ -39,7 +39,6 @@ import javax.servlet.jsp.PageContext;
 import java.util.HashMap;
 import java.util.Map;
 
-
 /**
  * Unit test for {@link ActionTag}.
  */
@@ -156,7 +155,7 @@ public class ActionTagTest extends AbstractTagTest {
         TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
 
         assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
-        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
         assertTrue(result.isExecuted());
     }
 
@@ -177,11 +176,11 @@ public class ActionTagTest extends AbstractTagTest {
         TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
 
         assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
-        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
         assertNull(result); // result is never executed, hence never set into invocation
     }
 
-     public void testExecuteButResetReturnSameInvocation() throws Exception {
+    public void testExecuteButResetReturnSameInvocation() throws Exception {
         Mock mockActionInv = new Mock(ActionInvocation.class);
         ActionTag tag = new ActionTag();
         tag.setPageContext(pageContext);
@@ -199,7 +198,7 @@ public class ActionTagTest extends AbstractTagTest {
         ActionComponent component = (ActionComponent) tag.getComponent();
 
         tag.doEndTag();
-         assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
+        assertSame(oldInvocation, ActionContext.getContext().getActionInvocation());
     }
 
     public void testIngoreContextParamsFalse() throws Exception {
@@ -236,7 +235,7 @@ public class ActionTagTest extends AbstractTagTest {
         tag.setIgnoreContextParams(true);
 
         Map<String, String[]> params = new HashMap<>();
-        params.put("user", new String[] { "Santa Claus" });
+        params.put("user", new String[]{"Santa Claus"});
         ActionContext.getContext().setParameters(HttpParameters.create(params).build());
 
         tag.doStartTag();
@@ -264,7 +263,7 @@ public class ActionTagTest extends AbstractTagTest {
             tag.doEndTag();
             fail("Should have thrown RuntimeException");
         } catch (StrutsException e) {
-             assertEquals("tag 'actioncomponent', field 'name': Action name is required. Example: updatePerson", e.getMessage());
+            assertEquals("tag 'actioncomponent', field 'name': Action name is required. Example: updatePerson", e.getMessage());
         }
     }
 
@@ -287,7 +286,7 @@ public class ActionTagTest extends AbstractTagTest {
         tag.setNamespace("");
         tag.setName("testActionTagAction!input");
         tag.setExecuteResult(true);
-        ((DefaultActionMapper)container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true");
+        ((DefaultActionMapper) container.getInstance(ActionMapper.class)).setAllowDynamicMethodCalls("true");
 
         tag.doStartTag();
 
@@ -299,13 +298,15 @@ public class ActionTagTest extends AbstractTagTest {
         TestActionTagResult result = (TestActionTagResult) component.getProxy().getInvocation().getResult();
 
         assertTrue(stack.getContext().containsKey(ServletActionContext.PAGE_CONTEXT));
-        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT)instanceof PageContext);
+        assertTrue(stack.getContext().get(ServletActionContext.PAGE_CONTEXT) instanceof PageContext);
         assertTrue(result.isExecuted());
     }
 
     protected void setUp() throws Exception {
         super.setUp();
-        initDispatcher(new HashMap<String, String>() {{ put("configProviders", TestConfigurationProvider.class.getName()); }});
+        initDispatcher(new HashMap<String, String>() {{
+            put("configProviders", TestConfigurationProvider.class.getName());
+        }});
         createMocks();
     }
 
diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
index 63654ee..6a981c8 100644
--- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
+++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestWorkflowInterceptor.java
@@ -34,17 +34,17 @@ import java.util.Map;
 import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
 
 /**
- * <!-- START SNIPPET: description -->
- * <p>
  * An interceptor that makes sure there are not validation errors before allowing the interceptor chain to continue.
  * <b>This interceptor does not perform any validation</b>.
- * </p>
  *
- * <p>Copied from the {@link com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support for error handling of Restful
- * operations.  For example, if an validation error is discovered, a map of errors is created and processed to be
- * returned, using the appropriate content handler for rendering the body.</p>
+ * <p>
+ * Copied from the {@link com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor}, this interceptor adds support
+ * for error handling of Restful operations.  For example, if an validation error is discovered, a map of errors
+ * is created and processed to be returned, using the appropriate content handler for rendering the body.
+ * </p>
  *
- * <p>This interceptor does nothing if the name of the method being invoked is specified in the <b>excludeMethods</b>
+ * <p>
+ * This interceptor does nothing if the name of the method being invoked is specified in the <b>excludeMethods</b>
  * parameter. <b>excludeMethods</b> accepts a comma-delimited list of method names. For example, requests to
  * <b>foo!input.action</b> and <b>foo!back.action</b> will be skipped by this interceptor if you set the
  * <b>excludeMethods</b> parameter to "input, back".
@@ -58,34 +58,20 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
  * all methods for both parameters.
  * See {@link MethodFilterInterceptor} for more info.
  * </p>
- * <!-- END SNIPPET: description -->
  *
- * <p><u>Interceptor parameters:</u></p>
- * <p>
- * <!-- START SNIPPET: parameters -->
+ * <b>Interceptor parameters:</b>
  *
  * <ul>
- *
  * <li>inputResultName - Default to "input". Determine the result name to be returned when
  * an action / field error is found.</li>
- *
  * </ul>
- * <p>
- * <!-- END SNIPPET: parameters -->
  *
- * <p><u>Extending the interceptor:</u></p>
- * <p>
- * <!-- START SNIPPET: extending -->
- * <p>
+ * <b>Extending the interceptor:</b>
  * There are no known extension points for this interceptor.
- * </p>
- * <!-- END SNIPPET: extending -->
  *
- * <p><u>Example code:</u></p>
+ * <b>Example code:</b>
  *
  * <pre>
- * <!-- START SNIPPET: example -->
- *
  * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
  *     &lt;interceptor-ref name="params"/&gt;
  *     &lt;interceptor-ref name="validation"/&gt;
@@ -118,8 +104,6 @@ import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
  *     &lt;/interceptor-ref&gt;
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
  * &lt;/action&gt;
- *
- * <!-- END SNIPPET: example -->
  * </pre>
  *
  * @author Jason Carreira