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();
}
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();
}
}
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);
}
}
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();
}
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);
}
}
Aggregations