struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sdu...@apache.org
Subject [03/16] struts-extras git commit: fixed struts version
Date Wed, 29 Mar 2017 09:56:52 GMT
fixed struts version


Project: http://git-wip-us.apache.org/repos/asf/struts-extras/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-extras/commit/02a1ca68
Tree: http://git-wip-us.apache.org/repos/asf/struts-extras/tree/02a1ca68
Diff: http://git-wip-us.apache.org/repos/asf/struts-extras/diff/02a1ca68

Branch: refs/heads/master
Commit: 02a1ca6819aa355574930285a0990a8b080bdd4a
Parents: 7879baf
Author: Stefaan Dutry <stefaan.dutry@gmail.com>
Authored: Tue Mar 28 08:23:12 2017 +0200
Committer: Stefaan Dutry <stefaan.dutry@gmail.com>
Committed: Tue Mar 28 08:23:12 2017 +0200

----------------------------------------------------------------------
 struts2-custom-results-plugin/pom.xml           |   2 +-
 .../HttpsOffloadAwareServletRedirectResult.java | 146 -------------------
 .../HttpsOffloadAwareServletRedirectResult.java | 145 ++++++++++++++++++
 3 files changed, 146 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-extras/blob/02a1ca68/struts2-custom-results-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/struts2-custom-results-plugin/pom.xml b/struts2-custom-results-plugin/pom.xml
index 44eadde..b0efc2d 100644
--- a/struts2-custom-results-plugin/pom.xml
+++ b/struts2-custom-results-plugin/pom.xml
@@ -70,7 +70,7 @@
         <dependency>
             <groupId>org.apache.struts</groupId>
             <artifactId>struts2-core</artifactId>
-            <version>2.3.20.1</version>
+            <version>2.5.10.1</version>
         </dependency>
 
         <dependency>

