Search in sources :

Example 6 with ApplicationConfig

use of com.liferay.faces.util.config.ApplicationConfig in project liferay-faces-alloy by liferay.

the class InputFileDecoderBase method getFacesServletMultiPartConfig.

protected MultiPartConfig getFacesServletMultiPartConfig(ExternalContext externalContext) {
    MultiPartConfig facesServletMultiPartConfig = null;
    String appConfigAttrName = ApplicationConfig.class.getName();
    Map<String, Object> applicationMap = externalContext.getApplicationMap();
    ApplicationConfig applicationConfig = (ApplicationConfig) applicationMap.get(appConfigAttrName);
    WebConfig webConfig = applicationConfig.getWebConfig();
    List<ConfiguredServlet> configuredServlets = webConfig.getConfiguredServlets();
    for (ConfiguredServlet configuredServlet : configuredServlets) {
        if (FACES_SERVLET_FQCN.equals(configuredServlet.getServletClass())) {
            facesServletMultiPartConfig = configuredServlet.getMultiPartConfig();
        }
    }
    return facesServletMultiPartConfig;
}
Also used : MultiPartConfig(com.liferay.faces.util.config.MultiPartConfig) ApplicationConfig(com.liferay.faces.util.config.ApplicationConfig) WebConfig(com.liferay.faces.util.config.WebConfig) ConfiguredServlet(com.liferay.faces.util.config.ConfiguredServlet)

Example 7 with ApplicationConfig

use of com.liferay.faces.util.config.ApplicationConfig in project liferay-faces-alloy by liferay.

the class ResLibResourceHandler method getResourceName.

protected String getResourceName(ExternalContext externalContext) {
    // Attempt to get the resource name from the "javax.faces.resource" request parameter. If it exists, then
    // this is probably a non-Liferay portlet environment like Pluto.
    String resourceName = externalContext.getRequestParameterMap().get("javax.faces.resource");
    if (resourceName == null) {
        // If the specified request was extension-mapped (suffix-mapped), then determine the resource name based
        // on the configured mappings to the Faces Servlet.
        Object request = externalContext.getRequest();
        if (request instanceof HttpServletRequest) {
            HttpServletRequest httpServletRequest = (HttpServletRequest) request;
            String servletPath = httpServletRequest.getServletPath();
            if ((servletPath != null) && servletPath.startsWith(RESOURCE_IDENTIFIER)) {
                Map<String, Object> applicationMap = externalContext.getApplicationMap();
                String appConfigAttrName = ApplicationConfig.class.getName();
                ApplicationConfig applicationConfig = (ApplicationConfig) applicationMap.get(appConfigAttrName);
                FacesConfig facesConfig = applicationConfig.getFacesConfig();
                List<ConfiguredServletMapping> configuredFacesServletMappings = facesConfig.getConfiguredFacesServletMappings();
                resourceName = servletPath.substring(RESOURCE_IDENTIFIER.length() + 1);
                for (ConfiguredServletMapping configuredFacesServletMapping : configuredFacesServletMappings) {
                    String configuredExtension = configuredFacesServletMapping.getExtension();
                    if (servletPath.endsWith(configuredExtension)) {
                        resourceName = resourceName.substring(0, resourceName.length() - configuredExtension.length());
                        break;
                    }
                }
            } else // Otherwise, it must be path-mapped.
            {
                resourceName = httpServletRequest.getPathInfo();
            }
        }
    }
    return resourceName;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FacesConfig(com.liferay.faces.util.config.FacesConfig) ApplicationConfig(com.liferay.faces.util.config.ApplicationConfig) ConfiguredServletMapping(com.liferay.faces.util.config.ConfiguredServletMapping)

Example 8 with ApplicationConfig

use of com.liferay.faces.util.config.ApplicationConfig in project liferay-faces-bridge-ext by liferay.

the class ResourceValidatorLiferayImpl method isSelfReferencing.

@Override
public boolean isSelfReferencing(FacesContext facesContext, String resourceId) {
    // If the delegation chain indicates that the specified resource is not self-referencing, then
    boolean selfReferencing = super.isSelfReferencing(facesContext, resourceId);
    if ((!selfReferencing) && (resourceId != null)) {
        // Process the configured servlet entries in order to determine which ones are portlet invokers.
        Set<String> invokerServletNames = new HashSet<String>();
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, Object> applicationMap = externalContext.getApplicationMap();
        ApplicationConfig applicationConfig = (ApplicationConfig) applicationMap.get(ApplicationConfig.class.getName());
        WebConfig webConfig = applicationConfig.getWebConfig();
        List<ConfiguredServlet> configuredServlets = webConfig.getConfiguredServlets();
        for (ConfiguredServlet configuredServlet : configuredServlets) {
            String configuredServletClass = configuredServlet.getServletClass();
            if (isInvokerServletClass(configuredServletClass)) {
                invokerServletNames.add(configuredServlet.getServletName());
            }
        }
        // For each of the servlet-mapping entries:
        List<ConfiguredServletMapping> configuredServletMappings = webConfig.getConfiguredServletMappings();
        for (ConfiguredServletMapping configuredServletMapping : configuredServletMappings) {
            // Determine whether or not the current servlet-mapping is mapped to a portlet invoker servlet-class.
            if (invokerServletNames.contains(configuredServletMapping.getServletName())) {
                if (configuredServletMapping.isMatch(resourceId)) {
                    selfReferencing = true;
                    break;
                }
            }
        }
    }
    return selfReferencing;
}
Also used : WebConfig(com.liferay.faces.util.config.WebConfig) ApplicationConfig(com.liferay.faces.util.config.ApplicationConfig) ExternalContext(javax.faces.context.ExternalContext) ConfiguredServlet(com.liferay.faces.util.config.ConfiguredServlet) ConfiguredServletMapping(com.liferay.faces.util.config.ConfiguredServletMapping) HashSet(java.util.HashSet)

Aggregations

ApplicationConfig (com.liferay.faces.util.config.ApplicationConfig)8 ExternalContext (javax.faces.context.ExternalContext)4 ConfiguredServlet (com.liferay.faces.util.config.ConfiguredServlet)3 ConfiguredServletMapping (com.liferay.faces.util.config.ConfiguredServletMapping)3 WebConfig (com.liferay.faces.util.config.WebConfig)3 BeanManager (com.liferay.faces.bridge.bean.BeanManager)2 BeanManagerFactory (com.liferay.faces.bridge.bean.BeanManagerFactory)2 FacesConfig (com.liferay.faces.util.config.FacesConfig)2 HashSet (java.util.HashSet)2 PortletContext (javax.portlet.PortletContext)2 PreDestroyInvoker (com.liferay.faces.bridge.bean.PreDestroyInvoker)1 PreDestroyInvokerFactory (com.liferay.faces.bridge.bean.PreDestroyInvokerFactory)1 PortletContextAdapter (com.liferay.faces.bridge.context.internal.PortletContextAdapter)1 BridgeRequestScopeManager (com.liferay.faces.bridge.scope.internal.BridgeRequestScopeManager)1 BridgeRequestScopeManagerFactory (com.liferay.faces.bridge.scope.internal.BridgeRequestScopeManagerFactory)1 MultiPartConfig (com.liferay.faces.util.config.MultiPartConfig)1 Product (com.liferay.faces.util.product.Product)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 FacesContext (javax.faces.context.FacesContext)1