maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r1056527 - in /maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src: main/java/org/apache/maven/doxia/site/decoration/inheritance/ main/mdo/ test/java/org/apache/maven/doxia/site/decoration/inheritance/
Date Fri, 07 Jan 2011 21:54:22 GMT
Author: ltheussl
Date: Fri Jan  7 21:54:21 2011
New Revision: 1056527

URL: http://svn.apache.org/viewvc?rev=1056527&view=rev
Log:
[DOXIASITETOOLS-45] assembleModelInheritance modifies parent DecorationModel

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
    maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo
    maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java?rev=1056527&r1=1056526&r2=1056527&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
Fri Jan  7 21:54:21 2011
@@ -31,6 +31,10 @@ import org.apache.maven.doxia.site.decor
 import org.apache.maven.doxia.site.decoration.Logo;
 import org.apache.maven.doxia.site.decoration.Menu;
 import org.apache.maven.doxia.site.decoration.MenuItem;
+import org.apache.maven.doxia.site.decoration.PublishDate;
+import org.apache.maven.doxia.site.decoration.Skin;
+import org.apache.maven.doxia.site.decoration.Version;
+
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
@@ -53,32 +57,31 @@ public class DefaultDecorationModelInher
         // cannot inherit from null parent.
         if ( parent != null )
         {
-            if ( child.getBannerLeft() == null )
+            if ( child.getBannerLeft() == null && parent.getBannerLeft() != null
)
             {
-                child.setBannerLeft( parent.getBannerLeft() );
+                child.setBannerLeft( (Banner) parent.getBannerLeft().clone());
                 resolveBannerPaths( child.getBannerLeft(), urlContainer );
             }
 
-            if ( child.getBannerRight() == null )
+            if ( child.getBannerRight() == null && parent.getBannerRight() != null)
             {
-                child.setBannerRight( parent.getBannerRight() );
-
+                child.setBannerRight( (Banner) parent.getBannerRight().clone());
                 resolveBannerPaths( child.getBannerRight(), urlContainer );
             }
 
-            if ( child.getPublishDate() == null )
+            if ( child.getPublishDate() == null && parent.getPublishDate() != null
)
             {
-                child.setPublishDate( parent.getPublishDate() );
+                child.setPublishDate( (PublishDate) parent.getPublishDate().clone());
             }
 
-            if ( child.getVersion() == null )
+            if ( child.getVersion() == null && parent.getVersion() != null )
             {
-                child.setVersion( parent.getVersion() );
+                child.setVersion( (Version) parent.getVersion().clone());
             }
 
-            if ( child.getSkin() == null )
+            if ( child.getSkin() == null && parent.getSkin() != null )
             {
-                child.setSkin( parent.getSkin() );
+                child.setSkin( (Skin) parent.getSkin().clone());
             }
 
             child.setPoweredBy( mergePoweredByLists( child.getPoweredBy(), parent.getPoweredBy(),
urlContainer ) );
@@ -220,7 +223,7 @@ public class DefaultDecorationModelInher
 
     private List mergeMenus( final List childMenus, final List parentMenus, final URLContainer
urlContainer )
     {
-        List menus = new ArrayList();
+        List menus = new ArrayList( childMenus.size() + parentMenus.size() );
 
         for ( Iterator it = childMenus.iterator(); it.hasNext(); )
         {
@@ -232,7 +235,7 @@ public class DefaultDecorationModelInher
         int topCounter = 0;
         for ( Iterator it = parentMenus.iterator(); it.hasNext(); )
         {
-            Menu menu = (Menu) it.next();
+            Menu menu = (Menu) ( (Menu) it.next() ).clone();
 
             if ( "top".equals( menu.getInherit() ) )
             {
@@ -286,11 +289,11 @@ public class DefaultDecorationModelInher
 
     private List mergeLinkItemLists( final List childList, final List parentList, final URLContainer
urlContainer )
     {
-        List items = new ArrayList();
+        List items = new ArrayList( childList.size() + parentList.size() );
 
         for ( Iterator it = parentList.iterator(); it.hasNext(); )
         {
-            LinkItem item = (LinkItem) it.next();
+            LinkItem item = (LinkItem) ( (LinkItem) it.next() ).clone();
 
             resolveLinkItemPaths( item, urlContainer );
 
@@ -315,11 +318,11 @@ public class DefaultDecorationModelInher
 
     private List mergePoweredByLists( final List childList, final List parentList, final
URLContainer urlContainer )
     {
-        List logos = new ArrayList();
+        List logos = new ArrayList( childList.size() + parentList.size() );
 
         for ( Iterator it = parentList.iterator(); it.hasNext(); )
         {
-            Logo logo = (Logo) it.next();
+            Logo logo = (Logo) ( (Logo) it.next() ).clone();
 
             if ( !logos.contains( logo ) )
             {

Modified: maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo?rev=1056527&r1=1056526&r2=1056527&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo Fri
Jan  7 21:54:21 2011
@@ -38,7 +38,7 @@ under the License.
     </default>
   </defaults>
   <classes>
-    <class rootElement="true" xml.tagName="project">
+    <class rootElement="true" xml.tagName="project" java.clone="deep">
       <name>DecorationModel</name>
       <description><![CDATA[
          The <code>&lt;project&gt;</code> element is the root of the
site decoration descriptor.
@@ -210,7 +210,7 @@ under the License.
         </codeSegment>
       </codeSegments>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>Banner</name>
       <description>Banner logo on the masthead of the site.</description>
       <version>1.0.0+</version>
@@ -267,7 +267,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>PublishDate</name>
       <description>Modify display properties for date published.</description>
       <version>1.0.0+</version>
@@ -289,7 +289,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>Version</name>
       <description>Modify display properties for version published.</description>
       <version>1.0.0+</version>
@@ -303,13 +303,13 @@ under the License.
         </field>
       </fields>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>Logo</name>
       <description>Power by logo on the navigation.</description>
       <version>1.0.0+</version>
       <superClass>LinkItem</superClass>
     </class>
-    <class xsd.compositor="sequence">
+    <class java.clone="deep" xsd.compositor="sequence">
       <name>Body</name>
       <description>The main content decoration.</description>
       <version>1.0.0+</version>
@@ -353,7 +353,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>LinkItem</name>
       <description>A link in the navigation.</description>
       <version>1.0.0+</version>
@@ -424,7 +424,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class xsd.compositor="sequence">
+    <class java.clone="deep" xsd.compositor="sequence">
       <name>Menu</name>
       <description>A menu in the navigation.</description>
       <version>1.0.0+</version>
@@ -519,7 +519,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class xsd.compositor="sequence">
+    <class java.clone="deep" xsd.compositor="sequence">
       <name>MenuItem</name>
       <description>A menu item.</description>
       <version>1.0.0+</version>
@@ -559,7 +559,7 @@ under the License.
         </field>
       </fields>
     </class>
-    <class>
+    <class java.clone="deep">
       <name>Skin</name>
       <description>An skin artifact declaration.</description>
       <version>1.0.0+</version>

Modified: maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java?rev=1056527&r1=1056526&r2=1056527&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritenceAssemblerTest.java
Fri Jan  7 21:54:21 2011
@@ -48,7 +48,6 @@ public class DecorationModelInheritenceA
 
     private static final String NAME = "Name";
 
-    /** @throws Exception */
     public void testInheritence()
         throws IOException, XmlPullParserException
     {
@@ -60,6 +59,8 @@ public class DecorationModelInheritenceA
         DecorationModel mergedModel = readModel( "merged.xml" );
 
         assertEquals( "Check result", mergedModel, childModel );
+
+        assertEquals( "Modified parent!", readModel( "parent.xml" ), parentModel );
     }
 
     public void testPathsResolvedWhenEmpty()
@@ -74,6 +75,8 @@ public class DecorationModelInheritenceA
         DecorationModel mergedModel = readModel( "empty.xml" );
 
         assertEquals( "Check result", mergedModel, childModel );
+
+        assertEquals( "Modified parent!", readModel( "empty.xml" ), parentModel );
     }
 
     public void testPathsNotResolvedForExternalUrls()
@@ -107,6 +110,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "http://www.apache.org/special/", menuItem.getHref()
);
+
+        assertEquals( "Modified parent!", readModel( "external-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForRelativeUrls()
@@ -137,6 +142,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "../special/", menuItem.getHref() );
+
+        assertEquals( "Modified parent!", readModel( "relative-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForSubsiteUrls()
@@ -167,6 +174,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "../special/", menuItem.getHref() );
+
+        assertEquals( "Modified parent!", readModel( "subsite-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForRelativeUrlsDepthOfTwo()
@@ -198,6 +207,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "../../special/", menuItem.getHref() );
+
+        assertEquals( "Modified parent!", readModel( "relative-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForReverseRelativeUrls()
@@ -229,6 +240,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "doxia/special/", menuItem.getHref() );
+
+        assertEquals( "Modified parent!", readModel( "relative-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForReverseRelativeUrlsDepthOfTwo()
@@ -261,6 +274,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "doxia/core/special/", menuItem.getHref() );
+
+        assertEquals( "Modified parent!", readModel( "relative-urls.xml" ), parentModel );
     }
 
     public void testPathsResolvedForUnrelatedRelativeUrls()
@@ -295,6 +310,8 @@ public class DecorationModelInheritenceA
         Menu menu = (Menu) childModel.getBody().getMenus().get( 0 );
         LinkItem menuItem = (LinkItem) menu.getItems().get( 0 );
         assertEquals( "check menu item href", "http://jakarta.apache.org/special/", menuItem.getHref()
);
+
+        assertEquals( "Modified parent!", readModel( "relative-urls.xml" ), parentModel );
     }
 
     public void testNullParent()
@@ -320,6 +337,8 @@ public class DecorationModelInheritenceA
         DecorationModel mergedModel = readModel( "fully-populated-child.xml" );
 
         assertEquals( "Check result", mergedModel, childModel );
+
+        assertEquals( "Modified parent!", readModel( "fully-populated-child.xml" ), parentModel
);
     }
 
     public void testFullyPopulatedParentAndEmptyChild()
@@ -333,6 +352,8 @@ public class DecorationModelInheritenceA
         DecorationModel mergedModel = readModel( "fully-populated-merged.xml" );
 
         assertEquals( "Check result", mergedModel, childModel );
+
+        assertEquals( "Modified parent!", readModel( "fully-populated-child.xml" ), parentModel
);
     }
 
     public void testResolvingAllExternalUrls()
@@ -459,6 +480,8 @@ public class DecorationModelInheritenceA
         assertEquals( "Check size", 1, model.getPoweredBy().size() );
         assertEquals( "Check item", createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"
),
                       model.getPoweredBy().get( 0 ) );
+
+        assertEquals( "Modified parent!", new DecorationModel(), parent );
     }
 
     public void testBreadcrumbWithoutHref()



Mime
View raw message