avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl DefaultContainmentModel.java
Date Tue, 09 Sep 2003 12:56:29 GMT
mcconnell    2003/09/09 05:56:29

  Modified:    merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultContainmentModel.java
  Log:
  Improved reporting.
  
  Revision  Changes    Path
  1.4       +50 -6     avalon-sandbox/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
  
  Index: DefaultContainmentModel.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultContainmentModel.java	9 Sep 2003 12:32:03 -0000	1.3
  +++ DefaultContainmentModel.java	9 Sep 2003 12:56:29 -0000	1.4
  @@ -56,6 +56,7 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.net.URLClassLoader;
  +import java.net.URLConnection;
   import java.util.Hashtable;
   import java.util.List;
   import java.util.ArrayList;
  @@ -511,7 +512,8 @@
                   {
                       if( child instanceof DeploymentModel )
                       {
  -                        ((DeploymentModel)child).setConfiguration( target.getConfiguration()
);
  +                        ((DeploymentModel)child).setConfiguration( 
  +                          target.getConfiguration() );
                       }
                       else if( child instanceof ContainmentModel )
                       {
  @@ -525,11 +527,13 @@
                   {
                       if( child instanceof DeploymentModel )
                       {
  -                        ((DeploymentModel)child).setCategories( target.getCategoriesDirective()
);
  +                        ((DeploymentModel)child).setCategories( 
  +                           target.getCategoriesDirective() );
                       }
                       else if( child instanceof ContainmentModel )
                       {
  -                        ((ContainmentModel)child).setCategories( target.getCategoriesDirective()
);
  +                        ((ContainmentModel)child).setCategories( 
  +                          target.getCategoriesDirective() );
                       }
                   }
               }
  @@ -605,7 +609,8 @@
                   catch( Throwable e )
                   {
                       final String error = 
  -                    "Unable to create block from embedded descriptor [" + blockURL.toString()

  +                    "Unable to create block from embedded descriptor [" 
  +                      + blockURL.toString() 
                       + "] in the containmment model [" 
                       + getQualifiedName() 
                       + "] due to a build related error.";
  @@ -630,6 +635,14 @@
               }
               else if( path.endsWith( "/" ) )
               {
  +
  +                verifyPath( path );
  +
  +                //
  +                // TODO: add validation that the path exists
  +                // before appending 
  +                //
  +
                   final URL blockURL = 
                     new URL( url.toString() + "BLOCK-INF/block.xml" );
   
  @@ -645,7 +658,8 @@
                     "including composite block: " + blockURL.toString();
                   getLogger().debug( message );
   
  -                return createContainmentModel( getName( name, profile ), profile, new URL[]{
url }  );
  +                return createContainmentModel( 
  +                  getName( name, profile ), profile, new URL[]{ url }  );
               }
               else
               {
  @@ -681,6 +695,36 @@
                 + "] into the containmment model [" 
                 + getQualifiedName() 
                 + "] because of an unexpected error.";
  +            throw new ModelException( error, e );
  +        }
  +    }
  +
  +   /**
  +    * Verify the a path is valid.  The implementation will 
  +    * throw an exception if a connection to a url established 
  +    * using the path agument cann be resolved.
  +    *
  +    * @exception ModelException if the path is not resolvable 
  +    *    to a url connection
  +    */
  +    private void verifyPath( String path ) throws ModelException
  +    {
  +        try
  +        {
  +            URL url = new URL( path );
  +            URLConnection connection = url.openConnection();
  +            connection.connect();
  +        }
  +        catch( java.io.FileNotFoundException e )
  +        {
  +            final String error = 
  +              "Invalid path: " + path;
  +            throw new ModelException( error );
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Invalid path: " + path;
               throw new ModelException( error, e );
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message