Search in sources :

Example 1 with ConfiguredServlet

use of com.liferay.faces.util.config.ConfiguredServlet in project liferay-faces-bridge-impl by liferay.

the class ResourceValidatorBridgeImpl method isSelfReferencing.

@Override
public boolean isSelfReferencing(FacesContext facesContext, String resourceId) {
    ExternalContext externalContext = facesContext.getExternalContext();
    final Product PLUTO = ProductFactory.getProductInstance(externalContext, Product.Name.PLUTO);
    // If the delegation chain indicates that the specified resource is not self-referencing, then
    boolean selfReferencing = super.isSelfReferencing(facesContext, resourceId);
    if (PLUTO.isDetected() && (!selfReferencing) && (resourceId != null)) {
        // Process the configured servlet entries in order to determine which ones are portlet invokers.
        Set<String> invokerServletNames = new HashSet<String>();
        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 : Product(com.liferay.faces.util.product.Product) 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)

Example 2 with ConfiguredServlet

use of com.liferay.faces.util.config.ConfiguredServlet 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 3 with ConfiguredServlet

use of com.liferay.faces.util.config.ConfiguredServlet 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)3 ConfiguredServlet (com.liferay.faces.util.config.ConfiguredServlet)3 WebConfig (com.liferay.faces.util.config.WebConfig)3 ConfiguredServletMapping (com.liferay.faces.util.config.ConfiguredServletMapping)2 HashSet (java.util.HashSet)2 ExternalContext (javax.faces.context.ExternalContext)2 MultiPartConfig (com.liferay.faces.util.config.MultiPartConfig)1 Product (com.liferay.faces.util.product.Product)1