myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [myfaces] branch master updated: refactored
Date Mon, 24 Dec 2018 17:10:15 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 4811568  refactored
4811568 is described below

commit 4811568af152d3465f6f053a5218d0a24aa29a5a
Author: Thomas Andraschko <tandraschko@apache.org>
AuthorDate: Mon Dec 24 18:09:57 2018 +0100

    refactored
---
 .../apache/myfaces/application/ViewIdSupport.java  |   4 +-
 .../apache/myfaces/util/ExternalContextUtils.java  | 112 ++++++++++++++++++
 .../java/org/apache/myfaces/util/RequestType.java  | 128 ---------------------
 ...ProtectionUtils.java => UrlPatternMatcher.java} |   9 +-
 .../facelets/pool/impl/ViewPoolFactoryImpl.java    |   4 +-
 .../util/FaceletsTemplateMappingUtils.java         |   4 +-
 6 files changed, 120 insertions(+), 141 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java b/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
index 08d70fa..8ba2dcf 100644
--- a/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ViewIdSupport.java
@@ -35,7 +35,7 @@ import org.apache.myfaces.util.ConcurrentLRUCache;
 import org.apache.myfaces.util.SharedStringBuilder;
 import org.apache.myfaces.util.ExternalContextUtils;
 import org.apache.myfaces.util.LangUtils;
