struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1533338 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/ core/src/main/java/org/apache/struts2/dispatcher/mapper/ core/src/main/java/org/apache/struts2/dispatcher/ng/ plugins/rest/src/main/java/org/apache/struts2/rest/
Date Fri, 18 Oct 2013 07:07:32 GMT
Author: lukaszlenart
Date: Fri Oct 18 07:07:32 2013
New Revision: 1533338

URL: http://svn.apache.org/r1533338
Log:
WW-4225 Extracts duplicated code into util class

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/RequestUtils.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
    struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/RequestUtils.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/RequestUtils.java?rev=1533338&r1=1533337&r2=1533338&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/RequestUtils.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/RequestUtils.java Fri Oct 18
07:07:32 2013
@@ -62,4 +62,26 @@ public class RequestUtils {
         return requestUri.substring(startIndex, endIndex);
     }
 
+    /**
+     * Gets the uri from the request
+     *
+     * @param request The request
+     * @return The uri
+     */
+    public static String getUri(HttpServletRequest request) {
+        // handle http dispatcher includes.
+        String uri = (String) request
+                .getAttribute("javax.servlet.include.servlet_path");
+        if (uri != null) {
+            return uri;
+        }
+
+        uri = getServletPath(request);
+        if (uri != null && !"".equals(uri)) {
+            return uri;
+        }
+
+        uri = request.getRequestURI();
+        return uri.substring(request.getContextPath().length());
+    }
 }

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?rev=1533338&r1=1533337&r2=1533338&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
Fri Oct 18 07:07:32 2013
@@ -236,7 +236,7 @@ public class DefaultActionMapper impleme
      */
     public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager)
{
         ActionMapping mapping = new ActionMapping();
-        String uri = getUri(request);
+        String uri = RequestUtils.getUri(request);
 
         int indexOfSemicolon = uri.indexOf(";");
         uri = (indexOfSemicolon > -1) ? uri.substring(0, indexOfSemicolon) : uri;
@@ -438,29 +438,6 @@ public class DefaultActionMapper impleme
         }
     }
 
-    /**
-     * Gets the uri from the request
-     *
-     * @param request The request
-     * @return The uri
-     */
-    protected String getUri(HttpServletRequest request) {
-        // handle http dispatcher includes.
-        String uri = (String) request
-                .getAttribute("javax.servlet.include.servlet_path");
-        if (uri != null) {
-            return uri;
-        }
-
-        uri = RequestUtils.getServletPath(request);
-        if (uri != null && !"".equals(uri)) {
-            return uri;
-        }
-
-        uri = request.getRequestURI();
-        return uri.substring(request.getContextPath().length());
-    }
-
     /*
      * (non-Javadoc)
      *

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java?rev=1533338&r1=1533337&r2=1533338&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/PrefixBasedActionMapper.java
Fri Oct 18 07:07:32 2013
@@ -5,6 +5,7 @@ import com.opensymphony.xwork2.inject.Co
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
 
 import javax.servlet.http.HttpServletRequest;
@@ -73,7 +74,7 @@ public class PrefixBasedActionMapper ext
 
     @SuppressWarnings("unchecked")
     public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager)
{
-        String uri = getUri(request);
+        String uri = RequestUtils.getUri(request);
         for (int lastIndex = uri.lastIndexOf('/'); lastIndex > (-1); lastIndex = uri.lastIndexOf('/',
lastIndex - 1)) {
             ActionMapper actionMapper = actionMappers.get(uri.substring(0, lastIndex));
             if (actionMapper != null) {

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java?rev=1533338&r1=1533337&r2=1533338&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
Fri Oct 18 07:07:32 2013
@@ -196,7 +196,7 @@ public class PrepareOperations {
      */
     public boolean isUrlExcluded( HttpServletRequest request, List<Pattern> excludedPatterns
) {
         if (excludedPatterns != null) {
-            String uri = getUri(request);
+            String uri = RequestUtils.getUri(request);
             for ( Pattern pattern : excludedPatterns ) {
                 if (pattern.matcher(uri).matches()) {
                     return true;
@@ -206,27 +206,4 @@ public class PrepareOperations {
         return false;
     }
 
-    /**
-     * Gets the uri from the request
-     *
-     * @param request The request
-     *
-     * @return The uri
-     */
-    private String getUri( HttpServletRequest request ) {
-        // handle http dispatcher includes.
-        String uri = (String) request.getAttribute("javax.servlet.include.servlet_path");
-        if (uri != null) {
-            return uri;
-        }
-
-        uri = RequestUtils.getServletPath(request);
-        if (uri != null && !"".equals(uri)) {
-            return uri;
-        }
-
-        uri = request.getRequestURI();
-        return uri.substring(request.getContextPath().length());
-    }
-
 }

Modified: struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java?rev=1533338&r1=1533337&r2=1533338&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
(original)
+++ struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
Fri Oct 18 07:07:32 2013
@@ -27,6 +27,7 @@ import com.opensymphony.xwork2.config.en
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
+import org.apache.struts2.RequestUtils;
 import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.dispatcher.mapper.DefaultActionMapper;
@@ -180,7 +181,7 @@ public class RestActionMapper extends De
     public ActionMapping getMapping(HttpServletRequest request,
             ConfigurationManager configManager) {
         ActionMapping mapping = new ActionMapping();
-        String uri = getUri(request);
+        String uri = RequestUtils.getUri(request);
 
         uri = dropExtension(uri, mapping);
         if (uri == null) {



Mime
View raw message