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 );
if ( superBytes == null || superBytes.length < 1 )
{
throw new DependencyProcessorException( "cannot read metadata for " + bmd.getGAV() );
}
MavenDomainModel domainModel = new MavenDomainModel( superBytes );
domainModels.add( domainModel );
@ -104,15 +106,17 @@ public final class MavenDependencyProcessor
}
List<DomainModel> parentModels = getParentsOfDomainModel( domainModel, mdReader );
if( parentModels == null )
if ( parentModels == null )
{
throw new DependencyProcessorException( "cannot read parent for " + bmd.getGAV() );
}
domainModels.addAll( parentModels );
}
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() );
@ -128,7 +132,7 @@ public final class MavenDependencyProcessor
}
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() );
if ( b == null || b.length < 1 )
{
throw new DependencyProcessorException( "cannot read metadata for " + domainModel.getParentMetadata() );
}
MavenDomainModel parentDomainModel =
new MavenDomainModel( b );
MavenDomainModel parentDomainModel = new MavenDomainModel( b );
domainModels.add( parentDomainModel );
domainModels.addAll( getParentsOfDomainModel( parentDomainModel, mdReader ) );
}

View File

@ -63,7 +63,7 @@ public final class MavenDomainModel
/**
* Constructor
*
*
* @throws IOException if there is a problem constructing the model
*/
public MavenDomainModel( byte[] bytes )
@ -74,7 +74,7 @@ public final class MavenDomainModel
/**
* Constructor
*
*
* @throws IOException if there is a problem constructing the model
*/
public MavenDomainModel( InputStream inputStream )
@ -85,7 +85,7 @@ public final class MavenDomainModel
/**
* Constructor
*
*
* @throws IOException if there is a problem constructing the model
*/
public MavenDomainModel( List<ModelProperty> modelProperties )
@ -247,7 +247,7 @@ public final class MavenDomainModel
}
ModelDataSource dataSource = new DefaultModelDataSource( container.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(),
new ExclusionModelContainerFactory() ));
new ExclusionModelContainerFactory() ) );
List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
for ( ModelContainer exclusion : dataSource.queryFor( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri ) )

View File

@ -10,6 +10,7 @@ import java.util.List;
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;
}

View File

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