myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch 2.3.x updated: MYFACES-4289
Date Tue, 30 Apr 2019 21:32:39 GMT
This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.3.x by this push:
     new 4d05123  MYFACES-4289
4d05123 is described below

commit 4d05123ae7566420cd8d28b08976a55d6be68a26
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Tue Apr 30 23:32:21 2019 +0200

    MYFACES-4289
---
 .../application/FacesServletMappingUtils.java      | 68 +++++++++++++++-------
 1 file changed, 46 insertions(+), 22 deletions(-)

diff --git a/shared/src/main/java/org/apache/myfaces/shared/application/FacesServletMappingUtils.java
b/shared/src/main/java/org/apache/myfaces/shared/application/FacesServletMappingUtils.java
index 6fb71c2..e2211c2 100644
--- a/shared/src/main/java/org/apache/myfaces/shared/application/FacesServletMappingUtils.java
+++ b/shared/src/main/java/org/apache/myfaces/shared/application/FacesServletMappingUtils.java
@@ -63,7 +63,7 @@ public class FacesServletMappingUtils
         return servletRegistration;
     }
     
-    public static String[] getFacesServletMappings(FacesContext facesContext,ServletContext
servletContext)
+    public static String[] getFacesServletMappings(FacesContext facesContext, ServletContext
servletContext)
     {
         Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
         
@@ -162,38 +162,62 @@ public class FacesServletMappingUtils
     {
         try
         {
-            ServletRegistration facesServletRegistration = getFacesServletRegistration(
-                    facesContext, servletContext);
-            if (facesServletRegistration != null)
+            Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations();
+            if (servletRegistrations  != null)
             {
                 FacesServletMapping facesExtensionMapping = null;
                 FacesServletMapping facesPrefixMapping = null;
                 FacesServletMapping facesExactMapping = null;
 
-                try
+                ServletRegistration facesServletRegistration = getFacesServletRegistration(
+                        facesContext, servletContext);
+                
+                for (ServletRegistration servletRegistration : servletRegistrations.values())
                 {
-                    String[] mappings = getFacesServletMappings(facesContext, servletContext);
-                    for (String mapping : mappings)
+                    try
                     {
-                        if (isExtensionMapping(mapping))
+                        Collection<String> mappings = servletRegistration.getMappings();
+                        if (servletRegistration.getClassName().equals(servletRegistration.getClassName()))
                         {
-                            facesExtensionMapping = FacesServletMapping.createExtensionMapping(
-                                    extractExtension(mapping));
+                            for (String mapping : mappings)
+                            {
+                                if (isExtensionMapping(mapping))
+                                {
+                                    facesExtensionMapping = FacesServletMapping.createExtensionMapping(
+                                            extractExtension(mapping));
+                                }
+                                else if (isPrefixMapping(mapping))
+                                {
+                                    facesPrefixMapping = FacesServletMapping.createPrefixMapping(
+                                            extractPrefix(mapping));
+                                }
+                                else if (allowExactMatch && mapping.startsWith("/")
&& mapping.equals(servletPath))
+                                {
+                                    facesExactMapping = FacesServletMapping.createExactMapping(servletPath);
+                                }
+                            }
                         }
-                        else if (isPrefixMapping(mapping))
+                        else
                         {
-                            facesPrefixMapping = FacesServletMapping.createPrefixMapping(
-                                    extractPrefix(mapping));
-                        }
-                        else if (allowExactMatch && mapping.startsWith("/") &&
mapping.equals(servletPath))
-                        {
-                            facesExactMapping = FacesServletMapping.createExactMapping(servletPath);
-                        }
+                            //This is not a FacesServlet mapping.  It could be a non-faces
request
+                            //Need to look for exact mapping to servletPath
+                            for (String mapping : mappings)
+                            {                                
+                                if (mapping.startsWith("/") && mapping.endsWith("/*"))
+                                {
+                                    mapping = mapping.substring(0, mapping.length()-2);
+                                }                                
+                                if (mapping.equals(servletPath))
+                                {
+                                    return FacesServletMapping.createPrefixMapping(mapping);
+                                }
+                            }
+                       }
+                    }
+                    catch (Exception ex)
+                    {
+                        //No op
                     }
-                }
-                catch (Exception ex)
-                {
-                    //No op
                 }
 
                 // Choose exact mapping if preferred.


Mime
View raw message