maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r737595 - in /maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model: ./ src/main/java/org/apache/maven/doxia/site/decoration/inheritance/ src/main/mdo/ src/test/resources/
Date Sun, 25 Jan 2009 22:32:15 GMT
Author: dennisl
Date: Sun Jan 25 22:32:15 2009
New Revision: 737595

URL: http://svn.apache.org/viewvc?rev=737595&view=rev
Log:
[DOXIA-254] Merge revisions 629097, 736603, 736628 and 736630 from trunk.

Modified:
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/pom.xml
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/mdo/decoration.mdo
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/child.xml
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/merged.xml
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/parent.xml
    maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/relative-urls-resolved.xml

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/pom.xml?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/pom.xml
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/pom.xml
Sun Jan 25 22:32:15 2009
@@ -41,16 +41,6 @@
   </dependencies>
 
   <build>
-    <pluginManagement>
-      <plugins>
-        <!-- TODO need to upgrade to last version -->
-        <plugin>
-          <groupId>org.codehaus.modello</groupId>
-          <artifactId>modello-maven-plugin</artifactId>
-          <version>1.0-alpha-17</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.codehaus.modello</groupId>

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/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/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
Sun Jan 25 22:32:15 2009
@@ -31,6 +31,7 @@
 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.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 /**
@@ -38,6 +39,7 @@
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version $Id$
  * @plexus.component role="org.apache.maven.doxia.site.decoration.inheritance.DecorationModelInheritanceAssembler"
  */
 public class DefaultDecorationModelInheritanceAssembler implements DecorationModelInheritanceAssembler
@@ -250,9 +252,13 @@
 
     private void resolveLinkItemPaths( LinkItem item, final URLContainer urlContainer )
     {
-        if ( item.getHref() != null )
+        if ( StringUtils.isNotEmpty( item.getHref() ) )
         {
-            item.setHref( convertPath( item.getHref(), urlContainer ) );
+            String href = convertPath( item.getHref(), urlContainer );
+            if ( StringUtils.isNotEmpty( href ) )
+            {
+                item.setHref( href );
+            }
         }
         else
         {

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/PathUtils.java
Sun Jan 25 22:32:15 2009
@@ -19,13 +19,13 @@
  * under the License.
  */
 
-import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.StringTokenizer;
+
+import org.codehaus.plexus.util.PathTool;
 
 /**
- * Utilitites that allow conversion of old and new pathes and URLs relative to each other.
+ * Utilities that allow conversion of old and new pathes and URLs relative to each other.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
@@ -35,8 +35,15 @@
 {
     private PathUtils()
     {
+        // nop
     }
 
+    /**
+     * @param oldPath not null
+     * @param newPath not null
+     * @return a PathDescriptor converted by the new path
+     * @throws MalformedURLException if any
+     */
     public static final PathDescriptor convertPath( final PathDescriptor oldPath, final PathDescriptor
newPath )
         throws MalformedURLException
     {
@@ -50,8 +57,15 @@
         return new PathDescriptor( relative );
     }
 
+    /**
+     * @param oldPathDescriptor not null
+     * @param newPathDescriptor not null
+     * @return a relative path depending if PathDescriptor is a file or a web url.
+     * @see PathTool#getRelativeFilePath(String, String)
+     * @see PathTool#getRelativeWebPath(String, String)
+     */
     public static final String getRelativePath( final PathDescriptor oldPathDescriptor,
-                                                final PathDescriptor newPathDescriptor )
throws MalformedURLException
+                                                final PathDescriptor newPathDescriptor )
     {
         // Cannot convert from URL to file.
         if ( oldPathDescriptor.isFile() )
@@ -65,11 +79,9 @@
                     // site into a new URL using resolvePaths()...
                     return oldPathDescriptor.getPath();
                 }
-                else
-                {
-                    // The old path is not relative. Bail out.
-                    return null;
-                }
+
+                // The old path is not relative. Bail out.
+                return null;
             }
         }
 
@@ -95,177 +107,23 @@
                 String oldPath = oldPathDescriptor.getPath();
                 String newPath = newPathDescriptor.getPath();
 
-                return getRelativeWebPath( newPath, oldPath );
-            }
-            else
-            {
-                // Different sites. No relative Path possible.
-                return null;
+                return PathTool.getRelativeWebPath( newPath, oldPath );
             }
