From 70895b5f439abf0adb15f1c5fb91bd5326cd7344 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Fri, 20 Feb 2009 00:41:01 +0000 Subject: [PATCH] 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 --- .../mercury/MavenDependencyProcessor.java | 19 ++++++++++++------- .../maven/mercury/MavenDomainModel.java | 8 ++++---- .../apache/maven/mercury/PomProcessor.java | 3 ++- .../maven/mercury/PomProcessorException.java | 3 ++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java index 77d4ddc915..9c702d02e1 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java @@ -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 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 ) ); } diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java index 19561d8186..6543098a0f 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java @@ -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 modelProperties ) @@ -247,7 +247,7 @@ public final class MavenDomainModel } ModelDataSource dataSource = new DefaultModelDataSource( container.getProperties(), Arrays.asList( new ArtifactModelContainerFactory(), - new ExclusionModelContainerFactory() )); + new ExclusionModelContainerFactory() ) ); List exclusions = new ArrayList(); for ( ModelContainer exclusion : dataSource.queryFor( ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri ) ) diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java index e91d454afe..8ddbb1dc5b 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessor.java @@ -10,6 +10,7 @@ import java.util.List; public interface PomProcessor { - List getRawPom(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map env, Map sysProps) + List getRawPom(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map env, + Map sysProps) throws MetadataReaderException, PomProcessorException; } diff --git a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java index 63bb1b52f1..ad523233c7 100644 --- a/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java +++ b/maven-mercury/src/main/java/org/apache/maven/mercury/PomProcessorException.java @@ -1,6 +1,7 @@ package org.apache.maven.mercury; -public class PomProcessorException extends Exception +public class PomProcessorException + extends Exception { static final long serialVersionUID = 980457843528974352L;