maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r412327 - in /maven/repository-manager/trunk: maven-repository-converter/src/main/java/org/apache/maven/repository/converter/ maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/
Date Wed, 07 Jun 2006 08:46:19 GMT
Author: brett
Date: Wed Jun  7 01:46:19 2006
New Revision: 412327

URL: http://svn.apache.org/viewvc?rev=412327&view=rev
Log:
error handling

Modified:
    maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java

Modified: maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java?rev=412327&r1=412326&r2=412327&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
(original)
+++ maven/repository-manager/trunk/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java
Wed Jun  7 01:46:19 2006
@@ -463,7 +463,6 @@
                 }
                 catch ( PomTranslationException e )
                 {
-                    // TODO! check handling, fix error message
                     reporter.addFailure( artifact, getI18NString( "failure.invalid.source.pom",
e.getMessage() ) );
                     result = false;
                 }

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java?rev=412327&r1=412326&r2=412327&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
Wed Jun  7 01:46:19 2006
@@ -26,7 +26,6 @@
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -92,106 +91,113 @@
      */
     private RepositoryMetadata buildMetadata( String repo, String metadataPath )
     {
-        RepositoryMetadata metadata = null;
-
+        Metadata m = null;
+        String repoPath = repo + "/" + metadataPath;
         try
         {
-            URL url = new File( repo + "/" + metadataPath ).toURL();
+            URL url = new File( repoPath ).toURL();
             InputStream is = url.openStream();
             Reader reader = new InputStreamReader( is );
             MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
 
-            Metadata m = metadataReader.read( reader );
-            String metaGroupId = m.getGroupId();
-            String metaArtifactId = m.getArtifactId();
-            String metaVersion = m.getVersion();
+            m = metadataReader.read( reader );
+        }
+        catch ( XmlPullParserException e )
+        {
+            getLogger().error( "Error parsing metadata file '" + repoPath + "': " + e.getMessage(),
e );
+        }
+        catch ( MalformedURLException e )
+        {
+            // shouldn't happen
+            getLogger().error( "Error constructing metadata file '" + repoPath + "': " +
e.getMessage(), e );
+        }
+        catch ( IOException e )
+        {
+            getLogger().error( "Error reading metadata file '" + repoPath + "': " + e.getMessage(),
e );
+        }
 
-            // check if the groupId, artifactId and version is in the
-            // metadataPath
-            // parse the path, in reverse order
-            List pathParts = new ArrayList();
-            StringTokenizer st = new StringTokenizer( metadataPath, "/\\" );
-            while ( st.hasMoreTokens() )
-            {
-                pathParts.add( st.nextToken() );
-            }
+        RepositoryMetadata repositoryMetadata = null;
+        if ( m != null )
+        {
+            repositoryMetadata = buildMetadata( m, metadataPath );
+        }
+        return repositoryMetadata;
+    }
 
-            Collections.reverse( pathParts );
-            // remove the metadata file
-            pathParts.remove( 0 );
-            Iterator it = pathParts.iterator();
-            String tmpDir = (String) it.next();
+    private RepositoryMetadata buildMetadata( Metadata m, String metadataPath )
+    {
+        String metaGroupId = m.getGroupId();
+        String metaArtifactId = m.getArtifactId();
+        String metaVersion = m.getVersion();
+
+        // check if the groupId, artifactId and version is in the
+        // metadataPath
+        // parse the path, in reverse order
+        List pathParts = new ArrayList();
+        StringTokenizer st = new StringTokenizer( metadataPath, "/\\" );
+        while ( st.hasMoreTokens() )
+        {
+            pathParts.add( st.nextToken() );
+        }
 
-            //ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
-            //if( metaVersion != null && !metaVersion.equals( "" ) )
-            //{
-            //   VersionRange version = VersionRange.createFromVersion( metaVersion );
-            //}
+        Collections.reverse( pathParts );
+        // remove the metadata file
+        pathParts.remove( 0 );
+        Iterator it = pathParts.iterator();
+        String tmpDir = (String) it.next();
+
+        //ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
+        //if( metaVersion != null && !metaVersion.equals( "" ) )
+        //{
+        //   VersionRange version = VersionRange.createFromVersion( metaVersion );
+        //}
 
-            Artifact artifact = null;
-            if ( metaVersion != null && !"".equals( metaVersion ) )
-            {
-                artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId,
metaVersion, "jar" );
-            }
+        Artifact artifact = null;
+        if ( metaVersion != null && !"".equals( metaVersion ) )
+        {
+            artifact = artifactFactory.createBuildArtifact( metaGroupId, metaArtifactId,
metaVersion, "jar" );
+        }
 
-            // snapshotMetadata
-            if ( tmpDir != null && tmpDir.equals( metaVersion ) )
+        // snapshotMetadata
+        RepositoryMetadata metadata = null;
+        if ( tmpDir != null && tmpDir.equals( metaVersion ) )
+        {
+            if ( artifact != null )
             {
-                if ( artifact != null )
-                {
-                    metadata = new SnapshotArtifactRepositoryMetadata( artifact );
-                }
+                metadata = new SnapshotArtifactRepositoryMetadata( artifact );
             }
-            else if ( tmpDir != null && tmpDir.equals( metaArtifactId ) )
+        }
+        else if ( tmpDir != null && tmpDir.equals( metaArtifactId ) )
+        {
+            // artifactMetadata
+            if ( artifact != null )
             {
-                // artifactMetadata
-                if ( artifact != null )
-                {
-                    metadata = new ArtifactRepositoryMetadata( artifact );
-                }
+                metadata = new ArtifactRepositoryMetadata( artifact );
             }
-            else
+        }
+        else
+        {
+            String groupDir = "";
+            int ctr = 0;
+            for ( it = pathParts.iterator(); it.hasNext(); )
             {
-
-                String groupDir = "";
-                int ctr = 0;
-                for ( it = pathParts.iterator(); it.hasNext(); )
+                String path = (String) it.next();
+                if ( ctr == 0 )
                 {
-                    String path = (String) it.next();
-                    if ( ctr == 0 )
-                    {
-                        groupDir = path;
-                    }
-                    else
-                    {
-                        groupDir = path + "." + groupDir;
-                    }
-                    ctr++;
+                    groupDir = path;
                 }
-
-                // groupMetadata
-                if ( metaGroupId != null && metaGroupId.equals( groupDir ) )
+                else
                 {
-                    metadata = new GroupRepositoryMetadata( metaGroupId );
+                    groupDir = path + "." + groupDir;
                 }
+                ctr++;
             }
 
-        }
-        catch ( FileNotFoundException fe )
-        {
-            // TODO: log ignored metadata!
-        }
-        catch ( XmlPullParserException xe )
-        {
-            // TODO: log ignored metadata!
-        }
-        catch ( MalformedURLException e )
-        {
-            // TODO: log ignored metadata!
-        }
-        catch ( IOException ie )
-        {
-            // TODO: log ignored metadata!
+            // groupMetadata
+            if ( metaGroupId != null && metaGroupId.equals( groupDir ) )
+            {
+                metadata = new GroupRepositoryMetadata( metaGroupId );
+            }
         }
 
         return metadata;



Mime
View raw message