http://git-wip-us.apache.org/repos/asf/struts-extras/blob/02a1ca68/struts2-custom-results-plugin/src/main/java/org/apache/struts2/dispatcher/HttpsOffloadAwareServletRedirectResult.java
----------------------------------------------------------------------
diff --git a/struts2-custom-results-plugin/src/main/java/org/apache/struts2/dispatcher/HttpsOffloadAwareServletRedirectResult.java
b/struts2-custom-results-plugin/src/main/java/org/apache/struts2/dispatcher/HttpsOffloadAwareServletRedirectResult.java
deleted file mode 100644
index b3ee26a..0000000
--- a/struts2-custom-results-plugin/src/main/java/org/apache/struts2/dispatcher/HttpsOffloadAwareServletRedirectResult.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, 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.apache.struts2.dispatcher;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.dispatcher.Dispatcher;
-import org.apache.struts2.dispatcher.ServletRedirectResult;
-import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import org.apache.struts2.views.util.UrlHelper;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.config.entities.ResultConfig;
-import com.opensymphony.xwork2.inject.Inject;
-
-public class HttpsOffloadAwareServletRedirectResult extends ServletRedirectResult {
-    private static final long serialVersionUID = -5384946213381645549L;
-    private static final Logger LOG = LogManager.getLogger(HttpsOffloadAwareServletRedirectResult.class);
-
-    private UrlHelper urlHelper;
-
-    @Inject
-    public void setUrlHelper(UrlHelper urlHelper) {
-        this.urlHelper = urlHelper;
-    }
-
-    /**
-     * Redirects to the location specified by calling
-     * {@link HttpServletResponse#sendRedirect(String)}.
-     * 
-     * @param finalLocation
-     *            the location to redirect to.
-     * @param invocation
-     *            an encapsulation of the action execution state.
-     * @throws Exception
-     *             if an error occurs when redirecting.
-     */
-    protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception
{
-        ActionContext ctx = invocation.getInvocationContext();
-        HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
-        HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
-
-        if (isPathUrl(finalLocation)) {
-            if (!finalLocation.startsWith("/")) {
-                ActionMapping mapping = actionMapper.getMapping(request,
-                        Dispatcher.getInstance().getConfigurationManager());
-                String namespace = null;
-                if (mapping != null) {
-                    namespace = mapping.getNamespace();
-                }
-
-                if ((namespace != null) && (namespace.length() > 0) &&
(!"/".equals(namespace))) {
-                    finalLocation = namespace + "/" + finalLocation;
-                } else {
-                    finalLocation = "/" + finalLocation;
-                }
-            }
-
-            // if the URL's are relative to the servlet context, append the
-            // servlet context path
-            if (prependServletContext && (request.getContextPath() != null)
-                    && (request.getContextPath().length() > 0)) {
-                finalLocation = request.getContextPath() + finalLocation;
-            }
-
-            finalLocation = fixSchemeIfNeeded(finalLocation, request);
-        }
-        ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
-        if (resultConfig != null) {
-            Map<String, String> resultConfigParams = resultConfig.getParams();
-
-            List<String> prohibitedResultParams = getProhibitedResultParams();
-            for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
-                if (!prohibitedResultParams.contains(e.getKey())) {
-                    Collection<String> values = conditionalParseCollection(e.getValue(),
invocation,
-                            suppressEmptyParameters);
-                    if (!suppressEmptyParameters || !values.isEmpty()) {
-                        requestParameters.put(e.getKey(), values);
-                    }
-                }
-            }
-        }
-
-        StringBuilder tmpLocation = new StringBuilder(finalLocation);
-        urlHelper.buildParametersString(requestParameters, tmpLocation, "&");
-
-        // add the anchor
-        if (anchor != null) {
-            tmpLocation.append('#').append(anchor);
-        }
-
-        finalLocation = response.encodeRedirectURL(tmpLocation.toString());
-
-        LOG.debug("Redirecting to finalLocation: {}", finalLocation);
-
-        sendRedirect(response, finalLocation);
-    }
-
-    private String fixSchemeIfNeeded(String location, HttpServletRequest request) {
-        if ("https".equals(request.getHeader("X-Forwarded-Proto"))) {
-            LOG.debug("https offloading happened, fixing redirectlocation");
-            StringBuilder fixedLocation = new StringBuilder();
-            fixedLocation.append("https");
-            fixedLocation.append("://");
-            fixedLocation.append(request.getServerName());
-            if (request.getServerPort() != 80) {
-                fixedLocation.append(':');
-                fixedLocation.append(request.getServerPort());
-            }
-            fixedLocation.append(location);
-
-            return fixedLocation.toString();
-        } else {
-            return location;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/struts-extras/blob/02a1ca68/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
----------------------------------------------------------------------
diff --git a/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
b/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
new file mode 100644
index 0000000..201eb3b
--- /dev/null
+++ b/struts2-custom-results-plugin/src/main/java/org/apache/struts2/result/HttpsOffloadAwareServletRedirectResult.java
@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, 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.apache.struts2.result;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.result.ServletRedirectResult;
+import org.apache.struts2.views.util.UrlHelper;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.inject.Inject;
+
+public class HttpsOffloadAwareServletRedirectResult extends ServletRedirectResult {
+    private static final long serialVersionUID = -5384946213381645549L;
+    private static final Logger LOG = LogManager.getLogger(HttpsOffloadAwareServletRedirectResult.class);
+
+    private UrlHelper urlHelper;
+
+    @Inject
+    public void setUrlHelper(UrlHelper urlHelper) {
+        this.urlHelper = urlHelper;
+    }
+
+    /**
+     * Redirects to the location specified by calling
+     * {@link HttpServletResponse#sendRedirect(String)}.
+     * 
+     * @param finalLocation
+     *            the location to redirect to.
+     * @param invocation
+     *            an encapsulation of the action execution state.
+     * @throws Exception
+     *             if an error occurs when redirecting.
+     */
+    protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception
{
+        ActionContext ctx = invocation.getInvocationContext();
+        HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
+        HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE);
+
+        if (isPathUrl(finalLocation)) {
+            if (!finalLocation.startsWith("/")) {
+                ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager());
+                String namespace = null;
+                if (mapping != null) {
+                    namespace = mapping.getNamespace();
+                }
+
+                if ((namespace != null) && (namespace.length() > 0) &&
(!"/".equals(namespace))) {
+                    finalLocation = namespace + "/" + finalLocation;
+                } else {
+                    finalLocation = "/" + finalLocation;
+                }
+            }
+
+            // if the URL's are relative to the servlet context, append the
+            // servlet context path
+            if (prependServletContext && (request.getContextPath() != null)
+                    && (request.getContextPath().length() > 0)) {
+                finalLocation = request.getContextPath() + finalLocation;
+            }
+
+            finalLocation = fixSchemeIfNeeded(finalLocation, request);
+        }
+        ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
+        if (resultConfig != null) {
+            Map<String, String> resultConfigParams = resultConfig.getParams();
+
+            List<String> prohibitedResultParams = getProhibitedResultParams();
+            for (Map.Entry<String, String> e : resultConfigParams.entrySet()) {
+                if (!prohibitedResultParams.contains(e.getKey())) {
+                    Collection<String> values = conditionalParseCollection(e.getValue(),
invocation,
+                            suppressEmptyParameters);
+                    if (!suppressEmptyParameters || !values.isEmpty()) {
+                        requestParameters.put(e.getKey(), values);
+                    }
+                }
+            }
+        }
+
+        StringBuilder tmpLocation = new StringBuilder(finalLocation);
+        urlHelper.buildParametersString(requestParameters, tmpLocation, "&");
+
+        // add the anchor
+        if (anchor != null) {
+            tmpLocation.append('#').append(anchor);
+        }
+
+        finalLocation = response.encodeRedirectURL(tmpLocation.toString());
+
+        LOG.debug("Redirecting to finalLocation: {}", finalLocation);
+
+        sendRedirect(response, finalLocation);
+    }
+
+    private String fixSchemeIfNeeded(String location, HttpServletRequest request) {
+        if ("https".equals(request.getHeader("X-Forwarded-Proto"))) {
+            LOG.debug("https offloading happened, fixing redirectlocation");
+            StringBuilder fixedLocation = new StringBuilder();
+            fixedLocation.append("https");
+            fixedLocation.append("://");
+            fixedLocation.append(request.getServerName());
+            if (request.getServerPort() != 80) {
+                fixedLocation.append(':');
+                fixedLocation.append(request.getServerPort());
+            }
+            fixedLocation.append(location);
+
+            return fixedLocation.toString();
+        } else {
+            return location;
+        }
+    }
+
+}


Mime
View raw message