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:14:52 UTC

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

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.


    from f071c9d  Reverse merges master
     new a504a16  WW-4789 WW-3788 Uses full variable name
     new 6c76275  WW-4789 WW-3788 Cleans up code & JavaDocs formatting

The 2 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:
 .../struts2/interceptor/ScopeInterceptor.java      | 14 ++++-----
 .../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 +++++++++++-----------
 5 files changed, 34 insertions(+), 80 deletions(-)


[struts] 01/02: WW-4789 WW-3788 Uses full variable name

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 a504a16eae6b9db08e70908f030c1483c201ed4e
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Tue Apr 28 08:01:26 2020 +0200

    WW-4789 WW-3788 Uses full variable name
---
 .../org/apache/struts2/interceptor/ScopeInterceptor.java   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
index 08afd6e..e9d09dc 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/ScopeInterceptor.java
@@ -262,9 +262,9 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
     }
 
     protected void after(ActionInvocation invocation, String result) throws Exception {
-        Map<String, Object> ses = ActionContext.getContext().getSession();
-        if ( ses != null) {
-            unlock(ses);
+        Map<String, Object> session = ActionContext.getContext().getSession();
+        if ( session != null) {
+            unlock(session);
         }
     }
 
@@ -282,14 +282,14 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
         }
 
         String key = getKey(invocation);
-        Map<String, Object> app = ActionContext.getContext().getApplication();
+        Map<String, Object> application = ActionContext.getContext().getApplication();
         final ValueStack stack = ActionContext.getContext().getValueStack();
 
         LOG.debug("scope interceptor before");
 
-        if (application != null)
-            for (String string : application) {
-                Object attribute = app.get(key + string);
+        if (this.application != null)
+            for (String string : this.application) {
+                Object attribute = application.get(key + string);
                 if (attribute != null) {
                     LOG.debug("Application scoped variable set {} = {}", string, String.valueOf(attribute));
                     stack.setValue(string, nullConvert(attribute));


[struts] 02/02: 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 6c76275af69fa64067fc1bf5281bfd8e1eb210a5
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 +++++++++++-----------
 4 files changed, 27 insertions(+), 73 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;
     }
+
 }