Search in sources :

Example 1 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-alloy by liferay.

the class ScriptsEncoderAlloyImpl method allowLiferayToHandleScripts.

private static boolean allowLiferayToHandleScripts(FacesContext facesContext) {
    ExternalContext externalContext = facesContext.getExternalContext();
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
    final Product LIFERAY_FACES_BRIDGE = productFactory.getProductInfo(Product.Name.LIFERAY_FACES_BRIDGE);
    return LIFERAY_PORTAL.isDetected() && LIFERAY_FACES_BRIDGE.isDetected();
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) ExternalContext(javax.faces.context.ExternalContext) Product(com.liferay.faces.util.product.Product)

Example 2 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.

the class PreDestroyInvokerFactoryImpl method getPreDestroyInvoker.

@Override
public PreDestroyInvoker getPreDestroyInvoker(ServletContext servletContext) {
    PortletContextAdapter portletContextAdapter = new PortletContextAdapter(servletContext);
    ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContextAdapter, ProductFactory.class);
    final Product MOJARRA = productFactory.getProductInfo(Product.Name.MOJARRA);
    if (MOJARRA.isDetected()) {
        return new PreDestroyInvokerMojarraImpl(servletContext);
    } else {
        return new PreDestroyInvokerImpl();
    }
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product) PortletContextAdapter(com.liferay.faces.bridge.context.internal.PortletContextAdapter)

Example 3 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.

the class BridgeDependencyVerifier method verify.

public static void verify(ExternalContext externalContext) {
    Package bridgePackage = BridgeDependencyVerifier.class.getPackage();
    String implementationTitle = bridgePackage.getImplementationTitle();
    String implementationVersion = bridgePackage.getImplementationVersion();
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
    if (LIFERAY_PORTAL.isDetected()) {
        final Product LIFERAY_FACES_BRIDGE_EXT = productFactory.getProductInfo(Product.Name.LIFERAY_FACES_BRIDGE_EXT);
        if (!LIFERAY_FACES_BRIDGE_EXT.isDetected()) {
            logger.error("{0} {1} is running in Liferay Portal {2}.{3} but the com.liferay.faces.bridge.ext.jar dependency is not in the classpath", implementationTitle, implementationVersion, LIFERAY_PORTAL.getMajorVersion(), LIFERAY_PORTAL.getMinorVersion());
        }
    }
    final Product PORTLET_API = productFactory.getProductInfo(Product.Name.PORTLET_API);
    final int PORTLET_API_MAJOR_VERSION = PORTLET_API.getMajorVersion();
    final int PORTLET_API_MINOR_VERSION = PORTLET_API.getMinorVersion();
    if (!((PORTLET_API_MAJOR_VERSION > 3) || ((PORTLET_API_MAJOR_VERSION == 3) && (PORTLET_API_MINOR_VERSION >= 0)))) {
        logger.error("{0} {1} is designed to be used with Portlet 3.0+ but detected {2}.{3}", implementationTitle, implementationVersion, PORTLET_API_MAJOR_VERSION, PORTLET_API_MINOR_VERSION);
    }
    final Product JSF = productFactory.getProductInfo(Product.Name.JSF);
    final int JSF_MAJOR_VERSION = JSF.getMajorVersion();
    final int JSF_MINOR_VERSION = JSF.getMinorVersion();
    if (!((JSF_MAJOR_VERSION == 2) && (JSF_MINOR_VERSION == 3))) {
        logger.error("{0} {1} is designed to be used with JSF 2.3 but detected {2}.{3}", implementationTitle, implementationVersion, JSF_MAJOR_VERSION, JSF_MINOR_VERSION);
    }
    String lsv485PatchVersion = externalContext.getInitParameter("com.liferay.faces.lsv.485.patch.version");
    if ((lsv485PatchVersion != null) && !lsv485PatchVersion.equals("")) {
        logger.error("{0} {1} contains fixes for LSV-485 so it is incompatible with com.liferay.faces.lsv.485.patch.jar. Please remove com.liferay.faces.lsv.485.patch.jar from the classpath.", implementationTitle, implementationVersion);
    }
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product)

Example 4 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.

the class BridgePortletRequestFactoryTCKResinImpl method isResinDetected.

@Override
protected boolean isResinDetected(PortletConfig portletConfig) {
    PortletContext portletContext = portletConfig.getPortletContext();
    ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
    final Product RESIN = productFactory.getProductInfo(Product.Name.RESIN);
    return RESIN.isDetected();
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) Product(com.liferay.faces.util.product.Product) PortletContext(javax.portlet.PortletContext)

Example 5 with ProductFactory

use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.

the class ViewDeclarationLanguageBridgeJspImpl method buildView.

