portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shins...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor PortletApplicationDescriptor.java PortletApplicationWar.java
Date Sat, 09 Apr 2005 00:24:45 GMT
shinsuke    2005/04/08 17:24:45

  Modified:    components/registry/src/java/org/apache/jetspeed/om/impl
                        LanguageImpl.java LanguageSetImpl.java
               components/registry/src/java/org/apache/jetspeed/om/portlet/impl
                        PortletDefinitionImpl.java
               portal/src/java/org/apache/jetspeed/tools/pamanager
                        PortletApplicationManager.java
               portal/src/java/org/apache/jetspeed/util/descriptor
                        PortletApplicationDescriptor.java
                        PortletApplicationWar.java
  Log:
  fixed portlet title handling issue
  
  Revision  Changes    Path
  1.13      +10 -3     jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageImpl.java
  
  Index: LanguageImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LanguageImpl.java	3 Apr 2005 23:28:15 -0000	1.12
  +++ LanguageImpl.java	9 Apr 2005 00:24:44 -0000	1.13
  @@ -87,13 +87,20 @@
           defaults.put(JAVAX_PORTLET_KEYWORDS, defaultKeyWords);
           this.resourceBundle = new DefaultsResourceBundle(bundle, defaults);
   
  -        this.locale = locale;
  +        setLocale(locale);
  +        setTitle(getResourceBundle().getString(JAVAX_PORTLET_TITLE));
  +        setShortTitle(getResourceBundle().getString(JAVAX_PORTLET_SHORT_TITLE));
  +        setKeywords(getResourceBundle().getString(JAVAX_PORTLET_KEYWORDS));
       }
   
       public LanguageImpl( Locale locale, ResourceBundle bundle )
       {
           this.resourceBundle = new DefaultsResourceBundle(bundle, new HashMap());
  -        this.locale = locale;
  +
  +        setLocale(locale);
  +        setTitle(getResourceBundle().getString(JAVAX_PORTLET_TITLE));
  +        setShortTitle(getResourceBundle().getString(JAVAX_PORTLET_SHORT_TITLE));
  +        setKeywords(getResourceBundle().getString(JAVAX_PORTLET_KEYWORDS));
       }
   
       /**
  
  
  
  1.13      +73 -59    jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java
  
  Index: LanguageSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LanguageSetImpl.java	3 Apr 2005 23:28:15 -0000	1.12
  +++ LanguageSetImpl.java	9 Apr 2005 00:24:44 -0000	1.13
  @@ -25,7 +25,6 @@
   import java.util.ResourceBundle;
   
   import org.apache.commons.lang.StringUtils;
  -import org.apache.jetspeed.util.JetspeedLocale;
   import org.apache.jetspeed.om.common.MutableLanguage;
   import org.apache.jetspeed.om.common.Support;
   import org.apache.pluto.om.common.Language;
  @@ -91,6 +90,7 @@
        */
       public Language get( Locale locale )
       {
  +
           Language fallBack = null;
           Iterator searchItr = innerCollection.iterator();
           while (searchItr.hasNext())
  @@ -101,8 +101,11 @@
               {
                   if (resources != null)
                   {
  -                    return createLanguage(lang.getLocale(), loadResourceBundle(lang.getLocale()),
lang.getTitle(), lang
  -                            .getShortTitle(), StringUtils.join(lang.getKeywords(), ","),
false);
  +                    LanguageImpl language = (LanguageImpl)createLanguage(lang.getLocale(),
loadResourceBundle(lang.getLocale()),"","","");
  +                    language.setTitle(lang.getTitle());
  +                    language.setShortTitle(lang.getShortTitle());
  +                    language.setKeywords(StringUtils.join(lang.getKeywords(), ","));
  +                    return language;
                   }
                   else
                   {
  @@ -118,13 +121,24 @@
   
           if (fallBack != null && resources != null)
           {
  -            fallBack = createLanguage(fallBack.getLocale(), loadResourceBundle(fallBack.getLocale()),
fallBack
  -                    .getTitle(), fallBack.getShortTitle(), StringUtils.join(fallBack.getKeywords(),
","), true);
  +            LanguageImpl language = (LanguageImpl)createLanguage(fallBack.getLocale(),
loadResourceBundle(fallBack.getLocale()),"","","");
  +            language.setTitle(fallBack.getTitle());
  +            language.setShortTitle(fallBack.getShortTitle());
  +            language.setKeywords(StringUtils.join(fallBack.getKeywords(), ","));
  +            fallBack = language;
           }
   
           if (fallBack == null)
           {
  -            fallBack = new LanguageImpl(locale, loadResourceBundle(locale));
  +            if(!getDefaultLocale().equals(locale))
  +            {
  +                Language defaultLang=get(getDefaultLocale());
  +                fallBack = new LanguageImpl(locale, loadResourceBundle(locale), defaultLang.getTitle(),
defaultLang.getShortTitle(), StringUtils.join(defaultLang.getKeywords(), ","));
  +            }
  +            else
  +            {
  +                fallBack = new LanguageImpl(locale, loadResourceBundle(locale), "","","");
  +            }
               innerCollection.add(fallBack);
           }
           return fallBack;
  @@ -143,22 +157,48 @@
        */
       public boolean add( Object o )
       {
  +        if (o instanceof Language)
  +        {
           Language language = (Language) o;
           if (language.getLocale() == null)
           {
  -            ((MutableLanguage) o).setLocale(Locale.ENGLISH);
  +                ((MutableLanguage) o).setLocale(getDefaultLocale());
           }
   
  +            Iterator ite = innerCollection.iterator();
  +            while (ite.hasNext())
  +            {
  +                Language lang = (Language) ite.next();
  +                if (lang.getLocale().equals(language.getLocale()))
  +                {
  +                    innerCollection.remove(lang);
           return innerCollection.add(o);
       }
  +            }
  +            return innerCollection.add(o);
  +        }
  +        return false;
  +    }
   
       /**
        * @see java.util.Collection#remove(java.lang.Object)
        */
  -    public boolean remove( Object o )
  +    public boolean remove(Object o)
  +    {
  +        if (o instanceof Language)
       {
           Language language = (Language) o;
  -        return innerCollection.remove(language);
  +            Iterator ite = innerCollection.iterator();
  +            while (ite.hasNext())
  +            {
  +                Language lang = (Language) ite.next();
  +                if (lang.getLocale().equals(language.getLocale()))
  +                {
  +                    return innerCollection.remove(lang);
  +                }
  +            }
  +        }
  +        return false;
       }
   
       /**
  @@ -197,14 +237,34 @@
        */
       public void postLoad( Object parameter ) throws Exception
       {
  +        String title = "";
  +        String shortTitle = "";
  +        String keywords = "";
  +        Language defaultLang = get(getDefaultLocale());
  +        if (defaultLang != null)
  +        {
  +            title = defaultLang.getTitle();
  +            shortTitle = defaultLang.getShortTitle();
  +            keywords = StringUtils.join(defaultLang.getKeywords(), ",");
  +        }
  +
  +        ResourceBundle defaultResource = loadResourceBundle(getDefaultLocale());
           Iterator iter = ((Collection) parameter).iterator();
           while (iter.hasNext())
           {
               Locale locale = (Locale) iter.next();
  -            Language language = createLanguage(locale, null);
  -            remove(language);
  +            ResourceBundle resource = loadResourceBundle(locale);
  +            if (resource == null)
  +            {
  +                resource = defaultResource;
  +            }
  +            Language language = createLanguage(locale, resource, title, shortTitle, keywords);
               add(language);
           }
  +
  +        // add default Language
  +        Language language = createLanguage(getDefaultLocale(), defaultResource, title,
shortTitle, keywords);
  +        add(language);
       }
   
       protected ResourceBundle loadResourceBundle( Locale locale )
  @@ -244,29 +304,6 @@
       }
   
       /**
  -     * Creates Language instance from a default Language
  -     * 
  -     * @param locale
  -     * @param bundle
  -     * @return
  -     */
  -    private Language createLanguage( Locale locale, ResourceBundle bundle )
  -    {
  -        String title = "";
  -        String shortTitle = "";
  -        String keywords = "";
  -        Language defaultLang = get(getDefaultLocale());
  -
  -        if (defaultLang != null)
  -        {
  -            title = defaultLang.getTitle();
  -            shortTitle = defaultLang.getShortTitle();
  -            keywords = StringUtils.join(defaultLang.getKeywords(), ",");
  -        }
  -        return createLanguage(locale, bundle, title, shortTitle, keywords, false);
  -    }
  -
  -    /**
        * Creates Language instance.
        * 
        * @param locale
  @@ -276,31 +313,8 @@
        * @param keywords
        * @return
        */
  -    private Language createLanguage( Locale locale, ResourceBundle bundle, String title,
String shortTitle,
  -            String keywords, boolean createNow)
  +    private Language createLanguage( Locale locale, ResourceBundle bundle, String title,
String shortTitle, String keywords)
       {
  -        if (!createNow && !locale.equals(getDefaultLocale()))
  -        {
  -            Language defaultLang = get(getDefaultLocale());
  -
  -            if (defaultLang != null)
  -            {
  -                if (title == null || title.length() < 1)
  -                {
  -                    title = defaultLang.getTitle();
  -                }
  -
  -                if (shortTitle == null || shortTitle.length() < 1)
  -                {
  -                    shortTitle = defaultLang.getShortTitle();
  -                }
  -
  -                if (keywords == null || keywords.length() < 1)
  -                {
  -                    keywords = StringUtils.join(defaultLang.getKeywords(), ",");
  -                }
  -            }
  -        }
           LanguageImpl lang = new LanguageImpl(locale, bundle, title, shortTitle, keywords);
           return (Language) lang;
       }
  
  
  
  1.28      +10 -2     jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
  
  Index: PortletDefinitionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- PortletDefinitionImpl.java	23 Mar 2005 22:27:27 -0000	1.27
  +++ PortletDefinitionImpl.java	9 Apr 2005 00:24:44 -0000	1.28
  @@ -908,9 +908,17 @@
           {
               langListWrapper.setResources(resourceBundle);
           }
  -        langListWrapper.setClassLoader(getPortletClassLoader());        
  +        
  +        if (parameter instanceof ClassLoader)
  +        {
  +            langListWrapper.setClassLoader((ClassLoader) parameter);
           langListWrapper.postLoad(this.supportedLocales);
       }
  +        else
  +        {
  +            langListWrapper.setClassLoader(getPortletClassLoader());
  +        }
  +    }
       
       public static void setPortletRegistry(PortletRegistry registry)
       {
  
  
  
  1.21      +4 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
  
  Index: PortletApplicationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- PortletApplicationManager.java	26 Mar 2005 22:05:13 -0000	1.20
  +++ PortletApplicationManager.java	9 Apr 2005 00:24:44 -0000	1.21
  @@ -189,7 +189,7 @@
   	}
   
   	protected MutablePortletApplication registerPortletApplication(PortletApplicationWar paWar,
  -		MutablePortletApplication oldPA, boolean local)
  +		MutablePortletApplication oldPA, boolean local, ClassLoader paClassLoader)
   		throws RegistryException
   	{
   		if (oldPA != null)
  @@ -205,7 +205,7 @@
   		try
   		{
   			log.info("Loading portlet.xml...." + paName);
  -			pa = paWar.createPortletApp();
  +			pa = paWar.createPortletApp(paClassLoader);
   
   			if (local)
   			{
  @@ -329,7 +329,7 @@
   			}
   			else
   			{
  -				pa = registerPortletApplication(paWar, pa, local);
  +				pa = registerPortletApplication(paWar, pa, local, paClassLoader);
   			}
               portletFactory.registerPortletApplication(pa, paClassLoader);
   		}
  
  
  
  1.5       +3 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java
  
  Index: PortletApplicationDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PortletApplicationDescriptor.java	16 Aug 2004 18:32:35 -0000	1.4
  +++ PortletApplicationDescriptor.java	9 Apr 2005 00:24:44 -0000	1.5
  @@ -72,7 +72,7 @@
        * @return MutablePortletApplication newly created MutablePortletApplication with
        * all values of the portlet application descriptor mapped into it.
        */
  -    public MutablePortletApplication createPortletApplication()
  +    public MutablePortletApplication createPortletApplication(ClassLoader classLoader)
           throws PortletApplicationException
       {
           try
  @@ -163,8 +163,7 @@
                       portletDef.setPortletIdentifier(portletDef.getName());
                   }
                   
  -                //TODO is pd a proper argument?
  -                ((Support)obj).postLoad(pd);
  +                ((Support)obj).postLoad(classLoader);
               }
               
               return pd;
  
  
  
  1.22      +2 -2      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
  
  Index: PortletApplicationWar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PortletApplicationWar.java	23 Mar 2005 22:53:53 -0000	1.21
  +++ PortletApplicationWar.java	9 Apr 2005 00:24:44 -0000	1.22
  @@ -208,14 +208,14 @@
        * @throws IOException
        * @see org.apache.jetspeed.uitl.descriptor.PortletApplicationDescriptor
        */
  -    public MutablePortletApplication createPortletApp() throws PortletApplicationException,
IOException
  +    public MutablePortletApplication createPortletApp(ClassLoader classLoader) throws PortletApplicationException,
IOException
       {
           Reader portletXmlReader = getReader(PORTLET_XML_PATH);
           
           try
           {
               PortletApplicationDescriptor paDescriptor = new PortletApplicationDescriptor(portletXmlReader,
paName);
  -            portletApp = paDescriptor.createPortletApplication();
  +            portletApp = paDescriptor.createPortletApplication(classLoader);
               // validate(portletApplication);
               Reader extMetaDataXml = null;
               try
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message