diff options
author | Olivier Lamy <olamy@apache.org> | 2014-04-16 18:11:38 +1000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-04-16 18:11:38 +1000 |
commit | ec1e655c9d996f20bd231b21505a6df865d8a1f7 (patch) | |
tree | 83a6e56ba6b0e2a0f9e0bd97c2ddd1b05b5d90aa /archiva-modules/plugins/metadata-store-file/src | |
parent | 767e00c182085b193c9f2481a815e90c5c054095 (diff) | |
download | archiva-ec1e655c9d996f20bd231b21505a6df865d8a1f7.tar.gz archiva-ec1e655c9d996f20bd231b21505a6df865d8a1f7.zip |
use Files.copy from java.nio.file
Diffstat (limited to 'archiva-modules/plugins/metadata-store-file/src')
-rw-r--r-- | archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index d4b3c6fed..15129c9a4 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -37,15 +37,15 @@ import org.apache.archiva.metadata.model.Scm; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -61,6 +61,8 @@ import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; +//import org.apache.commons.io.IOUtils; + public class FileMetadataRepository implements MetadataRepository { @@ -575,7 +577,7 @@ public class FileMetadataRepository } @Override - public <T>T obtainAccess( Class<T> aClass ) + public <T> T obtainAccess( Class<T> aClass ) { throw new IllegalArgumentException( "Access using " + aClass + " is not supported on the file metadata storage" ); @@ -647,7 +649,8 @@ public class FileMetadataRepository File directory = new File( getDirectory( artifactMetadata.getRepositoryId() ), artifactMetadata.getNamespace() + "/" + artifactMetadata.getProject() + "/" - + baseVersion ); + + baseVersion + ); Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY ); @@ -870,16 +873,11 @@ public class FileMetadataRepository throws IOException { Properties properties = new Properties(); - FileInputStream in = null; - try + try (InputStream in = Files.newInputStream( new File( directory, propertiesKey + ".properties" ).toPath() )) { - in = new FileInputStream( new File( directory, propertiesKey + ".properties" ) ); + properties.load( in ); } - finally - { - IOUtils.closeQuietly( in ); - } return properties; } @@ -1240,15 +1238,10 @@ public class FileMetadataRepository throws IOException { directory.mkdirs(); - FileOutputStream os = new FileOutputStream( new File( directory, propertiesKey + ".properties" ) ); - try + try (OutputStream os = Files.newOutputStream( new File( directory, propertiesKey + ".properties" ).toPath() )) { properties.store( os, null ); } - finally - { - IOUtils.closeQuietly( os ); - } } private static class ArtifactComparator |