-        }
-        else
-        {
-            // Both Descriptors point to a path. We can build a relative path.
-            String oldPath = oldPathDescriptor.getPath();
-            String newPath = newPathDescriptor.getPath();
-
-            if ( oldPath == null || newPath == null )
-            {
-                // One of the sites has a strange URL. no relative path possible, bail out.
-                return null;
-            }
-
-            return getRelativeFilePath( oldPath, newPath );
-        }
-    }
-
-    /**
-     * This method can calculate the relative path between two pathes on a web site.
-     */
-    public static final String getRelativeWebPath( final String oldPath, final String newPath
)
-    {
-        String resultPath = buildRelativePath( newPath, oldPath, '/' );
-
-        if ( newPath.endsWith( "/" ) && !resultPath.endsWith( "/" ) )
-        {
-            return resultPath + "/";
-        }
-        else
-        {
-            return resultPath;
-        }
-    }
-
-    /**
-     * This method can calculate the relative path between two pathes on a file system.
-     */
-    public static final String getRelativeFilePath( final String oldPath, final String newPath
)
-    {
-        // normalise the path delimiters
-        String fromPath = new File( oldPath ).getPath();
-        String toPath = new File( newPath ).getPath();
-
-        // strip any leading slashes if its a windows path
-        if ( toPath.matches( "^\\[a-zA-Z]:" ) )
-        {
-            toPath = toPath.substring( 1 );
-        }
-        if ( fromPath.matches( "^\\[a-zA-Z]:" ) )
-        {
-            fromPath = fromPath.substring( 1 );
-        }
-
-        // lowercase windows drive letters.
-        if ( fromPath.startsWith( ":", 1 ) )
-        {
-            fromPath = fromPath.substring( 0, 1 ).toLowerCase() + fromPath.substring( 1 );
-        }
-        if ( toPath.startsWith( ":", 1 ) )
-        {
-            toPath = toPath.substring( 0, 1 ).toLowerCase() + toPath.substring( 1 );
-        }
 
-        // check for the presence of windows drives. No relative way of
-        // traversing from one to the other.
-        if ( ( toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 ) )
-                        && ( !toPath.substring( 0, 1 ).equals( fromPath.substring(
0, 1 ) ) ) )
-        {
-            // they both have drive path element but they dont match, no
-            // relative path
-            return null;
-        }
-
-        if ( ( toPath.startsWith( ":", 1 ) && !fromPath.startsWith( ":", 1 ) )
-                        || ( !toPath.startsWith( ":", 1 ) && fromPath.startsWith(
":", 1 ) ) )
-        {
-            // one has a drive path element and the other doesnt, no relative
-            // path.
+            // Different sites. No relative Path possible.
             return null;
         }
 
-        String resultPath = buildRelativePath( toPath, fromPath, File.separatorChar );
+        // Both Descriptors point to a path. We can build a relative path.
+        String oldPath = oldPathDescriptor.getPath();
+        String newPath = newPathDescriptor.getPath();
 
-        if ( newPath.endsWith( File.separator ) && !resultPath.endsWith( File.separator
) )
-        {
-            return resultPath + File.separator;
-        }
-        else
+        if ( oldPath == null || newPath == null )
         {
-            return resultPath;
-        }
-    }
-
-    private static final String buildRelativePath( final String toPath, final String fromPath,
final char separatorChar )
-    {
-        // use tokeniser to traverse paths and for lazy checking
-        StringTokenizer toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar
) );
-        StringTokenizer fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar
) );
-
-        int count = 0;
-
-        // walk along the to path looking for divergence from the from path
-        while ( toTokeniser.hasMoreTokens() && fromTokeniser.hasMoreTokens() )
-        {
-            if ( separatorChar == '\\' )
-            {
-                if ( !fromTokeniser.nextToken().equalsIgnoreCase( toTokeniser.nextToken()
) )
-                {
-                    break;
-                }
-            }
-            else
-            {
-                if ( !fromTokeniser.nextToken().equals( toTokeniser.nextToken() ) )
-                {
-                    break;
-                }
-            }
-
-            count++;
-        }
-
-        // reinitialise the tokenisers to count positions to retrieve the
-        // gobbled token
-
-        toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
-        fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );
-
-        while ( count-- > 0 )
-        {
-            fromTokeniser.nextToken();
-            toTokeniser.nextToken();
-        }
-
-        String relativePath = "";
-
-        // add back refs for the rest of from location.
-        while ( fromTokeniser.hasMoreTokens() )
-        {
-            fromTokeniser.nextToken();
-
-            relativePath += "..";
-
-            if ( fromTokeniser.hasMoreTokens() )
-            {
-                relativePath += separatorChar;
-            }
-        }
-
-        if ( relativePath.length() != 0 && toTokeniser.hasMoreTokens() )
-        {
-            relativePath += separatorChar;
+            // One of the sites has a strange URL. no relative path possible, bail out.
+            return null;
         }
 
-        // add fwd fills for whatevers left of newPath.
-        while ( toTokeniser.hasMoreTokens() )
-        {
-            relativePath += toTokeniser.nextToken();
-
-            if ( toTokeniser.hasMoreTokens() )
-            {
-                relativePath += separatorChar;
-            }
-        }
-        return relativePath;
+        return PathTool.getRelativeFilePath( oldPath, newPath );
     }
 }

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/mdo/decoration.mdo
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/mdo/decoration.mdo?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/mdo/decoration.mdo
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/main/mdo/decoration.mdo
Sun Jan 25 22:32:15 2009
@@ -19,7 +19,8 @@
 under the License.
 -->
 