-import org.apache.myfaces.util.ViewProtectionUtils;
+import org.apache.myfaces.util.UrlPatternMatcher;
 
 /**
  * A ViewHandlerSupport implementation for use with standard Java Servlet engines,
@@ -629,7 +629,7 @@ public class ViewIdSupport
             {
                 for (String urlPattern : protectedViews)
                 {
-                    if (ViewProtectionUtils.matchPattern(viewId, urlPattern))
+                    if (UrlPatternMatcher.match(viewId, urlPattern))
                     {
                         protectedView = true;
                         break;
diff --git a/impl/src/main/java/org/apache/myfaces/util/ExternalContextUtils.java b/impl/src/main/java/org/apache/myfaces/util/ExternalContextUtils.java
index 10874fb..4e6cdb4 100644
--- a/impl/src/main/java/org/apache/myfaces/util/ExternalContextUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/util/ExternalContextUtils.java
@@ -650,4 +650,116 @@ public final class ExternalContextUtils
         }
         return null; // not found
     }
+    
+    
+    
+    
+    /**
+     * Represents the type of request currently in the ExternalContext.
+     * All servlet requests will be of the SERVLET requestType whereas
+     * all of the other RequestTypes will be portlet type requests.  There
+     * are a number of convenience methods on the RequestType enumeration
+     * which can be used to determine the capabilities of the current request.
+     * 
+     * @version $Revision$ $Date$
+     */
+    public enum RequestType
+    {
+        /**
+         * The type for all servlet requests.  SERVLET request types are
+         * both client requests and response writable.
+         */
+        SERVLET(true, true, false),
+
+        /**
+         * The type for a portlet RenderRequest.  RENDER request types are
+         * for portlets and are response writable but are NOT client
+         * requests.
+         */
+        RENDER(false, true, true),
+
+        /**
+         * The type for a portlet ActionRequest.  ACTION request types are
+         * for portlets and are client requests but are NOT response 
+         * writable.
+         */
+        ACTION(true, false, true),
+
+        /**
+         * The type for a portlet ResourceRequest.  RESOURCE request types
+         * are for portlets and are both client requests and response 
+         * writable.  RESOURCE request types will only be returned in a
+         * Portlet 2.0 portlet container.
+         */
+        RESOURCE(true, true, true),
+
+        /**
+         * The type for a portlet EventRequest.  EVENT request types
+         * are for portlets and are neither client requests nor response 
+         * writable.  EVENT request types will only be returned in a
+         * Portlet 2.0 portlet container.
+         */        
+        EVENT(false, false, true);
+
+        private boolean _client;
+        private boolean _writable;
+        private boolean _portlet;
+
+        RequestType(boolean client, boolean writable, boolean portlet)
+        {
+            _client = client;
+            _writable  = writable;
+            _portlet    = portlet;
+        }
+
+        /**
+         * Returns <code>true</code> if this request was a direct
+         * result of a call from the client.  This implies that
+         * the current application is the "owner" of the current
+         * request and that it has access to the inputStream, can
+         * get and set character encodings, etc.  Currently all
+         * SERVLET, ACTION, and RESOURCE RequestTypes are client
+         * requests.
+         * 
+         * @return <code>true</code> if the current request is a
+         *         client data type request and <code>false</code>
+         *         if it is not.
+         */
+        public boolean isRequestFromClient()
+        {
+            return _client;
+        }
+
+        /**
+         * Returns <code>true</code> if the response for this
+         * RequestType is intended to produce output to the client.
+         * Currently the SERVLET, RENDER, and RESOURCE request are
+         * response writable.
+         *  
+         * @return <code>true</code> if the current request is 
+         *         intended to produce output and <code>false</code>
+         *         if it is not.
+         */
+        public boolean isResponseWritable()
+        {
+            return _writable;
+        }
+
+        /**
+         * Returns <code>true</code> if the response for this
+         * RequestType originated from a JSR-168 or JSR-286 
+         * portlet container.  Currently RENDER, ACTION,
+         * RESOURCE, and EVENT RequestTypes are all portlet
+         * requests.
+         * 
+         * @return <code>true</code> if the current request
+         *         originated inside of a JSR-168 or JSR-286
+         *         Portlet Container or <code>false</code> if
+         *         it did not.
+         */
+        public boolean isPortlet()
+        {
+            return _portlet;
+        }
+    }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/util/RequestType.java b/impl/src/main/java/org/apache/myfaces/util/RequestType.java
deleted file mode 100644
index e81c0f4..0000000
--- a/impl/src/main/java/org/apache/myfaces/util/RequestType.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.myfaces.util;
-
-/**
- * Represents the type of request currently in the ExternalContext.
- * All servlet requests will be of the SERVLET requestType whereas
- * all of the other RequestTypes will be portlet type requests.  There
- * are a number of convenience methods on the RequestType enumeration
- * which can be used to determine the capabilities of the current request.
- * 
- * @version $Revision$ $Date$
- */
-public enum RequestType
-{
-    /**
-     * The type for all servlet requests.  SERVLET request types are
-     * both client requests and response writable.
-     */
-    SERVLET(true, true, false),
-    
-    /**
-     * The type for a portlet RenderRequest.  RENDER request types are
-     * for portlets and are response writable but are NOT client
-     * requests.
-     */
-    RENDER(false, true, true),
-    
-    /**
-     * The type for a portlet ActionRequest.  ACTION request types are
-     * for portlets and are client requests but are NOT response 
-     * writable.
-     */
-    ACTION(true, false, true),
-    
-    /**
-     * The type for a portlet ResourceRequest.  RESOURCE request types
-     * are for portlets and are both client requests and response 
-     * writable.  RESOURCE request types will only be returned in a
-     * Portlet 2.0 portlet container.
-     */
-    RESOURCE(true, true, true),
-    
-    /**
-     * The type for a portlet EventRequest.  EVENT request types
-     * are for portlets and are neither client requests nor response 
-     * writable.  EVENT request types will only be returned in a
-     * Portlet 2.0 portlet container.
-     */        
-    EVENT(false, false, true);
-    
-    private boolean _client;
-    private boolean _writable;
-    private boolean _portlet;
-    
-    RequestType(boolean client, boolean writable, boolean portlet)
-    {
-        _client = client;
-        _writable  = writable;
-        _portlet    = portlet;
-    }
-    
-    /**
-     * Returns <code>true</code> if this request was a direct
-     * result of a call from the client.  This implies that
-     * the current application is the "owner" of the current
-     * request and that it has access to the inputStream, can
-     * get and set character encodings, etc.  Currently all
-     * SERVLET, ACTION, and RESOURCE RequestTypes are client
-     * requests.
-     * 
-     * @return <code>true</code> if the current request is a
-     *         client data type request and <code>false</code>
-     *         if it is not.
-     */
-    public boolean isRequestFromClient()
-    {
-        return _client;
-    }
-    
-    /**
-     * Returns <code>true</code> if the response for this
-     * RequestType is intended to produce output to the client.
-     * Currently the SERVLET, RENDER, and RESOURCE request are
-     * response writable.
-     *  
-     * @return <code>true</code> if the current request is 
-     *         intended to produce output and <code>false</code>
-     *         if it is not.
-     */
-    public boolean isResponseWritable()
-    {
-        return _writable;
-    }
-    
-    /**
-     * Returns <code>true</code> if the response for this
-     * RequestType originated from a JSR-168 or JSR-286 
-     * portlet container.  Currently RENDER, ACTION,
-     * RESOURCE, and EVENT RequestTypes are all portlet
-     * requests.
-     * 
-     * @return <code>true</code> if the current request
-     *         originated inside of a JSR-168 or JSR-286
-     *         Portlet Container or <code>false</code> if
-     *         it did not.
-     */
-    public boolean isPortlet()
-    {
-        return _portlet;
-    }
-}
\ No newline at end of file
diff --git a/impl/src/main/java/org/apache/myfaces/util/ViewProtectionUtils.java b/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
similarity index 95%
rename from impl/src/main/java/org/apache/myfaces/util/ViewProtectionUtils.java
rename to impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
index 4195e54..6d636ea 100644
--- a/impl/src/main/java/org/apache/myfaces/util/ViewProtectionUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/util/UrlPatternMatcher.java
@@ -18,13 +18,8 @@
  */
 package org.apache.myfaces.util;
 
