portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl CastorXmlPageManager.java
Date Tue, 24 Aug 2004 21:33:05 GMT
weaver      2004/08/24 14:33:05

  Modified:    components/page-manager/src/java/org/apache/jetspeed/om/page/psml
                        PageImpl.java
               components/page-manager/testdata/pages default-page.psml
               components/page-manager/src/test/org/apache/jetspeed/page
                        TestCastorXmlPageManager.java
               components/page-manager/src/java/org/apache/jetspeed/page/impl
                        CastorXmlPageManager.java
  Log:
  Page titles now support localization
  
  Revision  Changes    Path
  1.5       +38 -1     jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java
  
  Index: PageImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/om/page/psml/PageImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PageImpl.java	18 Aug 2004 13:53:49 -0000	1.4
  +++ PageImpl.java	24 Aug 2004 21:33:04 -0000	1.5
  @@ -18,10 +18,14 @@
   
   import java.util.ArrayList;
   import java.util.Collection;
  +import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.Locale;
  +import java.util.Map;
   import java.util.Stack;
   
   import org.apache.jetspeed.om.common.GenericMetadata;
  +import org.apache.jetspeed.om.common.LocalizedField;
   import org.apache.jetspeed.om.folder.Folder;
   import org.apache.jetspeed.om.page.Fragment;
   import org.apache.jetspeed.om.page.Page;
  @@ -40,10 +44,13 @@
       private int hashCode;
   
       private Folder parent;
  +    
  +    private Map localizedTitles;
   
       public PageImpl()
       {
           // empty constructor
  +        this.localizedTitles = new HashMap();
       }
   
       /**
  @@ -59,6 +66,7 @@
           // Cheaper to generate the hash code now then every call to hashCode()
           hashCode = (Page.class.getName()+":"+id).hashCode();
           super.setId(id);
  +        
       }
       /**
        * <p>
  @@ -249,6 +257,15 @@
       public void setMetadataFields( Collection metadataFields )
       {
           this.metadataFields = metadataFields;
  +        Iterator fieldsItr = metadataFields.iterator();
  +        while(fieldsItr.hasNext())
  +        {
  +            LocalizedField field = (LocalizedField) fieldsItr.next();
  +            if(field.getName().equals("title"))
  +            {
  +                localizedTitles.put(field.getLocale(), field);
  +            }
  +        }
       }
       /**
        * <p>
  @@ -261,6 +278,26 @@
       public String getName()
       {
           return getId();
  +    }
  +    /**
  +     * <p>
  +     * getTitle
  +     * </p>
  +     *
  +     * @see org.apache.jetspeed.om.page.Page#getTitle(java.util.Locale)
  +     * @param locale
  +     * @return
  +     */
  +    public String getTitle( Locale locale )
  +    {
  +        if(localizedTitles.containsKey(locale))
  +        {            
  +            return ((LocalizedField)localizedTitles.get(locale)).getValue().trim();
  +        }
  +        else
  +        {
  +            return getTitle();
  +        }
       }
   }
   
  
  
  
  1.3       +25 -25    jakarta-jetspeed-2/components/page-manager/testdata/pages/default-page.psml
  
  Index: default-page.psml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/testdata/pages/default-page.psml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- default-page.psml	28 May 2004 22:05:10 -0000	1.2
  +++ default-page.psml	24 Aug 2004 21:33:05 -0000	1.3
  @@ -14,29 +14,29 @@
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
  -<page id="p001">
  -  <defaults
  -     skin="light-blue"
  -     layout-decorator="clear"
  -     portlet-decorator="box-titled"
  -  />
  -  <title>My First PSML Page</title>
  -  <fragment id="f001" type="layout" name="TwoColumns">
  -    <fragment id="pe001" type="portlet" name="HelloPortlet">
  -      <property layout="TwoColumns" name="row" value="0" />
  -      <property layout="TwoColumns" name="column" value="0" />      
  -    </fragment>
  -    <fragment id="pe002" type="portlet" name="JMXPortlet">
  -      <property layout="TwoColumns" name="row" value="0" />
  -      <property layout="TwoColumns" name="column" value="1" />      
  -    </fragment>
  -    <fragment id="pe003" type="portlet" name="CustomerList">
  -      <property layout="TwoColumns" name="row" value="1" />
  -      <property layout="TwoColumns" name="column" value="0" />      
  -    </fragment>
  -    <fragment id="pe004" type="portlet" name="CustomerInfo">
  -      <property layout="TwoColumns" name="row" value="1" />
  -      <property layout="TwoColumns" name="column" value="1" />      
  -    </fragment>
  -  </fragment>
  +<page id="p001">
  +	<defaults skin="light-blue" layout-decorator="clear" 
  +		portlet-decorator="box-titled" />
  +	<title>My First PSML Page</title>
  +	<fragment id="f001" type="layout" name="TwoColumns">
  +		<fragment id="pe001" type="portlet" name="HelloPortlet">
  +			<property layout="TwoColumns" name="row" value="0" />
  +			<property layout="TwoColumns" name="column" value="0" />
  +		</fragment>
  +		<fragment id="pe002" type="portlet" name="JMXPortlet">
  +			<property layout="TwoColumns" name="row" value="0" />
  +			<property layout="TwoColumns" name="column" value="1" />
  +		</fragment>
  +		<fragment id="pe003" type="portlet" name="CustomerList">
  +			<property layout="TwoColumns" name="row" value="1" />
  +			<property layout="TwoColumns" name="column" value="0" />
  +		</fragment>
  +		<fragment id="pe004" type="portlet" name="CustomerInfo">
  +			<property layout="TwoColumns" name="row" value="1" />
  +			<property layout="TwoColumns" name="column" value="1" />
  +		</fragment>
  +	</fragment>
  +	<metadata name="title" xml:lang="fr">
  +		Ma Premiere Page de PSML
  +	</metadata>
   </page>
  
  
  
  1.9       +13 -1     jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java
  
  Index: TestCastorXmlPageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestCastorXmlPageManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestCastorXmlPageManager.java	24 Aug 2004 14:15:00 -0000	1.8
  +++ TestCastorXmlPageManager.java	24 Aug 2004 21:33:05 -0000	1.9
  @@ -361,4 +361,16 @@
           assertNotNull(metaData);
           assertEquals("Default Title for Folder 1", metaData.getTitle(Locale.GERMAN));
       }
  +    
  +    public void testPageMetaData() throws Exception
  +    {	
  +        Page page = pageManager.getPage("default-page.psml");
  +        assertNotNull(page);
  +        String frenchTitle = page.getTitle(Locale.FRENCH);
  +        assertNotNull(frenchTitle);
  +        assertEquals("Ma Premiere Page de PSML", frenchTitle);
  +        String defaultTitle = page.getTitle(Locale.GERMAN);
  +        assertNotNull(defaultTitle);
  +        assertEquals("My First PSML Page", defaultTitle);
  +    }
   }
  
  
  
  1.9       +2 -2      jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java
  
  Index: CastorXmlPageManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/CastorXmlPageManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CastorXmlPageManager.java	24 Aug 2004 14:14:29 -0000	1.8
  +++ CastorXmlPageManager.java	24 Aug 2004 21:33:05 -0000	1.9
  @@ -458,8 +458,8 @@
               mapping = new Mapping();
   
               InputSource is = new InputSource(stream);
  +           
               is.setSystemId(mapFileResource);
  -
               mapping.loadMapping(is);
           }
           catch (Exception e)
  
  
  

---------------------------------------------------------------------
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