if (null == config) {
throw new NullPointerException(
"No PortletConfig at the bridge initialization");
}
if (initialized) {
throw new BridgeException("JSF portlet bridge already initialized");
}
String portletName = config.getPortletName();
if (log.isLoggable(Level.FINE)) {
log.fine("Start portletbridge initialization for " + portletName);
}
this.portletConfig = config;
PortletContext portletContext = config.getPortletContext();
// add locales to faces application
stateHolder = PortletStateHolder.init(portletContext);
initFaces(portletContext);
transferLocales(config);
exceptionHandler = createExceptionHandler(portletContext);
// Parse web.xml for a Faces Servlet mappings.
WebXML webXml = new WebXML();
webXml.parse(portletContext);
this.facesServletMappings = webXml.getFacesServletMappings();
if (null == facesServletMappings || facesServletMappings.size() == 0) {
throw new BridgeException("Unable to get Faces Servlet mapping");
}
errorPages = webXml.getErrorViews();
// Get defined role names from portlet.xml
PortletXML portletXML = new PortletXML();
portletXML.parse(portletContext);
userRoles = portletXML.getUserRoles(portletName);
// Get all excluded request attributes names.
this.excludedAttributes = new HashSet<ExcludedRequestAttribute>();
String bridgeParametersPrefix = Bridge.BRIDGE_PACKAGE_PREFIX
+ portletName + ".";
List<String> excluded = (List<String>) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
if (null != excluded) {
for (String name : excluded) {
excludedAttributes.add(new ExcludedRequestAttribute(name));
}
}
FacesConfig facesConfig = new FacesConfig();
facesConfig.parse(portletContext);
excluded = facesConfig.getExcludedAttributes();
if (null != excluded) {
for (String name : excluded) {
excludedAttributes.add(new ExcludedRequestAttribute(name));
}
}
// Get preserve action parameters flag
Boolean preserveParams = (Boolean) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.PRESERVE_ACTION_PARAMS);
this.preserveActionParams = Boolean.TRUE.equals(preserveParams);
// Get devault view's Map.
this.defaultViewIdMap = (Map<String, String>) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.DEFAULT_VIEWID_MAP);
if (null == this.defaultViewIdMap || 0 == this.defaultViewIdMap.size()) {
throw new BridgeException("No JSF view id's defined in portlet");
}
// Initialization done.
initialized = true;
if (log.isLoggable(Level.FINE)) {
log.fine("Done portletbridge initialization for " + portletName);