use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-impl by liferay.
the class RenderKitBridgeImpl method getRenderer.
@Override
public Renderer getRenderer(String family, String rendererType) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
final Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
final boolean PRIMEFACES_DETECTED = PRIMEFACES.isDetected();
Renderer renderer = super.getRenderer(family, rendererType);
if (UIOutput.COMPONENT_FAMILY.equals(family)) {
if (JAVAX_FACES_HEAD.equals(rendererType)) {
final Product ICEFACES = productFactory.getProductInfo(Product.Name.ICEFACES);
final boolean ICEFACES_DETECTED = ICEFACES.isDetected();
if (ICEFACES_DETECTED) {
renderer = new HeadRendererICEfacesImpl();
} else if (PRIMEFACES_DETECTED) {
renderer = new HeadRendererPrimeFacesImpl();
} else {
renderer = new HeadRendererBridgeImpl();
}
} else if (JAVAX_FACES_BODY.equals(rendererType)) {
renderer = new BodyRendererBridgeImpl(renderer);
} else if (RenderKitUtil.SCRIPT_RENDERER_TYPE.equals(rendererType) || RenderKitUtil.STYLESHEET_RENDERER_TYPE.equals(rendererType)) {
renderer = new ResourceRendererBridgeImpl(renderer);
}
} else if (UIForm.COMPONENT_FAMILY.equals(family) && JAVAX_FACES_FORM.equals(rendererType) && PRIMEFACES_DETECTED) {
renderer = new FormRendererPrimeFacesImpl(PRIMEFACES.getMajorVersion(), PRIMEFACES.getMinorVersion(), renderer);
} else if (PRIMEFACES_FAMILY.equals(family) && PRIMEFACES_FILE_UPLOAD_RENDERER_TYPE.equals(rendererType)) {
renderer = new FileUploadRendererPortletImpl(renderer);
} else if (RICHFACES_FILE_UPLOAD_FAMILY.equals(family) && RICHFACES_FILE_UPLOAD_RENDERER_TYPE.equals(rendererType)) {
renderer = new FileUploadRendererPortletImpl(new FileUploadRendererRichFacesImpl(renderer));
}
return renderer;
}
use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.
the class ResourceHandlerLiferayImpl method isJQueryPluginJSResource.
private boolean isJQueryPluginJSResource(String resourceLibrary, String resourceName) {
FacesContext startupFacesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = startupFacesContext.getExternalContext();
ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
final Product BOOTSFACES = productFactory.getProductInfo(Product.Name.BOOTSFACES);
boolean bootsFacesJQueryPluginJSResource = BOOTSFACES.isDetected() && "bsf".equals(resourceLibrary) && BOOTSFACES_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName);
boolean butterFacesJQueryPluginJSResource = false;
final Product BUTTERFACES = productFactory.getProductInfo(Product.Name.BUTTERFACES);
if (BUTTERFACES.isDetected() && (resourceLibrary != null)) {
butterFacesJQueryPluginJSResource = (resourceLibrary.equals("butterfaces-dist-bower") && BUTTERFACES_DIST_BOWER_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName)) || (resourceLibrary.equals("butterfaces-dist-bundle-js") && BUTTERFACES_DIST_BUNDLE_JS_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName)) || (resourceLibrary.equals("butterfaces-external") && BUTTERFACES_EXTERNAL_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName));
}
final Product PRIMEFACES = productFactory.getProductInfo(Product.Name.PRIMEFACES);
boolean primeFacesJQueryPluginJSResource = PRIMEFACES.isDetected() && ((resourceLibrary == null) || resourceLibrary.equals("primefaces")) && PRIMEFACES_JQUERY_PLUGIN_JS_RESOURCES.contains(resourceName);
boolean richFacesJQueryPluginJSResource = false;
final Product RICHFACES = productFactory.getProductInfo(Product.Name.RICHFACES);
if (RICHFACES.isDetected()) {
boolean richfacesResourceLibrary = ("org.richfaces.resource".equals(resourceLibrary) || "org.richfaces.staticResource".equals(resourceLibrary) || "org.richfaces".equals(resourceLibrary));
richFacesJQueryPluginJSResource = ((resourceLibrary == null) || richfacesResourceLibrary) && (resourceName.endsWith("packed.js") || resourceName.endsWith("jquery.js"));
}
return (bootsFacesJQueryPluginJSResource || butterFacesJQueryPluginJSResource || primeFacesJQueryPluginJSResource || richFacesJQueryPluginJSResource);
}
use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.
the class PortletRequestDispatcherBridgeLiferayImpl method include.
@Override
public void include(PortletRequest portletRequest, PortletResponse portletResponse) throws PortletException, IOException {
boolean unwrapRequest = false;
PortletSession portletSession = portletRequest.getPortletSession();
PortletContext portletContext = portletSession.getPortletContext();
ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
final int LIFERAY_PORTAL_MAJOR_VERSION = LIFERAY_PORTAL.getMajorVersion();
// For more info, see https://issues.liferay.com/browse/LPS-3311
if (LIFERAY_PORTAL_MAJOR_VERSION < 6) {
unwrapRequest = true;
} else // https://github.com/liferay/liferay-portal/commit/093dabbb252e2bba5404cddbcb600d787ef0b010
if (LIFERAY_PORTAL_MAJOR_VERSION == 6) {
final int LIFERAY_PORTAL_MINOR_VERSION = LIFERAY_PORTAL.getMinorVersion();
if (LIFERAY_PORTAL_MINOR_VERSION == 0) {
unwrapRequest = true;
} else if (LIFERAY_PORTAL_MINOR_VERSION == 1) {
final int LIFERAY_PORTAL_PATCH_VERSION = LIFERAY_PORTAL.getPatchVersion();
// CE
if (LIFERAY_PORTAL_PATCH_VERSION < 10) {
unwrapRequest = (LIFERAY_PORTAL_PATCH_VERSION < 2);
} else // EE
if (LIFERAY_PORTAL_PATCH_VERSION < 30) {
unwrapRequest = true;
}
}
}
if (unwrapRequest) {
portletRequest = unwrapPortletRequest(portletRequest);
}
// PortletResponseWrapper.
if ((portletResponse instanceof HttpServletResponseWrapper) || (portletResponse instanceof PortletResponseWrapper)) {
portletResponse = unwrapPortletResponse(portletResponse);
}
super.include(portletRequest, portletResponse);
}
use of com.liferay.faces.util.product.ProductFactory in project liferay-faces-bridge-ext by liferay.
the class BridgeExtDependencyVerifier method verify.
public static void verify(ExternalContext externalContext) {
ProductFactory productFactory = (ProductFactory) FactoryExtensionFinder.getFactory(externalContext, ProductFactory.class);
final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
Package bridgeExtPackage = BridgeExtDependencyVerifier.class.getPackage();
String implementationTitle = bridgeExtPackage.getImplementationTitle();
String implementationVersion = bridgeExtPackage.getImplementationVersion();
final int LIFERAY_PORTAL_MAJOR_VERSION = LIFERAY_PORTAL.getMajorVersion();
final int LIFERAY_PORTAL_MINOR_VERSION = LIFERAY_PORTAL.getMinorVersion();
if (!((LIFERAY_PORTAL_MAJOR_VERSION == 7) && (LIFERAY_PORTAL_MINOR_VERSION >= 2))) {
logger.error("{0} {1} is designed to be used with Liferay Portal 7.2+ but detected {2}.{3}", implementationTitle, implementationVersion, LIFERAY_PORTAL_MAJOR_VERSION, LIFERAY_PORTAL_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);
}
}
Aggregations