Author: chris.laprun(a)jboss.com
Date: 2007-11-12 15:57:56 -0500 (Mon, 12 Nov 2007)
New Revision: 8887
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
Log:
- Test that getPortlet correctly works if there is no PortletManagement support on the
producer
- Optimize WSRPPortletInfo a little by avoiding to create unnecessary (and costly)
objects. In particular, changed behavior: if info is not present in WSRP, do not create
empty data in MetaInfo.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-11-12
18:28:53 UTC (rev 8886)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/consumer/ProducerInfoTestCase.java 2007-11-12
20:57:56 UTC (rev 8887)
@@ -365,4 +365,4 @@
+ " is not a valid value for " + PROP_NAME, null);
}
}
-}
+}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-11-12
18:28:53 UTC (rev 8886)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/portlet/info/WSRPPortletInfo.java 2007-11-12
20:57:56 UTC (rev 8887)
@@ -59,7 +59,7 @@
public class WSRPPortletInfo implements org.jboss.portal.portlet.info.PortletInfo
{
- private CapabilitiesInfo capabilities;
+ private WSRPCapabilitiesInfo capabilities;
private MetaInfo metaInfo;
private boolean usesMethodGet;
private boolean defaultMarkupSecure;
@@ -144,8 +144,8 @@
{
PropertyDescription desc = descs[i];
String key = desc.getName();
- prefInfos.put(key, new WSRPPreferenceInfo(key,
createPortalLocalizedStringFrom(desc.getLabel()),
- createPortalLocalizedStringFrom(desc.getHint())));
+ prefInfos.put(key, new WSRPPreferenceInfo(key,
getPortalLocalizedStringOrNullFrom(desc.getLabel()),
+ getPortalLocalizedStringOrNullFrom(desc.getHint())));
}
}
else
@@ -252,31 +252,28 @@
{
final MarkupType[] markupTypes = portletDescription.getMarkupTypes();
final Map mimeTypes = new HashMap(markupTypes.length);
- final Set modes = new HashSet();
- final Set windowStates = new HashSet();
- final Set locales = new HashSet();
+ capabilities = new WSRPCapabilitiesInfo();
- for (int i = 0; i < markupTypes.length; i++)
+ for (MarkupType markupType : markupTypes)
{
- MarkupType markupType = markupTypes[i];
String mimeType = markupType.getMimeType();
MIMETypeInfo mimeTypeInfo = new MIMETypeInfo(markupType);
mimeTypes.put(mimeType, mimeTypeInfo);
- modes.addAll(mimeTypeInfo.modes);
- windowStates.addAll(mimeTypeInfo.windowStates);
- locales.addAll(mimeTypeInfo.locales);
+ capabilities.addModes(mimeTypeInfo.modes);
+ capabilities.addWindowStates(mimeTypeInfo.windowStates);
+ capabilities.addLocales(mimeTypeInfo.locales);
}
- capabilities = new WSRPCapabilitiesInfo(mimeTypes, modes, windowStates, locales);
+ capabilities.setMimeTypes(mimeTypes);
}
private void createMetaInfo(PortletDescription portletDescription)
{
final Map metaInfos = new HashMap();
- metaInfos.put(MetaInfo.DESCRIPTION,
createPortalLocalizedStringFrom(portletDescription.getDescription()));
- metaInfos.put(MetaInfo.DISPLAY_NAME,
createPortalLocalizedStringFrom(portletDescription.getDisplayName()));
- metaInfos.put(MetaInfo.SHORT_TITLE,
createPortalLocalizedStringFrom(portletDescription.getShortTitle()));
- metaInfos.put(MetaInfo.TITLE,
createPortalLocalizedStringFrom(portletDescription.getTitle()));
+ metaInfos.put(MetaInfo.DESCRIPTION,
getPortalLocalizedStringOrNullFrom(portletDescription.getDescription()));
+ metaInfos.put(MetaInfo.DISPLAY_NAME,
getPortalLocalizedStringOrNullFrom(portletDescription.getDisplayName()));
+ metaInfos.put(MetaInfo.SHORT_TITLE,
getPortalLocalizedStringOrNullFrom(portletDescription.getShortTitle()));
+ metaInfos.put(MetaInfo.TITLE,
getPortalLocalizedStringOrNullFrom(portletDescription.getTitle()));
// keywords need to be concatenated
LocalizedString[] keywords = portletDescription.getKeywords();
@@ -308,15 +305,15 @@
metaInfo = new WSRPMetaInfo(metaInfos);
}
- private org.jboss.portal.common.i18n.LocalizedString
createPortalLocalizedStringFrom(LocalizedString wsrpLocalizedString)
+ private org.jboss.portal.common.i18n.LocalizedString
getPortalLocalizedStringOrNullFrom(LocalizedString wsrpLocalizedString)
{
- if (wsrpLocalizedString == null)
+ if (wsrpLocalizedString != null)
{
- return new org.jboss.portal.common.i18n.LocalizedString(Locale.ENGLISH);
+ return new
org.jboss.portal.common.i18n.LocalizedString(wsrpLocalizedString.getValue(),
+ WSRPUtils.getLocale(wsrpLocalizedString.getLang()));
}
- return new
org.jboss.portal.common.i18n.LocalizedString(wsrpLocalizedString.getValue(),
- WSRPUtils.getLocale(wsrpLocalizedString.getLang()));
+ return null;
}
class MIMETypeInfo
@@ -414,11 +411,20 @@
private class WSRPCapabilitiesInfo implements CapabilitiesInfo
{
- private final Map mimeTypes;
- private final Set modes;
- private final Set windowStates;
- private final Set locales;
+ private Map mimeTypes;
+ private Set modes;
+ private Set windowStates;
+ private Set locales;
+ private WSRPCapabilitiesInfo()
+ {
+ }
+
+ private void setMimeTypes(Map mimeTypes)
+ {
+ this.mimeTypes = mimeTypes;
+ }
+
public WSRPCapabilitiesInfo(Map mimeTypes, Set modes, Set windowStates, Set
locales)
{
this.mimeTypes = mimeTypes;
@@ -479,6 +485,57 @@
return Collections.unmodifiableSet(mimeTypeInfo.locales);
}
+
+ private void addModes(Set modes)
+ {
+ if (modes != null)
+ {
+ int size = modes.size();
+ if (size != 0)
+ {
+ if (this.modes == null)
+ {
+ this.modes = new HashSet(size);
+ }
+
+ this.modes.addAll(modes);
+ }
+ }
+ }
+
+ private void addWindowStates(Set windowStates)
+ {
+ if (windowStates != null)
+ {
+ int size = windowStates.size();
+ if (size != 0)
+ {
+ if (this.windowStates == null)
+ {
+ this.windowStates = new HashSet(size);
+ }
+
+ this.windowStates.addAll(windowStates);
+ }
+ }
+ }
+
+ private void addLocales(Set locales)
+ {
+ if (locales != null)
+ {
+ int size = locales.size();
+ if (size != 0)
+ {
+ if (this.locales == null)
+ {
+ this.locales = new HashSet(size);
+ }
+
+ this.locales.addAll(locales);
+ }
+ }
+ }
}
private static class WSRPMetaInfo implements MetaInfo
Show replies by date