You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/10/29 04:06:06 UTC
svn commit: r708757 - in
/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade:
components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/
components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/
components/jet...
Author: ate
Date: Tue Oct 28 20:06:06 2008
New Revision: 708757
URL: http://svn.apache.org/viewvc?rev=708757&view=rev
Log:
JS2-871 - Upgrade Pluto container to version 2.0
See: http://issues.apache.org/jira/browse/JS2-871
- finishing most of the PortletDefinition implementation concerning language/resourceBundle combo
- aligning ExtendedDescriptorServiceImpl for it
- standardizing and simplyfiing on Locale creation in JetspeedLocale
- cleaning up FragmentPortletDefinition
Still todo: getPreferences() on both PortletDefinition and FragmentPortletDefinition
(not sure if this still should be the Portlet API Preferences or just a simple map of preferences as Pluto container requires it)
Added:
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java (with props)
Modified:
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/ (props changed)
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DescriptionImpl.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DisplayNameImpl.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/Language.java
portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/util/JetspeedLocale.java
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/ExtendedDescriptorServiceImpl.java Tue Oct 28 20:06:06 2008
@@ -19,6 +19,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Locale;
+import java.util.ResourceBundle;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
@@ -33,6 +35,7 @@
import org.apache.jetspeed.om.portlet.Filter;
import org.apache.jetspeed.om.portlet.FilterMapping;
import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.Language;
import org.apache.jetspeed.om.portlet.Listener;
import org.apache.jetspeed.om.portlet.PortletApplication;
import org.apache.jetspeed.om.portlet.PortletDefinition;
@@ -42,6 +45,8 @@
import org.apache.jetspeed.om.portlet.Supports;
import org.apache.jetspeed.om.portlet.UserAttribute;
import org.apache.jetspeed.om.portlet.UserAttributeRef;
+import org.apache.jetspeed.om.portlet.impl.CustomPortletModeImpl;
+import org.apache.jetspeed.om.portlet.impl.CustomWindowStateImpl;
import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
import org.apache.jetspeed.om.portlet.jetspeed.jaxb.MetadataType;
import org.apache.jetspeed.om.portlet.jetspeed.jaxb.Portlet;
@@ -51,6 +56,7 @@
import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriter;
import org.apache.jetspeed.tools.deploy.JetspeedWebApplicationRewriterFactory;
+import org.apache.jetspeed.util.JetspeedLocale;
import org.apache.pluto.descriptors.services.jaxb.PortletAppDescriptorServiceImpl;
import org.apache.pluto.om.portlet.CustomPortletMode;
import org.apache.pluto.om.portlet.CustomWindowState;
@@ -295,11 +301,22 @@
SecurityRoleRef jsrr = jpd.addSecurityRoleRef(srr.getRoleName());
jsrr.setRoleLink(srr.getRoleLink());
}
+
+ boolean defaultLocaleProcessed = false;
for (String locale : pd.getSupportedLocales())
{
jpd.addSupportedLocale(locale);
+ if (addLanguage(jpd, JetspeedLocale.convertStringToLocale(locale)).equals(JetspeedLocale.getDefaultLocale()))
+ {
+ defaultLocaleProcessed = true;
+ }
}
- // TODO: jpd.addLanguage()
+ if (!defaultLocaleProcessed)
+ {
+ addLanguage(jpd, JetspeedLocale.getDefaultLocale());
+ defaultLocaleProcessed = true;
+ }
+
for (org.apache.pluto.om.portlet.EventDefinitionReference ed : pd.getSupportedProcessingEvents())
{
if (ed.getQName() != null)
@@ -340,12 +357,33 @@
}
}
+ protected Language addLanguage(PortletDefinition jpd, Locale locale)
+ {
+ ResourceBundle bundle = jpd.getResourceBundle(locale);
+ Language l = jpd.addLanguage(locale);
+ String value = bundle.getString(Language.JAVAX_PORTLET_TITLE);
+ if (!value.equals(""))
+ {
+ l.setTitle(value);
+ }
+ value = bundle.getString(Language.JAVAX_PORTLET_SHORT_TITLE);
+ if (!value.equals(""))
+ {
+ l.setShortTitle(value);
+ }
+ value = bundle.getString(Language.JAVAX_PORTLET_SHORT_TITLE);
+ if (!value.equals(""))
+ {
+ l.setKeywords(value);
+ }
+ return l;
+ }
+
public void readExtended(InputStream in, PortletApplication app) throws IOException
{
try
{
- JAXBContext jc = JAXBContext
- .newInstance("org.apache.jetspeed.om.portlet.jetspeed.jaxb");
+ JAXBContext jc = JAXBContext.newInstance("org.apache.jetspeed.om.portlet.jetspeed.jaxb");
Unmarshaller u = jc.createUnmarshaller();
PortletApp pa = (PortletApp) u.unmarshal(in);
app.setJetspeedSecurityConstraint(pa.getSecurityConstraintRef());
@@ -355,11 +393,10 @@
}
for (MetadataType m : pa.getMetadata())
{
- // TODO: 2.2 metadata
- // ??? app.getMetadata().addField(locale, name, value);
- System.out.println("metadata: " + m.getMetadataName());
- System.out.println(" lang: " + m.getLang());
- System.out.println(" value: " + m.getContent());
+ if (m.getContent() != null)
+ {
+ app.getMetadata().addField(JetspeedLocale.convertStringToLocale(m.getLang()), m.getMetadataName(), m.getContent());
+ }
}
for (Portlet p : pa.getPortlets())
{
@@ -369,36 +406,43 @@
pd.setJetspeedSecurityConstraint(p.getSecurityConstraintRef());
for (MetadataType m : p.getMetadata())
{
- // TODO: 2.2 metadata
- System.out.println(" metadata: " + m.getMetadataName());
- System.out.println(" lang: " + m.getLang());
- System.out.println(" value: " + m.getContent());
+ if (m.getContent() != null)
+ {
+ pd.getMetadata().addField(JetspeedLocale.convertStringToLocale(m.getLang()), m.getMetadataName(), m.getContent());
+ }
}
}
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomPortletMode cpm : pa.getCustomPortletModes())
{
- // TODO: 2.2
-// System.out.println(" cpm name: " + cpm.getName());
-// System.out.println(" mapped: " + cpm.getMappedName());
-// System.out.println(" desc: " + cpm.getDescription());
+ if (cpm.getName() != null && cpm.getMappedName() != null && !cpm.getName().equals(cpm.getMappedName()))
+ {
+ CustomPortletMode jcpm = app.getCustomPortletMode(cpm.getMappedName());
+ if (jcpm != null && app.getCustomPortletMode(cpm.getName()) == null)
+ {
+ ((CustomPortletModeImpl)jcpm).setMappedName(cpm.getMappedName());
+ }
+ }
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomWindowState cws : pa.getCustomWindowStates())
{
- // TODO: 2.2
-// System.out.println(" cws name: " + cws.getName());
-// System.out.println(" mapped: " + cws.getMappedName());
-// System.out.println(" desc: " + cws.getDescription());
+ if (cws.getName() != null && cws.getMappedName() != null && !cws.getName().equals(cws.getMappedName()))
+ {
+ CustomWindowState jcws = app.getCustomWindowState(cws.getMappedName());
+ if (jcws != null && app.getCustomWindowState(cws.getName()) == null)
+ {
+ ((CustomWindowStateImpl)jcws).setMappedName(cws.getMappedName());
+ }
+ }
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.UserAttributeRef ref : pa.getUserAttributeRefs())
{
UserAttributeRef jref = app.addUserAttributeRef(ref.getName());
jref.setNameLink(ref.getNameLink());
- Description desc = jref.addDescription(ref.getDescription());
- // TODO: 2.2 desscription processing
+ Description desc = jref.addDescription("en");
+ desc.setDescription(ref.getDescription());
}
-
}
catch (JAXBException je)
{
Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Oct 28 20:06:06 2008
@@ -1,2 +1,2 @@
-target
+target
surefire*.properties
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DescriptionImpl.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DescriptionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DescriptionImpl.java Tue Oct 28 20:06:06 2008
@@ -57,36 +57,11 @@
public void setLang(String value)
{
lang = value;
- deriveLocale();
+ locale = JetspeedLocale.convertStringToLocale(lang);
}
public Locale getLocale()
{
- return locale == null ? deriveLocale() : locale;
- }
-
- protected Locale deriveLocale()
- {
- String lang = this.getLang();
- String country = "";
- String variant = "";
- String[] localeArray = lang.split("[-|_]");
- for (int i = 0; i < localeArray.length; i++)
- {
- if (i == 0)
- {
- lang = localeArray[i];
- }
- else if (i == 1)
- {
- country = localeArray[i];
- }
- else if (i == 2)
- {
- variant = localeArray[i];
- }
- }
- locale = new Locale(lang, country, variant);
- return locale;
+ return locale == null ? locale = JetspeedLocale.convertStringToLocale(lang) : locale;
}
}
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DisplayNameImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DisplayNameImpl.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DisplayNameImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/DisplayNameImpl.java Tue Oct 28 20:06:06 2008
@@ -52,35 +52,11 @@
public void setLang(String value)
{
lang = value;
- }
-
- public Locale getLocale()
- {
- return locale == null ? deriveLocale() : locale;
+ locale = JetspeedLocale.convertStringToLocale(lang);
}
- protected Locale deriveLocale()
+ public Locale getLocale()
{
- String lang = this.getLang();
- String country = "";
- String variant = "";
- String[] localeArray = lang.split("[-|_]");
- for (int i = 0; i < localeArray.length; i++)
- {
- if (i == 0)
- {
- lang = localeArray[i];
- }
- else if (i == 1)
- {
- country = localeArray[i];
- }
- else if (i == 2)
- {
- variant = localeArray[i];
- }
- }
- locale = new Locale(lang, country, variant);
- return locale;
+ return locale == null ? locale = JetspeedLocale.convertStringToLocale(lang) : locale;
}
}
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/FragmentPortletDefinition.java Tue Oct 28 20:06:06 2008
@@ -16,29 +16,26 @@
*/
package org.apache.jetspeed.om.portlet.impl;
-import java.io.IOException;
-import java.util.Collection;
+import java.util.List;
import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
-import org.apache.jetspeed.om.common.preference.PreferenceComposite;
-import org.apache.jetspeed.om.common.preference.PreferenceSetComposite;
import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.EventDefinitionReference;
import org.apache.jetspeed.om.portlet.GenericMetadata;
import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.Language;
+import org.apache.jetspeed.om.portlet.PortletApplication;
import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.jetspeed.om.preference.impl.FragmentPortletPreferenceSet;
-import org.apache.pluto.om.portlet.ObjectID;
-import org.apache.pluto.om.portlet.ParameterSet;
-import org.apache.pluto.om.portlet.Preference;
-import org.apache.pluto.om.portlet.PreferenceSet;
-import org.apache.pluto.om.portlet.Description;
-import org.apache.pluto.om.portlet.DescriptionSet;
-import org.apache.pluto.om.portlet.DisplayName;
-import org.apache.pluto.om.portlet.DisplayNameSet;
-import org.apache.pluto.om.portlet.PortletApplicationDefinition;
-import org.apache.pluto.om.portlet.SecurityRoleRef;
-import org.apache.pluto.om.portlet.SecurityRoleRefSet;
-import org.apache.pluto.om.servlet.ServletDefinition;
+import org.apache.jetspeed.om.portlet.PortletInfo;
+import org.apache.jetspeed.om.portlet.Preferences;
+import org.apache.jetspeed.om.portlet.SecurityRoleRef;
+import org.apache.jetspeed.om.portlet.Supports;
/**
* Per-request wrapper for a PortletDefinition that allows for
@@ -61,74 +58,99 @@
this.fragment = fragment;
}
- public void addDescription(Locale locale, String description)
+ public ContainerRuntimeOption addContainerRuntimeOption(String name)
{
- portletDefinition.addDescription(locale, description);
+ return portletDefinition.addContainerRuntimeOption(name);
}
- public void addDisplayName(DisplayName displayName)
+ public Description addDescription(String lang)
{
- portletDefinition.addDisplayName(displayName);
+ return portletDefinition.addDescription(lang);
}
- public void addDisplayName(Locale locale, String displayName)
+ public DisplayName addDisplayName(String lang)
{
- portletDefinition.addDisplayName(locale, displayName);
+ return portletDefinition.addDisplayName(lang);
}
- public InitParam addInitParameter(String name, String value, DescriptionSet description)
+ public InitParam addInitParam(String paramName)
{
- return portletDefinition.addInitParameter(name, value, description);
+ return portletDefinition.addInitParam(paramName);
}
- public InitParam addInitParameter(String name, String value, String description, Locale locale)
+ public Language addLanguage(Locale locale)
{
- return portletDefinition.addInitParameter(name, value, description, locale);
+ return portletDefinition.addLanguage(locale);
}
- public InitParam addInitParameter(String name, String value)
+ public SecurityRoleRef addSecurityRoleRef(String roleName)
{
- return portletDefinition.addInitParameter(name, value);
+ return portletDefinition.addSecurityRoleRef(roleName);
}
- public void addLanguage(String title, String shortTitle, String keywords, Locale locale)
+ public void addSupportedLocale(String lang)
{
- portletDefinition.addLanguage(title, shortTitle, keywords, locale);
+ portletDefinition.addSupportedLocale(lang);
}
- public void addPreference(Preference preference)
+ public EventDefinitionReference addSupportedProcessingEvent(QName qname)
{
- portletDefinition.addPreference(preference);
+ return portletDefinition.addSupportedProcessingEvent(qname);
}
- public PreferenceComposite addPreference(String name, String[] values)
+ public EventDefinitionReference addSupportedProcessingEvent(String name)
{
- return portletDefinition.addPreference(name, values);
+ return portletDefinition.addSupportedProcessingEvent(name);
}
- public void addSecurityRoleRef(SecurityRoleRef securityRef)
+ public void addSupportedPublicRenderParameter(String identifier)
{
- portletDefinition.addSecurityRoleRef(securityRef);
+ portletDefinition.addSupportedPublicRenderParameter(identifier);
}
- public SecurityRoleRef addSecurityRoleRef(String roleName, String roleLink)
+ public EventDefinitionReference addSupportedPublishingEvent(QName qname)
{
- return portletDefinition.addSecurityRoleRef(roleName, roleLink);
+ return portletDefinition.addSupportedPublishingEvent(qname);
}
- public String getPortletClass()
+ public EventDefinitionReference addSupportedPublishingEvent(String name)
{
- return portletDefinition.getPortletClass();
+ return portletDefinition.addSupportedPublishingEvent(name);
+ }
+
+ public Supports addSupports(String mimeType)
+ {
+ return portletDefinition.addSupports(mimeType);
+ }
+
+ public PortletApplication getApplication()
+ {
+ return portletDefinition.getApplication();
}
- public Description getDescription(Locale arg0)
+ public String getCacheScope()
{
- return portletDefinition.getDescription(arg0);
+ return portletDefinition.getCacheScope();
}
- public DescriptionSet getDescriptionSet()
+ public ContainerRuntimeOption getContainerRuntimeOption(String name)
{
- return portletDefinition.getDescriptionSet();
+ return portletDefinition.getContainerRuntimeOption(name);
+ }
+
+ public List<ContainerRuntimeOption> getContainerRuntimeOptions()
+ {
+ return portletDefinition.getContainerRuntimeOptions();
+ }
+
+ public Description getDescription(Locale locale)
+ {
+ return portletDefinition.getDescription(locale);
+ }
+
+ public List<Description> getDescriptions()
+ {
+ return portletDefinition.getDescriptions();
}
public String getDescriptionText(Locale locale)
@@ -136,14 +158,14 @@
return portletDefinition.getDescriptionText(locale);
}
- public DisplayName getDisplayName(Locale arg0)
+ public DisplayName getDisplayName(Locale locale)
{
- return portletDefinition.getDisplayName(arg0);
+ return portletDefinition.getDisplayName(locale);
}
- public DisplayNameSet getDisplayNameSet()
+ public List<DisplayName> getDisplayNames()
{
- return portletDefinition.getDisplayNameSet();
+ return portletDefinition.getDisplayNames();
}
public String getDisplayNameText(Locale locale)
@@ -151,54 +173,59 @@
return portletDefinition.getDisplayNameText(locale);
}
- public String getExpirationCache()
+ public int getExpirationCache()
{
return portletDefinition.getExpirationCache();
}
- public ObjectID getId()
+ public InitParam getInitParam(String paramName)
{
- return portletDefinition.getId();
+ return portletDefinition.getInitParam(paramName);
}
- public ParameterSet getInitParameterSet()
+ public List<InitParam> getInitParams()
{
- return portletDefinition.getInitParameterSet();
+ return portletDefinition.getInitParams();
}
- public SecurityRoleRefSet getInitSecurityRoleRefSet()
+ public String getJetspeedSecurityConstraint()
{
- return portletDefinition.getInitSecurityRoleRefSet();
+ return portletDefinition.getJetspeedSecurityConstraint();
}
- public GenericMetadata getMetadata()
+ public Language getLanguage(Locale locale)
{
- return portletDefinition.getMetadata();
+ return portletDefinition.getLanguage(locale);
}
- public String getPortletName()
+ public List<Language> getLanguages()
{
- return portletDefinition.getPortletName();
+ return portletDefinition.getLanguages();
+ }
+
+ public GenericMetadata getMetadata()
+ {
+ return portletDefinition.getMetadata();
}
- public PortletApplicationDefinition getPortletApplicationDefinition()
+ public String getPortletClass()
{
- return portletDefinition.getPortletApplicationDefinition();
+ return portletDefinition.getPortletClass();
}
- public ClassLoader getPortletClassLoader()
+ public PortletInfo getPortletInfo()
{
- return portletDefinition.getPortletClassLoader();
+ return portletDefinition.getPortletInfo();
}
- public String getPortletIdentifier()
+ public String getPortletName()
{
- return portletDefinition.getPortletIdentifier();
+ return portletDefinition.getPortletName();
}
- public PreferenceSet getPreferenceSet()
+ public Preferences getPortletPreferences()
{
- return new FragmentPortletPreferenceSet((PreferenceSetComposite) portletDefinition.getPreferenceSet(), fragment);
+// return new FragmentPortletPreferenceSet((PreferenceSetComposite) portletDefinition.getPreferenceSet(), fragment);
}
public String getPreferenceValidatorClassname()
@@ -211,84 +238,79 @@
return portletDefinition.getResourceBundle();
}
- public ServletDefinition getServletDefinition()
- {
- return portletDefinition.getServletDefinition();
- }
-
- public Collection getSupportedLocales()
+ public ResourceBundle getResourceBundle(Locale locale)
{
- return portletDefinition.getSupportedLocales();
+ return portletDefinition.getResourceBundle(locale);
}
- public String getUniqueName()
+ public SecurityRoleRef getSecurityRoleRef(String roleName)
{
- return portletDefinition.getUniqueName();
+ return portletDefinition.getSecurityRoleRef(roleName);
}
- public void setPortletClass(String arg0)
+ public List<SecurityRoleRef> getSecurityRoleRefs()
{
- portletDefinition.setPortletClass(arg0);
+ return portletDefinition.getSecurityRoleRefs();
}
- public void setDescriptions(DescriptionSet arg0)
+ public List<String> getSupportedLocales()
{
- portletDefinition.setDescriptions(arg0);
+ return portletDefinition.getSupportedLocales();
}
- public void setDisplayNames(DisplayNameSet arg0)
+ public List<EventDefinitionReference> getSupportedProcessingEvents()
{
- portletDefinition.setDisplayNames(arg0);
+ return portletDefinition.getSupportedProcessingEvents();
}
- public void setExpirationCache(String cache)
+ public List<String> getSupportedPublicRenderParameters()
{
- portletDefinition.setExpirationCache(cache);
+ return portletDefinition.getSupportedPublicRenderParameters();
}
- public void setId(String arg0)
+ public List<EventDefinitionReference> getSupportedPublishingEvents()
{
- portletDefinition.setId(arg0);
+ return portletDefinition.getSupportedPublishingEvents();
}
- public void setInitParameterSet(ParameterSet parameters)
+ public List<Supports> getSupports()
{
- portletDefinition.setInitParameterSet(parameters);
+ return portletDefinition.getSupports();
}
- public void setInitSecurityRoleRefSet(SecurityRoleRefSet securityRefs)
+ public Supports getSupports(String mimeType)
{
- portletDefinition.setInitSecurityRoleRefSet(securityRefs);
+ return portletDefinition.getSupports(mimeType);
}
- public void setMetadata(GenericMetadata metadata)
+ public String getUniqueName()
{
- portletDefinition.setMetadata(metadata);
+ return portletDefinition.getUniqueName();
}
- public void setPortletName(String arg0)
+ public boolean isSameIdentity(PortletDefinition other)
{
- portletDefinition.setPortletName(arg0);
+ return portletDefinition.isSameIdentity(other);
}
- public void setPortletApplicationDefinition(PortletApplicationDefinition pad)
+ public void setCacheScope(String cacheScope)
{
- portletDefinition.setPortletApplicationDefinition(pad);
+ portletDefinition.setCacheScope(cacheScope);
}
- public void setPortletClassLoader(ClassLoader arg0)
+ public void setExpirationCache(int expirationCache)
{
- portletDefinition.setPortletClassLoader(arg0);
+ portletDefinition.setExpirationCache(expirationCache);
}
- public void setPortletIdentifier(String portletIndentifier)
+ public void setJetspeedSecurityConstraint(String constraint)
{
- portletDefinition.setPortletIdentifier(portletIndentifier);
+ portletDefinition.setJetspeedSecurityConstraint(constraint);
}
- public void setPreferenceSet(PreferenceSet preferences)
+ public void setPortletClass(String portletClass)
{
- portletDefinition.setPreferenceSet(preferences);
+ portletDefinition.setPortletClass(portletClass);
}
public void setPreferenceValidatorClassname(String classname)
@@ -296,23 +318,15 @@
portletDefinition.setPreferenceValidatorClassname(classname);
}
- public void store() throws IOException
+ public void setResourceBundle(String resourceBundle)
{
- portletDefinition.store();
+ portletDefinition.setResourceBundle(resourceBundle);
}
public void storeChildren()
{
portletDefinition.storeChildren();
}
-
- public String getJetspeedSecurityConstraint()
- {
- return portletDefinition.getJetspeedSecurityConstraint();
- }
- public void setJetspeedSecurityConstraint(String constraint)
- {
- portletDefinition.setJetspeedSecurityConstraint(constraint);
- }
+
}
Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java?rev=708757&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java (added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java Tue Oct 28 20:06:06 2008
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.impl;
+
+import java.util.ListResourceBundle;
+import java.util.ResourceBundle;
+
+import org.apache.pluto.Constants;
+
+/**
+ * InlinePortletResourceBundle implementation which provides the inline title, short-title, and keywords as properties
+ * from the bundle. Borrowed and improved upon the one provided by the Pluto container.
+ *
+ * @version: $Id$
+ */
+class InlinePortletResourceBundle extends ListResourceBundle
+{
+ private Object[][] contents;
+
+ public InlinePortletResourceBundle(String title, String shortTitle, String keywords)
+ {
+ this(title,shortTitle,keywords,null);
+ }
+
+ public InlinePortletResourceBundle(String title, String shortTitle, String keywords, ResourceBundle parent)
+ {
+ contents = new Object[][]{ { Constants.TITLE_KEY, deriveValue(parent, Constants.TITLE_KEY, title) },
+ { Constants.SHORT_TITLE_KEY, deriveValue(parent, Constants.SHORT_TITLE_KEY, shortTitle) },
+ { Constants.KEYWORDS_KEY, deriveValue(parent, Constants.KEYWORDS_KEY, keywords) }};
+ }
+
+ private static String deriveValue(ResourceBundle parent, String key, String defaultValue)
+ {
+ String value = defaultValue;
+ if (parent != null)
+ {
+ try
+ {
+ value = parent.getString(key);
+ }
+ catch (Exception mre)
+ {
+ }
+ }
+ return value != null ? value : "";
+ }
+
+ protected Object[][] getContents()
+ {
+ return contents;
+ }
+
+ public void setParent(ResourceBundle parent)
+ {
+ super.setParent(parent);
+ }
+}
Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/InlinePortletResourceBundle.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java Tue Oct 28 20:06:06 2008
@@ -40,6 +40,7 @@
import org.apache.jetspeed.om.portlet.GenericMetadata;
import org.apache.jetspeed.om.portlet.JetspeedServiceReference;
import org.apache.jetspeed.om.portlet.Listener;
+import org.apache.jetspeed.om.portlet.LocalizedField;
import org.apache.jetspeed.om.portlet.PortletApplication;
import org.apache.jetspeed.om.portlet.PortletDefinition;
import org.apache.jetspeed.om.portlet.PublicRenderParameter;
@@ -76,7 +77,7 @@
private transient WebApplicationDefinition webApplication;
/** Metadata property */
- private Collection<GenericMetadata> metadataFields = null;
+ private Collection<LocalizedField> metadataFields = null;
/** Description */
private String description;
@@ -233,7 +234,7 @@
{
if(metadataFields == null)
{
- metadataFields = new ArrayList<GenericMetadata>();
+ metadataFields = new ArrayList<LocalizedField>();
}
GenericMetadata metadata = new PortletApplicationMetadataImpl();
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java Tue Oct 28 20:06:06 2008
@@ -19,19 +19,15 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-import javax.portlet.PreferencesValidator;
import javax.xml.namespace.QName;
import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
@@ -42,10 +38,10 @@
import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
import org.apache.jetspeed.om.portlet.Description;
import org.apache.jetspeed.om.portlet.DisplayName;
-import org.apache.jetspeed.om.portlet.EventDefinition;
import org.apache.jetspeed.om.portlet.EventDefinitionReference;
import org.apache.jetspeed.om.portlet.GenericMetadata;
import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.LocalizedField;
import org.apache.jetspeed.om.portlet.PortletApplication;
import org.apache.jetspeed.om.portlet.PortletDefinition;
import org.apache.jetspeed.om.portlet.PortletInfo;
@@ -57,16 +53,12 @@
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerAware;
import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.pluto.descriptors.portlet.EventDefinitionReferenceType;
-import org.apache.pluto.descriptors.portlet.SecurityRoleRefType;
-import org.apache.pluto.descriptors.portlet.SupportsType;
import org.apache.jetspeed.om.portlet.Language;
/**
*
* PortletDefinitionImpl
*
- * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
* @version $Id$
*
*/
@@ -88,7 +80,7 @@
private String cacheScope;
/** Metadata property */
- private Collection metadataFields;
+ private Collection<LocalizedField> metadataFields = null;
private String jetspeedSecurityConstraint;
@@ -104,7 +96,7 @@
private List<ContainerRuntimeOption> containerRuntimeOptions;
private List<String> supportedPublicRenderParameters;
- private transient Map<Locale,ResourceBundle> resourceBundles = new HashMap<Locale, ResourceBundle>();
+ private transient Map<Locale,InlinePortletResourceBundle> resourceBundles = new HashMap<Locale, InlinePortletResourceBundle>();
protected List portletEntities;
@@ -196,14 +188,91 @@
public ResourceBundle getResourceBundle(Locale locale)
{
- // TODO Auto-generated method stub
- return null;
+ InlinePortletResourceBundle bundle = resourceBundles.get(locale);
+ if (bundle == null && getResourceBundle() == null)
+ {
+ bundle = resourceBundles.get(JetspeedLocale.getDefaultLocale());
+ if (bundle == null)
+ {
+ // setting up default resource bundle
+ Language l = getLanguage(JetspeedLocale.getDefaultLocale());
+ bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords());
+ resourceBundles.put(JetspeedLocale.getDefaultLocale(), bundle);
+ }
+ resourceBundles.put(locale, bundle);
+ }
+ if (bundle == null)
+ {
+ Language l = getLanguage(locale);
+ if (l == null)
+ {
+ // always returns a default language
+ l = getLanguage(JetspeedLocale.getDefaultLocale());
+ }
+ ResourceBundle loadedBundle = loadResourceBundle(locale);
+ if (loadedBundle == null)
+ {
+ loadedBundle = loadResourceBundle(JetspeedLocale.getDefaultLocale());
+ }
+ if (loadedBundle != null)
+ {
+ bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords(), loadedBundle);
+ }
+ else
+ {
+ bundle = new InlinePortletResourceBundle(l.getTitle(), l.getShortTitle(), l.getKeywords());
+ }
+ resourceBundles.put(locale, bundle);
+ }
+ return bundle;
}
public Language getLanguage(Locale locale)
{
- // TODO Auto-generated method stub
- return null;
+ Language lang = null;
+ Language fallback = null;
+
+ for (Language l : getLanguages())
+ {
+ if (l.getLocale().equals(locale))
+ {
+ lang = l;
+ break;
+ }
+ if (l.getLocale().getLanguage().equals(locale.getLanguage()))
+ {
+ fallback = l;
+ }
+ }
+ if (lang == null)
+ {
+ if (fallback == null)
+ {
+ if (JetspeedLocale.getDefaultLocale().equals(locale))
+ {
+ // No default Language set/provided yet, adding it on the fly
+ lang = addLanguage(JetspeedLocale.getDefaultLocale());
+ }
+ else
+ {
+ // create a new locale on the fly but don't save it
+ LanguageImpl l = new LanguageImpl();
+ l.setLocale(locale);
+ lang = l;
+ }
+ }
+ else
+ {
+ // create a copy of the fallback for the locale but don't save it
+ LanguageImpl l = new LanguageImpl();
+ l.setLocale(locale);
+ l.setTitle(fallback.getTitle());
+ l.setShortTitle(fallback.getShortTitle());
+ l.setKeywords(fallback.getKeywords());
+ lang = l;
+ }
+ }
+ return lang;
}
public List<Language> getLanguages()
@@ -217,11 +286,15 @@
public Language addLanguage(Locale locale)
{
+ // clear resourceBundle cache
+ resourceBundles.clear();
for (Language l : languages)
{
if (l.getLocale().equals(locale))
{
- throw new IllegalArgumentException("Language already defined");
+ // very special usage needed for Language as the default locale might have been created on the fly
+ // and will always be returned for getLanguage(defaultLocale)
+ return l;
}
}
LanguageImpl l = new LanguageImpl();
@@ -280,7 +353,7 @@
{
if (metadataFields == null)
{
- metadataFields = new ArrayList();
+ metadataFields = new ArrayList<LocalizedField>();
}
GenericMetadata metadata = new PortletDefinitionMetadataImpl();
@@ -292,22 +365,6 @@
/**
* @return
*/
- protected Collection getMetadataFields()
- {
- return metadataFields;
- }
-
- /**
- * @param collection
- */
- protected void setMetadataFields( Collection metadataFields )
- {
- this.metadataFields = metadataFields;
- }
-
- /**
- * @return
- */
public String getResourceBundle()
{
return resourceBundle;
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/Language.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/Language.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/Language.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/Language.java Tue Oct 28 20:06:06 2008
@@ -27,6 +27,10 @@
*/
public interface Language extends PortletInfo, Serializable
{
+ public static final String JAVAX_PORTLET_TITLE = "javax.portlet.title";
+ public static final String JAVAX_PORTLET_SHORT_TITLE = "javax.portlet.short-title";
+ public static final String JAVAX_PORTLET_KEYWORDS = "javax.portlet.keywords";
+
Locale getLocale();
List<String> getKeywordList();
void setKeywords(String keywords);
Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/util/JetspeedLocale.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/util/JetspeedLocale.java?rev=708757&r1=708756&r2=708757&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/util/JetspeedLocale.java (original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/util/JetspeedLocale.java Tue Oct 28 20:06:06 2008
@@ -82,45 +82,30 @@
* @param localeString
* @return
*/
- public static Locale convertStringToLocale(String localeString)
+ public static Locale convertStringToLocale(String lang)
{
- if (localeString == null)
+ if (lang == null)
{
return null;
}
- StringTokenizer tokenizer = new StringTokenizer(localeString, DELIM);
-
- String language = tokenizer.nextToken().trim();
- String country = null;
- String variant = null;
- if (tokenizer.hasMoreTokens())
- {
- country = tokenizer.nextToken().trim();
- }
-
- if (tokenizer.hasMoreTokens())
- {
- variant = tokenizer.nextToken().trim();
- }
-
- if (country != null && language != null && variant != null)
- {
- return new Locale(language, country, variant);
- }
- else if (country != null && language != null)
- {
- return new Locale(language, country);
- }
- else if (language != null)
- {
- return new Locale(language, ""); // JDK 1.3 compatibility
- }
- else
- {
- return null;
+ String country = "";
+ String variant = "";
+ String[] localeArray = lang.split("[-|_]");
+ for (int i = 0; i < localeArray.length; i++)
+ {
+ if (i == 0)
+ {
+ lang = localeArray[i];
+ }
+ else if (i == 1)
+ {
+ country = localeArray[i];
+ }
+ else if (i == 2)
+ {
+ variant = localeArray[i];
+ }
}
-
+ return new Locale(lang, country, variant);
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org