akarasulu    2003/11/10 15:43:50

  Modified:    repository/api/src/java/org/apache/avalon/repository
                        RepositoryUtils.java
  Log:
  
  
  Revision  Changes    Path
  1.2       +54 -1     
avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/RepositoryUtils.java
  
  Index: RepositoryUtils.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/repository/api/src/java/org/apache/avalon/repository/RepositoryUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RepositoryUtils.java      9 Nov 2003 09:13:58 -0000       1.1
  +++ RepositoryUtils.java      10 Nov 2003 23:43:50 -0000      1.2
  @@ -125,6 +125,59 @@
        * @return the loaded properties for the file
        * @throws IOException if there is any problem loading the properties
        */
  +    public static Properties getProperties( String [] a_repos, 
  +        ArtifactDescriptor a_artifact ) throws RepositoryException
  +    {
  +        Throwable l_throwable = null ;
  +        Properties l_props = null ;
  +        
  +        for( int ii = 0; ii < a_repos.length; ii++ )
  +        {
  +            StringBuffer l_buf = new StringBuffer( a_repos[ii] ) ;
  +        
  +            if ( l_buf.charAt( l_buf.length() - 1 ) != '/' )
  +            {
  +                l_buf.append( '/' ) ;
  +            }
  +            
  +            l_buf.append( a_artifact.getGroup() ).append( '/' ) ;
  +            l_buf.append( "propertiess/" ) ;
  +            l_buf.append( a_artifact.getName() ).append( '-' ) ;
  +            l_buf.append( a_artifact.getVersion() ) ;
  +            l_buf.append( ".jar.properties" ) ;
  +
  +            try
  +            {
  +                URL l_url = new URL( l_buf.toString() ) ;
  +                l_props = getProperties( l_url ) ;
  +                return l_props ;
  +            }
  +            catch ( Throwable e )
  +            {
  +                l_throwable = e ;
  +            }
  +        }
  +
  +        StringBuffer l_repos = new StringBuffer() ;
  +        for ( int ii = 0; ii < a_repos.length; ii++ )
  +        {
  +            l_repos.append( a_repos[ii] ).append( ',' ) ;
  +        }
  +
  +        throw new RepositoryException( 
  +            "None of the repositories " + l_repos.toString() 
  +            + " contained the metadata properties for "
  +            + a_artifact, l_throwable ) ;
  +    }
  +    
  +    
  +    /**
  +     * Gets the Properties in a remote properties file.
  +     * 
  +     * @param a_url the url to the properties file
  +     * @return the loaded properties for the file
  +     * @throws IOException if there is any problem loading the properties
  +     */
       public static Properties getProperties( URL a_url ) throws IOException
       {
           InputStream l_in = null ;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to