mirror of https://github.com/apache/archiva.git
[MRM-1102] don't swallow parsing exception too early where it still has context, and only log the message not the trace in scanning
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@751932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0715c95f8c
commit
0fcfb7e339
|
@ -28,9 +28,9 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
|||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
/**
|
||||
* ProjectReaderConsumer
|
||||
|
@ -117,7 +117,7 @@ public class ProjectReaderConsumer
|
|||
System.err.println( "Got null model on " + pomFile );
|
||||
}
|
||||
}
|
||||
catch ( ProjectModelException e )
|
||||
catch ( XMLException e )
|
||||
{
|
||||
System.err.println( "Unable to process: " + pomFile );
|
||||
e.printStackTrace( System.out );
|
||||
|
|
|
@ -41,11 +41,11 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
|||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.cache.Cache;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -178,9 +178,9 @@ public class ProjectModelToDatabaseConsumer
|
|||
}
|
||||
|
||||
}
|
||||
catch ( ProjectModelException e )
|
||||
catch ( XMLException e )
|
||||
{
|
||||
log.warn( "Unable to read project model " + artifactFile + " : " + e.getMessage(), e );
|
||||
log.warn( "Unable to read project model " + artifactFile + " : " + e.getMessage() );
|
||||
|
||||
addProblem( artifact, "Unable to read project model " + artifactFile + " : " + e.getMessage() );
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.maven.archiva.repository.project;
|
|||
*/
|
||||
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -30,5 +31,6 @@ import java.io.File;
|
|||
*/
|
||||
public interface ProjectModelReader
|
||||
{
|
||||
public ArchivaProjectModel read( File pomFile ) throws ProjectModelException;
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws XMLException;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,12 @@ package org.apache.maven.archiva.repository.project.readers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
|
@ -30,18 +36,11 @@ import org.apache.maven.archiva.model.MailingList;
|
|||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.apache.maven.archiva.xml.XMLReader;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* ProjectModel300Reader
|
||||
*
|
||||
|
@ -52,9 +51,7 @@ public class ProjectModel300Reader
|
|||
{
|
||||
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws ProjectModelException
|
||||
{
|
||||
try
|
||||
throws XMLException
|
||||
{
|
||||
XMLReader xml = new XMLReader( "project", pomFile );
|
||||
|
||||
|
@ -93,26 +90,16 @@ public class ProjectModel300Reader
|
|||
model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) );
|
||||
model.setDependencies( getDependencies( xml ) );
|
||||
|
||||
model.setOrigin("filesystem");
|
||||
model.setOrigin( "filesystem" );
|
||||
|
||||
/* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files.
|
||||
*
|
||||
* model.setDependencyManagement()
|
||||
* model.setPlugins()
|
||||
* model.setParentProject()
|
||||
* model.setPackaging()
|
||||
* model.setCiManagement()
|
||||
* model.setBuildExtensions()
|
||||
* model.setRelocation()
|
||||
/*
|
||||
* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files. model.setDependencyManagement()
|
||||
* model.setPlugins() model.setParentProject() model.setPackaging() model.setCiManagement()
|
||||
* model.setBuildExtensions() model.setRelocation()
|
||||
*/
|
||||
|
||||
return model;
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
throw new ProjectModelException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,12 @@ package org.apache.maven.archiva.repository.project.readers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
|
@ -34,18 +40,11 @@ import org.apache.maven.archiva.model.Organization;
|
|||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.apache.maven.archiva.xml.XMLReader;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* ProjectModel400Reader - read in modelVersion 4.0.0 pom files into archiva-model structures.
|
||||
*
|
||||
|
@ -54,11 +53,8 @@ import java.util.Properties;
|
|||
public class ProjectModel400Reader
|
||||
implements ProjectModelReader
|
||||
{
|
||||
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws ProjectModelException
|
||||
{
|
||||
try
|
||||
throws XMLException
|
||||
{
|
||||
XMLReader xml = new XMLReader( "project", pomFile );
|
||||
|
||||
|
@ -104,15 +100,10 @@ public class ProjectModel400Reader
|
|||
|
||||
model.setRelocation( getRelocation( xml ) );
|
||||
|
||||
model.setOrigin("filesystem");
|
||||
model.setOrigin( "filesystem" );
|
||||
|
||||
return model;
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
throw new ProjectModelException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.maven.archiva.repository.project.resolvers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
|
@ -26,8 +28,7 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
|||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
/**
|
||||
* Resolve Project from managed repository.
|
||||
|
@ -55,7 +56,14 @@ public class ManagedRepositoryProjectResolver
|
|||
|
||||
File repoFile = repository.toFile( artifact );
|
||||
|
||||
try
|
||||
{
|
||||
return reader.read( repoFile );
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
throw new ProjectModelException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
|||
import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
@ -56,7 +57,7 @@ public class EffectiveProjectModelFilterTest
|
|||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
|||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -136,7 +137,7 @@ public class ProjectModelExpressionExpanderTest
|
|||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.archiva.repository.project.readers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ProjectModel300ReaderTest
|
||||
*
|
||||
|
@ -36,7 +36,7 @@ public class ProjectModel300ReaderTest
|
|||
extends PlexusInSpringTestCase
|
||||
{
|
||||
public void testLoadSimple()
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/legacy-repository" );
|
||||
File pomFile = new File( defaultRepoDir, "org.apache.maven/poms/maven-model-v3-2.0.pom" );
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.maven.archiva.repository.project.readers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ProjectModel400ReaderTest
|
||||
*
|
||||
|
@ -36,7 +36,7 @@ public class ProjectModel400ReaderTest
|
|||
extends PlexusInSpringTestCase
|
||||
{
|
||||
public void testLoadSimple()
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
|
||||
File pomFile = new File( defaultRepoDir,
|
||||
|
@ -66,7 +66,7 @@ public class ProjectModel400ReaderTest
|
|||
}
|
||||
|
||||
public void testLoadWithNamespace()
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
|
||||
File pomFile = new File( defaultRepoDir,
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.maven.archiva.repository.project.ProjectModelException;
|
|||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
|
@ -128,7 +129,7 @@ public class ProjectModel400WriterTest
|
|||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws ProjectModelException
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
|
|
Loading…
Reference in New Issue