@Override
public void buildView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException {
    ExternalContext externalContext = facesContext.getExternalContext();
    ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
    final Product MYFACES = productFactory.getProductInfo(Product.Name.MYFACES);
    final boolean MYFACES_DETECTED = MYFACES.isDetected();
    PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
    PortletResponse portletResponse = (PortletResponse) externalContext.getResponse();
    // adapter that implements HttpServletRequest.
    if (MYFACES_DETECTED) {
        if (portletRequest instanceof HeaderRequest) {
            String requestCharacterEncoding = externalContext.getRequestCharacterEncoding();
            externalContext.setRequest(new HeaderRequestHttpServletAdapter((HeaderRequest) portletRequest, requestCharacterEncoding));
        } else if (portletRequest instanceof ResourceRequest) {
            externalContext.setRequest(new ResourceRequestHttpServletAdapter((ResourceRequest) portletRequest));
        }
    }
    final Product MOJARRA = productFactory.getProductInfo(Product.Name.MOJARRA);
    final boolean MOJARRA_DETECTED = MOJARRA.isDetected();
    // PortletResponse with an adapter that implements HttpServletResponse.
    if (MOJARRA_DETECTED || MYFACES_DETECTED) {
        if (portletResponse instanceof HeaderResponse) {
            externalContext.setResponse(new HeaderResponseHttpServletAdapter((HeaderResponse) portletResponse));
        } else if (portletResponse instanceof ResourceResponse) {
            externalContext.setResponse(new ResourceResponseHttpServletAdapter((ResourceResponse) portletResponse));
        }
    }
    // Delegate
    super.buildView(facesContext, uiViewRoot);
    // If Mojarra or MyFaces is detected, then un-decorate the PortletRequest.
    if (MOJARRA_DETECTED || MYFACES_DETECTED) {
        externalContext.setResponse(portletResponse);
    }
    // If MyFaces is detected, then un-decorate the PortletResponse.
    if (MYFACES_DETECTED) {
        externalContext.setRequest(portletRequest);
    }
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) ResourceResponseHttpServletAdapter(com.liferay.faces.bridge.filter.internal.ResourceResponseHttpServletAdapter) PortletResponse(javax.portlet.PortletResponse) Product(com.liferay.faces.util.product.Product) ResourceRequestHttpServletAdapter(com.liferay.faces.bridge.filter.internal.ResourceRequestHttpServletAdapter) HeaderResponseHttpServletAdapter(com.liferay.faces.bridge.filter.internal.HeaderResponseHttpServletAdapter) HeaderResponse(javax.portlet.HeaderResponse) PortletRequest(javax.portlet.PortletRequest) HeaderRequestHttpServletAdapter(com.liferay.faces.bridge.filter.internal.HeaderRequestHttpServletAdapter) ResourceResponse(javax.portlet.ResourceResponse) ExternalContext(javax.faces.context.ExternalContext) HeaderRequest(javax.portlet.HeaderRequest) ResourceRequest(javax.portlet.ResourceRequest)

Aggregations

ProductFactory (com.liferay.faces.util.product.ProductFactory)14 Product (com.liferay.faces.util.product.Product)12 ExternalContext (javax.faces.context.ExternalContext)5 PortletContext (javax.portlet.PortletContext)4 FacesRequestParameterMap (com.liferay.faces.util.context.map.FacesRequestParameterMap)2 MultiPartFormData (com.liferay.faces.util.context.map.MultiPartFormData)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FacesContext (javax.faces.context.FacesContext)2 PortletSession (javax.portlet.PortletSession)2 PortletContextAdapter (com.liferay.faces.bridge.context.internal.PortletContextAdapter)1 HeaderRequestHttpServletAdapter (com.liferay.faces.bridge.filter.internal.HeaderRequestHttpServletAdapter)1 HeaderResponseHttpServletAdapter (com.liferay.faces.bridge.filter.internal.HeaderResponseHttpServletAdapter)1 ResourceRequestHttpServletAdapter (com.liferay.faces.bridge.filter.internal.ResourceRequestHttpServletAdapter)1 ResourceResponseHttpServletAdapter (com.liferay.faces.bridge.filter.internal.ResourceResponseHttpServletAdapter)1 UploadedFile (com.liferay.faces.bridge.model.UploadedFile)1 UploadedFileBridgeImpl (com.liferay.faces.bridge.model.internal.UploadedFileBridgeImpl)1 FileUploadRendererPortletImpl (com.liferay.faces.bridge.renderkit.bridge.internal.FileUploadRendererPortletImpl)1 HeadRendererICEfacesImpl (com.liferay.faces.bridge.renderkit.icefaces.internal.HeadRendererICEfacesImpl)1 FormRendererPrimeFacesImpl (com.liferay.faces.bridge.renderkit.primefaces.internal.FormRendererPrimeFacesImpl)1