You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/01/22 16:46:26 UTC
[myfaces] branch master updated: fixed exact mapping integration
tests
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 74cc468 fixed exact mapping integration tests
74cc468 is described below
commit 74cc4685cc41c8eef3b5f99b32de00d9216bb31f
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Tue Jan 22 17:45:35 2019 +0100
fixed exact mapping integration tests
---
.../resource/BaseResourceHandlerSupport.java | 7 +++++-
.../org/apache/myfaces/resource/ResourceImpl.java | 28 ++++++++++++++--------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/resource/BaseResourceHandlerSupport.java b/impl/src/main/java/org/apache/myfaces/resource/BaseResourceHandlerSupport.java
index 2727484..9403ceb 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/BaseResourceHandlerSupport.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/BaseResourceHandlerSupport.java
@@ -70,7 +70,12 @@ public class BaseResourceHandlerSupport extends ResourceHandlerSupport
if (mapping != null)
{
String resourceBasePath = null;
- if (mapping.isExtensionMapping())
+ if (mapping.isExactMapping())
+ {
+ // this method is actually only used to determine if the current request is a resource request
+ // as the resource can never be a exact mapping, lets ignore it
+ }
+ else if (mapping.isExtensionMapping())
{
// Mapping using a suffix. In this case we have to strip
// the suffix. If we have a url like:
diff --git a/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java b/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
index a6076a3..dbf4120 100644
--- a/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
@@ -28,6 +28,8 @@ import java.util.Map;
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
import javax.faces.context.FacesContext;
+import org.apache.myfaces.application.FacesServletMapping;
+import org.apache.myfaces.application.FacesServletMappingUtils;
/**
* Default implementation for resources
@@ -110,20 +112,26 @@ public class ResourceImpl extends Resource implements ContractResource
{
if (_requestPath == null)
{
- String path;
- if (_resourceHandlerSupport.isExtensionMapping())
+ FacesContext context = FacesContext.getCurrentInstance();
+ FacesServletMapping mapping = FacesServletMappingUtils.getCurrentRequestFacesServletMapping(context);
+ if (mapping.isExactMapping())
+ {
+ // resources can't be exact, lets fallback to a generic one
+ mapping = FacesServletMappingUtils.getGenericPrefixOrSuffixMapping(context);
+ }
+
+ String path = "";
+ if (mapping.isExtensionMapping())
{
path = _resourceHandlerSupport.getResourceIdentifier() + '/' +
- getResourceName() + _resourceHandlerSupport.getMapping();
+ getResourceName() + mapping.getExtension();
}
- else
+ else if (mapping.isPrefixMapping())
{
- String mapping = _resourceHandlerSupport.getMapping();
path = _resourceHandlerSupport.getResourceIdentifier() + '/' + getResourceName();
- path = (mapping == null) ? path : mapping + path;
+ path = (mapping.getPrefix() == null) ? path : mapping.getPrefix() + path;
}
- FacesContext facesContext = FacesContext.getCurrentInstance();
String metadata = null;
boolean useAmp = false;
if (getLibraryName() != null)
@@ -132,12 +140,12 @@ public class ResourceImpl extends Resource implements ContractResource
path = path + metadata;
useAmp = true;
- if (!facesContext.isProjectStage(ProjectStage.Production)
+ if (!context.isProjectStage(ProjectStage.Production)
&& JSF_JS_RESOURCE_NAME.equals(getResourceName())
&& JAVAX_FACES_LIBRARY_NAME.equals(getLibraryName()))
{
// append &stage=?? for all ProjectStages except Production
- path = path + "&stage=" + facesContext.getApplication().getProjectStage().toString();
+ path = path + "&stage=" + context.getApplication().getProjectStage().toString();
}
}
if (_resourceMeta.getLocalePrefix() != null)
@@ -150,7 +158,7 @@ public class ResourceImpl extends Resource implements ContractResource
path = path + (useAmp ? '&' : '?') + "con=" + _resourceMeta.getContractName();
useAmp = true;
}
- _requestPath = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path);
+ _requestPath = context.getApplication().getViewHandler().getResourceURL(context, path);
}
return _requestPath;
}