use of com.liferay.faces.bridge.context.internal.LegacyBridgeContext in project liferay-faces-bridge-impl by liferay.
the class ELResolverImpl method resolveVariable.
@Override
protected Object resolveVariable(ELContext elContext, String varName) {
Object value = null;
if (varName != null) {
if (varName.equals(ACTION_REQUEST)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
value = getPortletRequest(facesContext);
} else {
throw new ELException("Unable to get actionRequest during " + portletPhase);
}
} else if (varName.equals(ACTION_RESPONSE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.ACTION_PHASE) {
value = getPortletResponse(facesContext);
} else {
throw new ELException("Unable to get actionResponse during " + portletPhase);
}
} else if (varName.equals(BRIDGE_CONFIG) || varName.equals(BRIDGE_CONTEXT) || varName.equals(PORTLET_CONFIG)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
BridgeConfig bridgeConfig = RequestMapUtil.getBridgeConfig(portletRequest);
if (varName.equals(BRIDGE_CONFIG)) {
value = bridgeConfig;
} else if (varName.equals(PORTLET_CONFIG)) {
value = unwrapPortletConfig(RequestMapUtil.getPortletConfig(portletRequest));
} else {
value = new LegacyBridgeContext(bridgeConfig);
}
} else if (varName.equals(EVENT_REQUEST)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.EVENT_PHASE) {
value = getPortletRequest(facesContext);
} else {
throw new ELException("Unable to get eventRequest during " + portletPhase);
}
} else if (varName.equals(EVENT_RESPONSE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.EVENT_PHASE) {
value = getPortletResponse(facesContext);
} else {
throw new ELException("Unable to get eventResponse during " + portletPhase);
}
} else if (varName.equals(FLASH)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
value = getFlash(facesContext);
} else if (varName.equals(HTTP_SESSION_SCOPE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
PortletSession portletSession = (PortletSession) externalContext.getSession(true);
PortletConfig portletConfig = RequestMapUtil.getPortletConfig(portletRequest);
PortletContext portletContext = portletConfig.getPortletContext();
boolean preferPreDestroy = PortletConfigParam.PreferPreDestroy.getBooleanValue(portletConfig);
ContextMapFactory contextMapFactory = (ContextMapFactory) BridgeFactoryFinder.getFactory(portletContext, ContextMapFactory.class);
value = contextMapFactory.getSessionScopeMap(portletContext, portletSession, PortletSession.APPLICATION_SCOPE, preferPreDestroy);
} else if (varName.equals(MUTABLE_PORTLET_PREFERENCES_VALUES)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest portletRequest = getPortletRequest(facesContext);
if (portletRequest != null) {
value = new MutablePreferenceMap(portletRequest.getPreferences());
}
} else if (varName.equals(PORTLET_SESSION)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
value = facesContext.getExternalContext().getSession(true);
} else if (varName.equals(PORTLET_SESSION_SCOPE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
value = facesContext.getExternalContext().getSessionMap();
} else if (varName.equals(PORTLET_PREFERENCES)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest portletRequest = getPortletRequest(facesContext);
if (portletRequest != null) {
value = portletRequest.getPreferences();
}
} else if (varName.equals(PORTLET_PREFERENCES_VALUES)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
PortletRequest portletRequest = getPortletRequest(facesContext);
if (portletRequest != null) {
value = portletRequest.getPreferences().getMap();
}
} else if (varName.equals(RENDER_REQUEST)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if ((portletPhase == Bridge.PortletPhase.HEADER_PHASE) || (portletPhase == Bridge.PortletPhase.RENDER_PHASE)) {
value = getPortletRequest(facesContext);
} else {
throw new ELException("Unable to get renderRequest during " + portletPhase);
}
} else if (varName.equals(RENDER_RESPONSE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if ((portletPhase == Bridge.PortletPhase.HEADER_PHASE) || (portletPhase == Bridge.PortletPhase.RENDER_PHASE)) {
value = getPortletResponse(facesContext);
} else {
throw new ELException("Unable to get renderResponse during " + portletPhase);
}
} else if (varName.equals(RESOURCE_REQUEST)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.RESOURCE_PHASE) {
value = getPortletRequest(facesContext);
} else {
throw new ELException("Unable to get resourceRequest during " + portletPhase);
}
} else if (varName.equals(RESOURCE_RESPONSE)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.RESOURCE_PHASE) {
value = getPortletResponse(facesContext);
} else {
throw new ELException("Unable to get renderResponse during " + portletPhase);
}
} else {
value = super.resolveVariable(elContext, varName);
}
}
return value;
}
Aggregations