Skip to content

Commit

Permalink
FACES-2953 alloy components fail to load due to infinite loop of requ…
Browse files Browse the repository at this point in the history
…ests in Pluto 3.0
  • Loading branch information
stiemannkj1 committed Oct 27, 2016
1 parent 78a8b11 commit 9542656
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public InputStream getInputStream() throws IOException {
}

if ("text/css".equals(contentType)) {
resourceText = ExpressionUtil.filterExpressions(resourceText, resourceHandlerChain, externalContext);
resourceText = ExpressionUtil.filterResourceExpressions(resourceText, resourceHandlerChain,
externalContext);
}

comboResourceText.append(resourceText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private ExpressionUtil() {
throw new AssertionError();
}

/* package-priavte */ static String filterExpressions(String text, ResourceHandler resourceHandlerChain,
/* package-priavte */ static String filterResourceExpressions(String text, ResourceHandler resourceHandlerChain,
ExternalContext externalContext) {

int startPos = text.indexOf(RESOURCE_TOKEN_BEGIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*/
public class FilteredResourceExpressionImpl extends FilteredResourceBase {

// Private Constants
private static final String COMBO_MODULE_PATHS_DELIMITER = "#{comboModulePathsDelimiter}";
private static final String SCRIPT_MODULE_PATHS_DELIMITER = "#{scriptModulePathsDelimiter}";

// Private Members
private Resource wrappedResource;

Expand All @@ -44,7 +48,34 @@ protected String filter(String text) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ResourceHandler resourceHandlerChain = facesContext.getApplication().getResourceHandler();
ExternalContext externalContext = facesContext.getExternalContext();
String comboModulePathsDelimiter = getModulePathsDelimiter("combo", resourceHandlerChain, externalContext);
String scriptModulePathsDelimiter = getModulePathsDelimiter("script", resourceHandlerChain, externalContext);
text = text.replace(COMBO_MODULE_PATHS_DELIMITER, comboModulePathsDelimiter);
text = text.replace(SCRIPT_MODULE_PATHS_DELIMITER, scriptModulePathsDelimiter);

return ExpressionUtil.filterResourceExpressions(text, resourceHandlerChain, externalContext);
}

private String getModulePathsDelimiter(String resourceName, ResourceHandler resourceHandlerChain,
ExternalContext externalContext) {

String modulePathsDelimiter = "&";
Resource resource = resourceHandlerChain.createResource(resourceName, ResLibResourceHandler.LIBRARY_NAME);

if (resource != null) {

String requestPath = resource.getRequestPath();

if (requestPath != null) {

String resourceURL = externalContext.encodeResourceURL(requestPath);

if (!resourceURL.contains("?")) {
modulePathsDelimiter = "?";
}
}
}

return ExpressionUtil.filterExpressions(text, resourceHandlerChain, externalContext);
return modulePathsDelimiter;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
;(function() {
window.YUI_config = {
base: "#{resource['liferay-faces-alloy-reslib:script']}&",
base: "#{resource['liferay-faces-alloy-reslib:script']}#{scriptModulePathsDelimiter}",
combine: true,
comboBase: "#{resource['liferay-faces-alloy-reslib:combo']}&",
comboBase: "#{resource['liferay-faces-alloy-reslib:combo']}#{comboModulePathsDelimiter}",
root: 'build/',
};
})();
Expand Down

0 comments on commit 9542656

Please sign in to comment.