From 2132965397ca7d93a66c2eea3dfce98ca377268d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 17 Apr 2014 10:46:06 +1000 Subject: more code simplification with 1.7 features --- .../converter/artifact/LegacyToDefaultConverter.java | 19 ++++--------------- .../consumers/core/ValidateChecksumConsumer.java | 12 ------------ 2 files changed, 4 insertions(+), 27 deletions(-) (limited to 'archiva-modules/archiva-base') diff --git a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java index 3635408df..ba8bf2703 100644 --- a/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java +++ b/archiva-modules/archiva-base/archiva-artifact-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverter.java @@ -51,12 +51,12 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import javax.inject.Inject; import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; +import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -393,24 +393,13 @@ public class LegacyToDefaultConverter private Metadata readMetadata( File file ) throws ArtifactConversionException { - Metadata metadata; MetadataXpp3Reader reader = new MetadataXpp3Reader(); - try (FileReader fileReader = new FileReader( file )) + try (Reader fileReader = Files.newBufferedReader( file.toPath(), Charset.defaultCharset() )) { return reader.read( fileReader ); } - catch ( FileNotFoundException e ) - { - throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ), - e ); //$NON-NLS-1$ - } - catch ( IOException e ) - { - throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ), - e ); //$NON-NLS-1$ - } - catch ( XmlPullParserException e ) + catch ( IOException | XmlPullParserException e ) { throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ), e ); //$NON-NLS-1$ diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java index 0a8f22ffc..07f108c30 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ValidateChecksumConsumer.java @@ -60,24 +60,12 @@ public class ValidateChecksumConsumer private static final String CHECKSUM_IO_ERROR = "checksum-io-error"; - /** - * default-value="validate-checksums" - */ private String id = "validate-checksums"; - /** - * default-value="Validate checksums against file." - */ private String description = "Validate checksums against file."; - /** - * - */ private ChecksumFile checksum; - /** - * - */ private List allDigesters; @Inject -- cgit v1.2.3