error handling

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412327 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-06-07 08:46:19 +00:00
parent f1f69f4c8a
commit 9202e38f96
2 changed files with 94 additions and 89 deletions

View File

@ -463,7 +463,6 @@ public class DefaultRepositoryConverter
} }
catch ( PomTranslationException e ) catch ( PomTranslationException e )
{ {
// TODO! check handling, fix error message
reporter.addFailure( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) ); reporter.addFailure( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) );
result = false; result = false;
} }

View File

@ -26,7 +26,6 @@ import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -92,16 +91,41 @@ public class DefaultMetadataDiscoverer
*/ */
private RepositoryMetadata buildMetadata( String repo, String metadataPath ) private RepositoryMetadata buildMetadata( String repo, String metadataPath )
{ {
RepositoryMetadata metadata = null; Metadata m = null;
String repoPath = repo + "/" + metadataPath;
try try
{ {
URL url = new File( repo + "/" + metadataPath ).toURL(); URL url = new File( repoPath ).toURL();
InputStream is = url.openStream(); InputStream is = url.openStream();
Reader reader = new InputStreamReader( is ); Reader reader = new InputStreamReader( is );
MetadataXpp3Reader metadataReader = new MetadataXpp3Reader(); MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
Metadata m = metadataReader.read( reader ); 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 );
}
RepositoryMetadata repositoryMetadata = null;
if ( m != null )
{
repositoryMetadata = buildMetadata( m, metadataPath );
}
return repositoryMetadata;
}
private RepositoryMetadata buildMetadata( Metadata m, String metadataPath )
{
String metaGroupId = m.getGroupId(); String metaGroupId = m.getGroupId();
String metaArtifactId = m.getArtifactId(); String metaArtifactId = m.getArtifactId();
String metaVersion = m.getVersion(); String metaVersion = m.getVersion();
@ -135,6 +159,7 @@ public class DefaultMetadataDiscoverer
} }
// snapshotMetadata // snapshotMetadata
RepositoryMetadata metadata = null;
if ( tmpDir != null && tmpDir.equals( metaVersion ) ) if ( tmpDir != null && tmpDir.equals( metaVersion ) )
{ {
if ( artifact != null ) if ( artifact != null )
@ -152,7 +177,6 @@ public class DefaultMetadataDiscoverer
} }
else else
{ {
String groupDir = ""; String groupDir = "";
int ctr = 0; int ctr = 0;
for ( it = pathParts.iterator(); it.hasNext(); ) for ( it = pathParts.iterator(); it.hasNext(); )
@ -176,24 +200,6 @@ public class DefaultMetadataDiscoverer
} }
} }
}
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!
}
return metadata; return metadata;
} }
} }