svn commit: r1142 - in development/main/transit/handler: etc/setup/authority src/main/net/dpml/transit/artifact

mcconnell at netcompartner.com mcconnell at netcompartner.com
Tue Dec 7 05:17:57 EST 2004


Author: mcconnell
Date: Tue Dec  7 11:17:57 2004
New Revision: 1142

Modified:
   development/main/transit/handler/etc/setup/authority/hosts.xml
   development/main/transit/handler/src/main/net/dpml/transit/artifact/XMLHostsBuilder.java
Log:
Add a local trusted repository to the default transit configuration and special processing for file based repository directives in the hosts.xml file (use of dir as opposed to href).

Modified: development/main/transit/handler/etc/setup/authority/hosts.xml
==============================================================================
--- development/main/transit/handler/etc/setup/authority/hosts.xml	(original)
+++ development/main/transit/handler/etc/setup/authority/hosts.xml	Tue Dec  7 11:17:57 2004
@@ -2,6 +2,11 @@
 
 <hosts>
 
+  <host dir="local">
+    <priority>10</priority>
+    <trusted>true</trusted>
+  </host>
+
   <host href="http://www.dpml.net">
     <priority>20</priority>
   </host>

Modified: development/main/transit/handler/src/main/net/dpml/transit/artifact/XMLHostsBuilder.java
==============================================================================
--- development/main/transit/handler/src/main/net/dpml/transit/artifact/XMLHostsBuilder.java	(original)
+++ development/main/transit/handler/src/main/net/dpml/transit/artifact/XMLHostsBuilder.java	Tue Dec  7 11:17:57 2004
@@ -18,11 +18,13 @@
 
 package net.dpml.transit.artifact;
 
+import java.io.File;
 import java.io.InputStream;
 import java.io.IOException;
 
 import java.net.URL;
 
+import net.dpml.transit.Transit;
 import net.dpml.transit.TransitException;
 import net.dpml.transit.util.ElementHelper;
 
@@ -111,9 +113,17 @@
         String base = ElementHelper.getAttribute( root, "href", null );
         if( null == base )
         {
-            final String error =
-              "The base element does not contain the required 'href' attribute.";
-            throw new IllegalArgumentException( error );
+            String dir = ElementHelper.getAttribute( root, "dir", null );
+            if( null == dir )
+            {
+                final String error =
+                  "The base element does not contain the an 'href' or 'dir' attribute.";
+                throw new IllegalArgumentException( error );
+            }
+            else
+            {
+                return resolveLocalRepositoryURL( dir );
+            }
         }
 
         if( !base.endsWith( "/" ) )
@@ -124,6 +134,30 @@
     }
 
    /**
+    * Resolve a base url to a local file repository using a supplied path.  If the path
+    * resolves to an absolute filename a local repository will be created at that location
+    * otherwise a repository will be created relative to ${dpml.home}.
+    * 
+    * @param path the repository path
+    * @return the repository url
+    */
+    private static URL resolveLocalRepositoryURL( String path ) throws IOException
+    {
+        File base = new File( path );
+        if( base.isAbsolute() )
+        {
+            base.mkdirs();
+            return base.toURL();
+        }
+        else
+        {
+            File dir = new File( Transit.HOME, path );
+            dir.mkdirs();
+            return dir.toURL();
+        }
+    }
+
+   /**
     * Get the index url from the supplied host element using a child element
     * named 'index' with an href attribute.
     * @param root the XML host element



More information about the dev-dpml mailing list