Author: chris.laprun(a)jboss.com
Date: 2010-10-14 21:59:25 -0400 (Thu, 14 Oct 2010)
New Revision: 4674
Modified:
portal/trunk/pom.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
Log:
- Updated to use PC 2.2.0-BETA06-SNAPSHOT and adapted to CacheLevel changes.
- GTNWSRP-97: retrieve WSRP-specific parameters from servlet request and set them as
attributes of the invocation so that they can be used by the WSRP component. This is
needed when the consumer uses templates.
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-10-15 01:53:39 UTC (rev 4673)
+++ portal/trunk/pom.xml 2010-10-15 01:59:25 UTC (rev 4674)
@@ -46,7 +46,7 @@
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.3-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.2-GA</org.gatein.wci.version>
- <org.gatein.pc.version>2.2.0-Beta05</org.gatein.pc.version>
+ <org.gatein.pc.version>2.2.0-Beta06-SNAPSHOT</org.gatein.pc.version>
<org.picketlink.idm>1.1.6.GA</org.picketlink.idm>
<org.gatein.wsrp.version>2.0.0-Beta02-SNAPSHOT</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-15
01:53:39 UTC (rev 4673)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-10-15
01:59:25 UTC (rev 4674)
@@ -79,6 +79,11 @@
import org.gatein.pc.portlet.impl.spi.AbstractServerContext;
import org.gatein.pc.portlet.impl.spi.AbstractWindowContext;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -89,16 +94,10 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
-import java.util.Map.Entry;
-import javax.portlet.PortletMode;
-import javax.portlet.WindowState;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.namespace.QName;
-
/** May 19, 2006 */
@ComponentConfig(lifecycle = UIPortletLifecycle.class, template =
"system:/groovy/portal/webui/application/UIPortlet.gtmpl", events = {
@EventConfig(listeners = RenderActionListener.class),
@@ -115,6 +114,10 @@
protected static final Log log = ExoLogger.getLogger("portal:UIPortlet");
static final public String DEFAULT_THEME =
"Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme";
+ private static final String WSRP_URL = "wsrp-url";
+ private static final String WSRP_PREFER_OPERATION = "wsrp-preferOperation";
+ private static final String WSRP_REQUIRES_REWRITE = "wsrp-requiresRewrite";
+ private static final String WSRP_NAVIGATIONAL_VALUES =
"wsrp-navigationalValues";
/** . */
private String storageId;
@@ -162,9 +165,9 @@
private StateString navigationalState;
- /** A field storing localized value of javax.portlet.title **/
+ /** A field storing localized value of javax.portlet.title * */
private String configuredTitle;
-
+
public UIPortlet()
{
// That value will be overriden when it is mapped onto a data storage
@@ -661,7 +664,7 @@
Map<String, String[]> publicParams = uiPortal.getPublicParameters();
Set<String> allPublicParamsNames = publicParams.keySet();
List<String> supportedPublicParamNames = getPublicRenderParamNames();
-
+
for (String oneOfAllParams : allPublicParamsNames)
{
if (supportedPublicParamNames.contains(oneOfAllParams))
@@ -669,14 +672,14 @@
publicParamsMap.put(oneOfAllParams, publicParams.get(oneOfAllParams));
}
}
-
+
// Handle exposed portal contextual properties
ContextualPropertyManager propertyManager =
this.getApplicationComponent(ContextualPropertyManager.class);
Map<QName, String[]> exposedPortalState =
propertyManager.getProperties(this);
- for(QName prpQName : exposedPortalState.keySet())
+ for (QName prpQName : exposedPortalState.keySet())
{
String prpId = supportsPublicParam(prpQName);
- if(prpId != null)
+ if (prpId != null)
{
publicParamsMap.put(prpId, exposedPortalState.get(prpQName));
}
@@ -711,7 +714,6 @@
if (type.equals(ActionInvocation.class))
{
ActionInvocation actionInvocation = new ActionInvocation(pic);
- actionInvocation.setForm(allParams);
actionInvocation.setRequestContext(new AbstractRequestContext(servletRequest));
String interactionState =
@@ -719,8 +721,12 @@
if (interactionState != null)
{
actionInvocation.setInteractionState(StateString.create(interactionState));
+ // remove the interaction state from remaining params
+ allParams.remove(ExoPortletInvocationContext.INTERACTION_STATE_PARAM_NAME);
}
+ actionInvocation.setForm(allParams);
+
invocation = type.cast(actionInvocation);
}
else if (type.equals(ResourceInvocation.class))
@@ -729,23 +735,49 @@
resourceInvocation.setRequestContext(new
AbstractRequestContext(servletRequest));
String resourceId =
servletRequest.getParameter(Constants.RESOURCE_ID_PARAMETER);
- if (resourceId != null)
+ if (!ParameterValidation.isNullOrEmpty(resourceId))
{
resourceInvocation.setResourceId(resourceId);
}
String cachability =
servletRequest.getParameter(Constants.CACHELEVEL_PARAMETER);
- if (cachability != null)
+ if (!ParameterValidation.isNullOrEmpty(cachability))
{
- resourceInvocation.setCacheLevel(CacheLevel.valueOf(cachability));
+ // we need to convert the given value to upper case as it might come from
WSRP in lower case
+
resourceInvocation.setCacheLevel(CacheLevel.create(cachability.toUpperCase(Locale.ENGLISH)));
}
String resourceState =
servletRequest.getParameter(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
- if (resourceState != null)
+ if (!ParameterValidation.isNullOrEmpty(resourceState))
{
resourceInvocation.setResourceState(StateString.create(resourceState));
}
+ // remove the resource state from remaining params
+ allParams.remove(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
+ // deal with WSRP-specific parameters: add them to the invocation attributes if
they exist and remove them from form params
+ String url = servletRequest.getParameter(WSRP_URL);
+ if (!ParameterValidation.isNullOrEmpty(url))
+ {
+ resourceInvocation.setAttribute(WSRP_URL, url);
+ }
+ allParams.remove(WSRP_URL);
+
+ String preferOperation = servletRequest.getParameter(WSRP_PREFER_OPERATION);
+ if (!ParameterValidation.isNullOrEmpty(preferOperation))
+ {
+ resourceInvocation.setAttribute(WSRP_PREFER_OPERATION, preferOperation);
+ }
+ allParams.remove(WSRP_PREFER_OPERATION);
+
+ String requiresRewrite = servletRequest.getParameter(WSRP_REQUIRES_REWRITE);
+ if (!ParameterValidation.isNullOrEmpty(requiresRewrite))
+ {
+ resourceInvocation.setAttribute(WSRP_REQUIRES_REWRITE, requiresRewrite);
+ }
+ allParams.remove(WSRP_REQUIRES_REWRITE);
+ // End WSRP-specific parameters handling
+
resourceInvocation.setForm(allParams);
invocation = type.cast(resourceInvocation);
@@ -766,9 +798,19 @@
// Navigational state
invocation.setNavigationalState(navigationalState);
- // Public navigational state
+ // Public navigational state
invocation.setPublicNavigationalState(this.getPublicParameters());
+ // WSRP-specific public navigational state handling needed when we have a URL
coming from template
+ String navigationalValues = servletRequest.getParameter(WSRP_NAVIGATIONAL_VALUES);
+ if(!ParameterValidation.isNullOrEmpty(navigationalValues))
+ {
+ // add to the invocation attributes so that it can be retrieved and used by the
WSRP component
+ invocation.setAttribute(WSRP_NAVIGATIONAL_VALUES, navigationalValues);
+ }
+ allParams.remove(WSRP_NAVIGATIONAL_VALUES);
+ // End WSRP-specific public navigational state handling
+
// Mode
invocation.setMode(Mode.create(getCurrentPortletMode().toString()));
@@ -777,7 +819,7 @@
StatefulPortletContext<C> preferencesPortletContext = getPortletContext();
if (preferencesPortletContext == null)
- {
+ {
return null;
}
@@ -866,22 +908,24 @@
ModelAdapter<S, C> adapter =
ModelAdapter.getAdapter(state.getApplicationType());
PortletContext producerOfferedPortletContext =
adapter.getProducerOfferedPortletContext(applicationId);
org.gatein.pc.api.Portlet producedOfferedPortlet;
-
+
try
{
- producedOfferedPortlet =
portletInvoker.getPortlet(producerOfferedPortletContext);
+ producedOfferedPortlet =
portletInvoker.getPortlet(producerOfferedPortletContext);
}
catch (NoSuchPortletException nspe)
{
- producedOfferedPortlet = null;
- nspe.printStackTrace();
+ producedOfferedPortlet = null;
+ nspe.printStackTrace();
}
-
+
this.adapter = adapter;
this.producerOfferedPortletContext = producerOfferedPortletContext;
this.producedOfferedPortlet = producedOfferedPortlet;
this.applicationId = applicationId;
- } catch(NoSuchDataException de){
+ }
+ catch (NoSuchDataException de)
+ {
log.error(de.getMessage());
throw de;
}
@@ -973,37 +1017,38 @@
{
this.navigationalState = navigationalState;
}
-
+
protected void setConfiguredTitle(String _configuredTitle)
{
- this.configuredTitle = _configuredTitle;
+ this.configuredTitle = _configuredTitle;
}
-
+
/**
* Returns the title showed on the InfoBar. The title is computed in following
manner.
- *
- * 1. First, the method getTitle(), inherited from UIPortalComponent is called. The
getTitle() returns
- * what users set in the PortletSetting tab, the current method returns call result if
it is not null.
- *
+ * <p/>
+ * 1. First, the method getTitle(), inherited from UIPortalComponent is called. The
getTitle() returns what users set
+ * in the PortletSetting tab, the current method returns call result if it is not
null.
+ * <p/>
* 2. configuredTitle, which is the localized value of javax.portlet.title is returned
if it is not null.
- *
- * 3. If the method does not terminate at neither (1) nor (2), the configured display
name is returned.
+ * <p/>
+ * 3. If the method does not terminate at neither (1) nor (2), the configured display
name is returned.
+ *
* @return
*/
public String getDisplayTitle()
{
- String displayedTitle = getTitle();
- if(displayedTitle != null && displayedTitle.trim().length() > 0)
- {
- return displayedTitle;
- }
-
- if(configuredTitle != null)
- {
- return configuredTitle;
- }
-
- return getDisplayName();
-
+ String displayedTitle = getTitle();
+ if (displayedTitle != null && displayedTitle.trim().length() > 0)
+ {
+ return displayedTitle;
+ }
+
+ if (configuredTitle != null)
+ {
+ return configuredTitle;
+ }
+
+ return getDisplayName();
+
}
}
\ No newline at end of file