-/**
- *
- * @since 2.2
- */
-public class ViewProtectionUtils
+public class UrlPatternMatcher
 {
-    
     /**
      * NOTE: Taken from org.apache.catalina.deploy.SecurityConstraint
      * 
@@ -36,7 +31,7 @@ public class ViewProtectionUtils
      *  (must start with '/')
      * @param pattern URL pattern to be compared against
      */
-    public static boolean matchPattern(String path, String pattern)
+    public static boolean match(String path, String pattern)
     {
         // Normalize the argument strings
         if ((path == null) || (path.length() == 0))
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/pool/impl/ViewPoolFactoryImpl.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/pool/impl/ViewPoolFactoryImpl.java
index 96281a0..e26f486 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/pool/impl/ViewPoolFactoryImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/pool/impl/ViewPoolFactoryImpl.java
@@ -27,7 +27,7 @@ import javax.faces.context.FacesContext;
 import org.apache.myfaces.config.RuntimeConfig;
 import org.apache.myfaces.config.element.ViewPoolMapping;
 import org.apache.myfaces.config.element.ViewPoolParameter;
-import org.apache.myfaces.util.ViewProtectionUtils;
+import org.apache.myfaces.util.UrlPatternMatcher;
 import org.apache.myfaces.view.facelets.ViewPoolProcessor;
 import org.apache.myfaces.view.facelets.pool.ViewPool;
 import org.apache.myfaces.view.facelets.pool.ViewPoolFactory;
@@ -69,7 +69,7 @@ public class ViewPoolFactoryImpl extends ViewPoolFactory
         for (int i = 0; i < urlPatterns.size(); i++)
         {
             String urlPattern = urlPatterns.get(i);
-            if (ViewProtectionUtils.matchPattern(root.getViewId(), urlPattern))
+            if (UrlPatternMatcher.match(root.getViewId(), urlPattern))
             {
                 return viewPoolList.get(i);
             }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/util/FaceletsTemplateMappingUtils.java
b/impl/src/main/java/org/apache/myfaces/view/facelets/util/FaceletsTemplateMappingUtils.java
index b1c3754..834b370 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/util/FaceletsTemplateMappingUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/util/FaceletsTemplateMappingUtils.java
@@ -20,7 +20,7 @@ package org.apache.myfaces.view.facelets.util;
 
 import org.apache.myfaces.config.RuntimeConfig;
 import org.apache.myfaces.config.element.FaceletsTemplateMapping;
-import org.apache.myfaces.util.ViewProtectionUtils;
+import org.apache.myfaces.util.UrlPatternMatcher;
 
 /**
  *
@@ -31,7 +31,7 @@ public class FaceletsTemplateMappingUtils
     {
         for (FaceletsTemplateMapping mapping : runtimeConfig.getFaceletsTemplateMappings())
         {
-            if (ViewProtectionUtils.matchPattern(path, mapping.getUrlPattern()))
+            if (UrlPatternMatcher.match(path, mapping.getUrlPattern()))
             {
                 return true;
             }


Mime
View raw message