Author: chris.laprun(a)jboss.com
Date: 2007-02-15 00:55:53 -0500 (Thu, 15 Feb 2007)
New Revision: 6290
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/PortletManagementBehavior.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
Log:
- Added getPreferences implementation in WSRPPortletInfo that was somehow forgotten...
- Fixed potential infinite loop in ProducerInfo.refresh.
- Added support for delayed retrieval of property description.
- Updated tests.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/PortletManagementBehavior.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/PortletManagementBehavior.java 2007-02-15
05:42:58 UTC (rev 6289)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/PortletManagementBehavior.java 2007-02-15
05:55:53 UTC (rev 6290)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.wsrp.framework;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.ClonePortlet;
import org.jboss.portal.wsrp.core.DestroyPortlets;
@@ -92,6 +93,6 @@
throws MissingParametersFault, InconsistentParametersFault,
InvalidUserCategoryFault, InvalidRegistrationFault,
AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
{
- return null;
+ return WSRPTypeFactory.createPortletPropertyDescriptionResponse(null);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-02-15 05:42:58 UTC
(rev 6289)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2007-02-15 05:55:53 UTC
(rev 6290)
@@ -720,8 +720,8 @@
*/
public static PortletPropertyDescriptionResponse
createPortletPropertyDescriptionResponse(PropertyDescription[] propertyDescriptions)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(propertyDescriptions,
"PropertyDescriptions");
- return new
PortletPropertyDescriptionResponse(createModelDescription(propertyDescriptions), null,
null);
+ ModelDescription modelDescription = propertyDescriptions == null ? null :
createModelDescription(propertyDescriptions);
+ return new PortletPropertyDescriptionResponse(modelDescription, null, null);
}
/**
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-02-15
05:42:58 UTC (rev 6289)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-02-15
05:55:53 UTC (rev 6290)
@@ -36,12 +36,15 @@
import org.jboss.portal.wsrp.consumer.portlet.info.WSRPPortletInfo;
import org.jboss.portal.wsrp.core.CookieProtocol;
import org.jboss.portal.wsrp.core.GetPortletDescription;
+import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InvalidHandleFault;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
+import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import java.util.Collections;
import java.util.HashMap;
@@ -175,7 +178,7 @@
}
catch (Exception e)
{
- resetRegistration(false);
+ registrationInfo.resetRegistration();
throw new PortletInvokerException("Couldn't register with
producer '" + producerId + "'", e);
}
@@ -279,7 +282,7 @@
ParameterValidation.throwIllegalArgExceptionIfNull(portletDescription,
"PortletDescription");
String portletHandle = portletDescription.getPortletHandle();
log.debug("Extracting info for '" + portletHandle + "'
portlet");
- WSRPPortletInfo info = new WSRPPortletInfo(portletDescription);
+ WSRPPortletInfo info = new WSRPPortletInfo(portletDescription, this);
WSRPPortlet wsrpPortlet = null;
if (info.isUsesMethodGet())
{
@@ -477,12 +480,45 @@
public void resetRegistration() throws PortletInvokerException
{
- resetRegistration(true);
+ registrationInfo.resetRegistration();
+ refresh(true);
}
- private void resetRegistration(boolean refresh) throws PortletInvokerException
+ // make package only after package reorg
+ public PortletPropertyDescriptionResponse getPropertyDescriptionsFor(String
portletHandle)
{
- registrationInfo.resetRegistration();
- refresh(refresh);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"portlet handle", null);
+ try
+ {
+ WSRP_v1_PortletManagement_PortType service =
getEndpointConfigurationInfo().getPortletManagementService();
+
+ GetPortletPropertyDescription request =
WSRPTypeFactory.createSimpleGetPortletPropertyDescription(portletHandle);
+ request.setRegistrationContext(registrationInfo.getRegistrationContext());
+ request.setUserContext(null); // todo: fix me!
+
+ return service.getPortletPropertyDescription(request);
+ }
+ catch (InvalidHandleFault invalidHandleFault)
+ {
+ throw new IllegalArgumentException("Unknown portlet '" +
portletHandle + "'");
+ }
+ catch (org.jboss.portal.wsrp.core.InvalidRegistrationFault
invalidRegistrationFault)
+ {
+ try
+ {
+ resetRegistration();
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new RuntimeException("Couldn't reset registration", e);
+ }
+ throw new IllegalArgumentException("Couldn't get property descriptions
for portlet '" + portletHandle
+ + "' because the provided registration is invalid!");
+ }
+ catch (Exception e)
+ {
+ log.debug("Couldn't get property descriptions for portlet '" +
portletHandle + "'", e);
+ throw new RuntimeException(e);
+ }
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2007-02-15
05:42:58 UTC (rev 6289)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/WSRPPortlet.java 2007-02-15
05:55:53 UTC (rev 6290)
@@ -54,7 +54,7 @@
public static WSRPPortlet createClone(PortletContext newContext, WSRPPortletInfo
originalInfo)
{
ParameterValidation.throwIllegalArgExceptionIfNull(newContext,
"PortletContext");
- return new WSRPPortlet(newContext, new WSRPPortletInfo(originalInfo));
+ return new WSRPPortlet(newContext, new WSRPPortletInfo(originalInfo,
newContext.getId()));
}
/** Portlet interface implemented methods */
@@ -94,6 +94,6 @@
public String toString()
{
- return "WSRPPortlet[context=" + portletContext + "]";
+ return "WSRPPortlet[context=" + portletContext + "]";
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-02-15
05:42:58 UTC (rev 6289)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-02-15
05:55:53 UTC (rev 6290)
@@ -27,18 +27,24 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.LocaleInfo;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.common.value.Value;
import org.jboss.portal.portlet.info.CacheInfo;
import org.jboss.portal.portlet.info.CapabilitiesInfo;
import org.jboss.portal.portlet.info.MetaInfo;
import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.portlet.info.PreferenceInfo;
import org.jboss.portal.portlet.info.PreferencesInfo;
import org.jboss.portal.portlet.info.SecurityInfo;
import org.jboss.portal.portlet.info.SessionInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
import org.jboss.portal.wsrp.WSRPUtils;
+import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.core.LocalizedString;
import org.jboss.portal.wsrp.core.MarkupType;
+import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.PortletDescription;
+import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import java.util.Collections;
import java.util.HashMap;
@@ -65,22 +71,30 @@
private boolean templatesStoredInSession;
private boolean doesUrlTemplateProcessing;
private String groupId;
+ private PreferencesInfo prefInfo;
+ private ProducerInfo originatingProducer;
+ private String portletHandle;
- public WSRPPortletInfo(final PortletDescription portletDescription)
+ public WSRPPortletInfo(final PortletDescription portletDescription, ProducerInfo
originatingProducerInfo)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletDescription,
"PortletDescription");
+ ParameterValidation.throwIllegalArgExceptionIfNull(originatingProducerInfo,
"ProducerInfo");
createCapabilitiesInfo(portletDescription);
createMetaInfo(portletDescription);
createWSRPInfo(portletDescription);
+
+ this.originatingProducer = originatingProducerInfo;
+ this.portletHandle = portletDescription.getPortletHandle();
}
- public WSRPPortletInfo(WSRPPortletInfo other)
+ public WSRPPortletInfo(WSRPPortletInfo other, String newHandle)
{
ParameterValidation.throwIllegalArgExceptionIfNull(other,
"WSRPPortletInfo");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(newHandle, "new
portlet handle", "WSRPPortletInfo");
usesMethodGet = other.usesMethodGet;
defaultMarkupSecure = other.defaultMarkupSecure;
@@ -98,6 +112,11 @@
WSRPMetaInfo otherMeta = (WSRPMetaInfo)other.getMeta();
metaInfo = new WSRPMetaInfo(new HashMap(otherMeta.metaInfos));
+ WSRPPreferencesInfo otherPref = (WSRPPreferencesInfo)other.getPreferences();
+ prefInfo = new WSRPPreferencesInfo(new HashMap(otherPref.preferences));
+
+ originatingProducer = other.originatingProducer;
+ portletHandle = newHandle;
}
public CapabilitiesInfo getCapabilities()
@@ -105,14 +124,36 @@
return capabilities;
}
- /**
- * Return null for now as the wsrp implementation does not support management.
- *
- * @return null
- */
public PreferencesInfo getPreferences()
{
- return null;
+ // lazy initialization of preference information since it requires an access to
PortletManagement which would be
+ // too bandwidth intensive if it was done when the service description is
parsed...
+ if (prefInfo == null)
+ {
+ PortletPropertyDescriptionResponse propertyDescs =
originatingProducer.getPropertyDescriptionsFor(portletHandle);
+ ModelDescription modelDesc = propertyDescs.getModelDescription();
+ Map prefInfos;
+ if (modelDesc != null)
+ {
+ PropertyDescription[] descs = modelDesc.getPropertyDescriptions();
+ prefInfos = new HashMap(descs.length);
+ for (int i = 0; i < descs.length; i++)
+ {
+ PropertyDescription desc = descs[i];
+ String key = desc.getName();
+ prefInfos.put(key, new WSRPPreferenceInfo(key,
createPortalLocalizedStringFrom(desc.getLabel()),
+ createPortalLocalizedStringFrom(desc.getHint())));
+ }
+ }
+ else
+ {
+ prefInfos = Collections.EMPTY_MAP;
+ }
+
+ prefInfo = new WSRPPreferencesInfo(prefInfos);
+ }
+
+ return prefInfo;
}
public MetaInfo getMeta()
@@ -440,4 +481,63 @@
return (org.jboss.portal.common.util.LocalizedString)metaInfos.get(key);
}
}
+
+ static class WSRPPreferencesInfo implements PreferencesInfo
+ {
+ private Map preferences;
+
+ public WSRPPreferencesInfo(Map preferences)
+ {
+ this.preferences = preferences;
+ }
+
+ public Set getKeys()
+ {
+ return Collections.unmodifiableSet(preferences.entrySet());
+ }
+
+ public PreferenceInfo getPreference(String key) throws IllegalArgumentException
+ {
+ return (PreferenceInfo)preferences.get(key);
+ }
+ }
+
+ static class WSRPPreferenceInfo implements PreferenceInfo
+ {
+ private String key;
+ private org.jboss.portal.common.util.LocalizedString displayName;
+ private org.jboss.portal.common.util.LocalizedString description;
+
+ public WSRPPreferenceInfo(String key, org.jboss.portal.common.util.LocalizedString
displayName, org.jboss.portal.common.util.LocalizedString description)
+ {
+ this.key = key;
+ this.displayName = displayName;
+ this.description = description;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public org.jboss.portal.common.util.LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public org.jboss.portal.common.util.LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public Boolean isReadOnly()
+ {
+ return null; // cannot be determined, so returning null per javadoc
+ }
+
+ public Value getDefaultValue()
+ {
+ return null; // cannot be determined, so returning null per javadoc
+ }
+ }
}