o used exception chaining as much as possible

o added generics to PomProcessor
o fixed code style

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@746072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2009-02-20 00:41:01 +00:00
parent 0c1aaae366
commit 70895b5f43
4 changed files with 20 additions and 13 deletions

View File

@ -91,7 +91,9 @@ public final class MavenDependencyProcessor
byte[] superBytes = mdReader.readMetadata( bmd ); byte[] superBytes = mdReader.readMetadata( bmd );
if ( superBytes == null || superBytes.length < 1 ) if ( superBytes == null || superBytes.length < 1 )
{
throw new DependencyProcessorException( "cannot read metadata for " + bmd.getGAV() ); throw new DependencyProcessorException( "cannot read metadata for " + bmd.getGAV() );
}
MavenDomainModel domainModel = new MavenDomainModel( superBytes ); MavenDomainModel domainModel = new MavenDomainModel( superBytes );
domainModels.add( domainModel ); domainModels.add( domainModel );
@ -105,14 +107,16 @@ public final class MavenDependencyProcessor
List<DomainModel> parentModels = getParentsOfDomainModel( domainModel, mdReader ); List<DomainModel> parentModels = getParentsOfDomainModel( domainModel, mdReader );
if( parentModels == null ) if ( parentModels == null )
{
throw new DependencyProcessorException( "cannot read parent for " + bmd.getGAV() ); throw new DependencyProcessorException( "cannot read parent for " + bmd.getGAV() );
}
domainModels.addAll( parentModels ); domainModels.addAll( parentModels );
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new MetadataReaderException( "Failed to create domain model. Message = " + e.getMessage() ); throw new MetadataReaderException( "Failed to create domain model. Message = " + e.getMessage(), e );
} }
PomTransformer transformer = new PomTransformer( new MavenDomainModelFactory() ); PomTransformer transformer = new PomTransformer( new MavenDomainModelFactory() );
@ -128,7 +132,7 @@ public final class MavenDependencyProcessor
} }
catch ( IOException e ) catch ( IOException e )
{ {
throw new MetadataReaderException( "Unable to transform model" ); throw new MetadataReaderException( "Unable to transform model", e );
} }
} }
@ -141,10 +145,11 @@ public final class MavenDependencyProcessor
byte[] b = mdReader.readMetadata( domainModel.getParentMetadata() ); byte[] b = mdReader.readMetadata( domainModel.getParentMetadata() );
if ( b == null || b.length < 1 ) if ( b == null || b.length < 1 )
{
throw new DependencyProcessorException( "cannot read metadata for " + domainModel.getParentMetadata() ); throw new DependencyProcessorException( "cannot read metadata for " + domainModel.getParentMetadata() );
}
MavenDomainModel parentDomainModel = MavenDomainModel parentDomainModel = new MavenDomainModel( b );
new MavenDomainModel( b );
domainModels.add( parentDomainModel ); domainModels.add( parentDomainModel );
domainModels.addAll( getParentsOfDomainModel( parentDomainModel, mdReader ) ); domainModels.addAll( getParentsOfDomainModel( parentDomainModel, mdReader ) );
} }

View File

@ -247,7 +247,7 @@ public final class MavenDomainModel
} }
ModelDataSource dataSource = new DefaultModelDataSource( container.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), ModelDataSource dataSource = new DefaultModelDataSource( container.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
new ExclusionModelContainerFactory() )); new ExclusionModelContainerFactory() ) );
List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>(); List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
for ( ModelContainer exclusion : dataSource.queryFor( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri ) ) for ( ModelContainer exclusion : dataSource.queryFor( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri ) )

View File

@ -10,6 +10,7 @@ import java.util.List;
public interface PomProcessor public interface PomProcessor
{ {
List<ModelProperty> getRawPom(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map env, Map sysProps) List<ModelProperty> getRawPom(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map<String, String> env,
Map<String, String> sysProps)
throws MetadataReaderException, PomProcessorException; throws MetadataReaderException, PomProcessorException;
} }

View File

@ -1,6 +1,7 @@
package org.apache.maven.mercury; package org.apache.maven.mercury;
public class PomProcessorException extends Exception public class PomProcessorException
extends Exception
{ {
static final long serialVersionUID = 980457843528974352L; static final long serialVersionUID = 980457843528974352L;