-<model>
+<model xmlns="http://modello.codehaus.org/MODELLO/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://modello.codehaus.org/MODELLO/1.0.0 http://modello.codehaus.org/xsd/modello-1.0.0.xsd"
+  xsd.namespace="http://maven.apache.org/DECORATION/1.0.0" xsd.target-namespace="http://maven.apache.org/DECORATION/1.0.0">
   <id>decoration</id>
   <name>Decoration</name>
   <description><![CDATA[
@@ -312,7 +313,7 @@
         </field>
       </fields>
     </class>
-    <class>
+    <class xsd.compositor="sequence">
       <name>Body</name>
       <description><![CDATA[
         The main content decoration.
@@ -349,7 +350,6 @@
           <association>
             <type>LinkItem</type>
             <multiplicity>*</multiplicity>
-            <identifier>true</identifier>
           </association>
           <identifier>true</identifier>
         </field>
@@ -394,7 +394,7 @@
         </field>
       </fields>
     </class>
-    <class>
+    <class xsd.compositor="sequence">
       <name>Menu</name>
       <description><![CDATA[
         A menu in the navigation.
@@ -413,7 +413,7 @@
         <field xml.attribute="true">
           <name>inherit</name>
           <description><![CDATA[
-            The way in which the menu is inherited.
+            The way in which the menu is inherited. Can be one of : <code>top</code>,
<code>bottom</code>.
           ]]></description>
           <version>1.0.0</version>
           <type>String</type>
@@ -461,7 +461,7 @@
         </field>
       </fields>
     </class>
-    <class>
+    <class xsd.compositor="sequence">
       <name>MenuItem</name>
       <description><![CDATA[
         A menu item.
@@ -512,7 +512,7 @@
     <class>
       <name>Skin</name>
       <description><![CDATA[
-        An skin artifact declaratio.
+        An skin artifact declaration.
       ]]></description>
       <version>1.0.0</version>
       <fields>

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/child.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/child.xml?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/child.xml
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/child.xml
Sun Jan 25 22:32:15 2009
@@ -24,8 +24,8 @@
     </links>
 
     <menu name="Subproject menu">
-      <item name="Introduction" href="/index.html"/>
-      <item name="Usage" href="/usage.html"/>
+      <item name="Introduction" href="/indexChild.html"/>
+      <item name="Usage" href="/usageChild.html"/>
     </menu>
 
   </body>

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/merged.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/merged.xml?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/merged.xml
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/merged.xml
Sun Jan 25 22:32:15 2009
@@ -47,18 +47,18 @@
     </links>
 
     <menu name="Top Menu" inherit="top">
-      <item name="Introduction" href="/index.html"/>
-      <item name="Usage" href="/usage.html"/>
+      <item name="Introduction" href="../indexParent.html"/>
+      <item name="Usage" href="../usageParent.html"/>
     </menu>
     <menu name="empty menu" inherit="top">
 
     </menu>
     <menu name="Subproject menu">
-      <item name="Introduction" href="/index.html"/>
-      <item name="Usage" href="/usage.html"/>
+      <item name="Introduction" href="/indexChild.html"/>
+      <item name="Usage" href="/usageChild.html"/>
     </menu>
     <menu name="Other Links" inherit="bottom">
-      <item name="Copyright" href="/copyright.html"/>
+      <item name="Copyright" href="../copyrightParent.html"/>
     </menu>
   </body>
 </project>

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/parent.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/parent.xml?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/parent.xml
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/parent.xml
Sun Jan 25 22:32:15 2009
@@ -43,17 +43,17 @@
     </breadcrumbs>
 
     <menu name="Top Menu" inherit="top">
-      <item name="Introduction" href="/index.html"/>
-      <item name="Usage" href="/usage.html"/>
+      <item name="Introduction" href="/indexParent.html"/>
+      <item name="Usage" href="/usageParent.html"/>
     </menu>
     <menu name="empty menu" inherit="top">
 
     </menu>
     <menu name="Special" inherit="off">
-      <item name="Special" href="/special.html"/>
+      <item name="Special" href="/specialParent.html"/>
     </menu>
     <menu name="Other Links" inherit="bottom">
-      <item name="Copyright" href="/copyright.html"/>
+      <item name="Copyright" href="/copyrightParent.html"/>
     </menu>
   </body>
 </project>

Modified: maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/relative-urls-resolved.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/relative-urls-resolved.xml?rev=737595&r1=737594&r2=737595&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/relative-urls-resolved.xml
(original)
+++ maven/doxia/doxia-sitetools/branches/doxia-sitetools-1.0.x/doxia-decoration-model/src/test/resources/relative-urls-resolved.xml
Sun Jan 25 22:32:15 2009
@@ -30,7 +30,7 @@
   </bannerRight>
 
   <poweredBy>
-    <logo name="Tomcat" href="/tomcat" img="tomcat/logo.gif"/>
+    <logo name="Tomcat" href="tomcat" img="tomcat/logo.gif"/>
   </poweredBy>
 
   <body>



Mime
View raw message