import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
-import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.archiva.xml.XMLReader;
import org.apache.commons.lang.math.NumberUtils;
import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Date;
/**
</metadata>
*/
+ private static final Logger log = LoggerFactory.getLogger( MavenMetadataReader.class );
+
/**
* Read and return the {@link org.apache.archiva.model.ArchivaRepositoryMetadata} object from the provided xml file.
*
* @return the archiva repository metadata object that represents the provided file contents.
* @throws XMLException
*/
- public static ArchivaRepositoryMetadata read( File metadataFile )
+ public static ArchivaRepositoryMetadata read( Path metadataFile )
throws XMLException
{
- XMLReader xml = new XMLReader( "metadata", metadataFile );
+ XMLReader xml = new XMLReader( "metadata", metadataFile.toFile() );
// invoke this to remove namespaces, see MRM-1136
xml.removeNamespaces();
metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
metadata.setArtifactId( xml.getElementText( "//metadata/artifactId" ) );
metadata.setVersion( xml.getElementText( "//metadata/version" ) );
- metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
- metadata.setFileSize( metadataFile.length() );
+ Date modTime;
+ try
+ {
+ modTime = new Date(Files.getLastModifiedTime( metadataFile ).toMillis( ));
+ }
+ catch ( IOException e )
+ {
+ modTime = new Date();
+ log.error("Could not read modification time of {}", metadataFile);
+ }
+ metadata.setFileLastModified( modTime );
+ try
+ {
+ metadata.setFileSize( Files.size( metadataFile ) );
+ }
+ catch ( IOException e )
+ {
+ metadata.setFileSize( 0 );
+ log.error("Could not read file size of {}", metadataFile);
+ }
metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import java.util.Properties;
}
@Override
- public void applyPolicy( String policySetting, Properties request, File localFile )
+ public void applyPolicy( String policySetting, Properties request, Path localFile )
throws PolicyViolationException, PolicyConfigurationException
{
if ( !StringUtils.equals( request.getProperty( "filetype" ), "artifact" ) )
throw new PolicyViolationException( "NO to update, " + getUpdateMode() + " policy set to NEVER." );
}
- if ( !localFile.exists() )
+ if ( !Files.exists(localFile) )
{
// No file means it's ok.
log.debug( "OK to update {}, local file does not exist.", getUpdateMode() );
Calendar cal = Calendar.getInstance();
cal.add( Calendar.DAY_OF_MONTH, -1 );
Calendar fileCal = Calendar.getInstance();
- fileCal.setTimeInMillis( localFile.lastModified() );
+ try
+ {
+ fileCal.setTimeInMillis( Files.getLastModifiedTime(localFile).toMillis() );
+ }
+ catch ( IOException e )
+ {
+ fileCal.setTimeInMillis( new Date().getTime() );
+ log.error("Could not read modification time of {}", localFile);
+ }
if ( cal.after( fileCal ) )
{
Calendar cal = Calendar.getInstance();
cal.add( Calendar.HOUR, -1 );
Calendar fileCal = Calendar.getInstance();
- fileCal.setTimeInMillis( localFile.lastModified() );
+ try
+ {
+ fileCal.setTimeInMillis( Files.getLastModifiedTime(localFile).toMillis() );
+ }
+ catch ( IOException e )
+ {
+ fileCal.setTimeInMillis( new Date().getTime() );
+ log.error("Could not read modification time of {}", localFile);
+ }
if ( cal.after( fileCal ) )
{
import org.springframework.stereotype.Service;
import javax.inject.Inject;
-import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
}
@Override
- public void applyPolicy( String policySetting, Properties request, File localFile )
+ public void applyPolicy( String policySetting, Properties request, Path localFile )
throws PolicyViolationException, PolicyConfigurationException
{
if ( !options.contains( policySetting ) )
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
}
@Override
- public void applyPolicy( String policySetting, Properties request, File localFile )
+ public void applyPolicy( String policySetting, Properties request, Path localFile )
throws PolicyViolationException, PolicyConfigurationException
{
if ( "resource".equals( request.getProperty( "filetype" ) ) )
return;
}
- if ( !localFile.exists() )
+ if ( !Files.exists(localFile) )
{
// Local File does not exist.
throw new PolicyViolationException(
- "Checksum policy failure, local file " + localFile.getAbsolutePath() + " does not exist to check." );
+ "Checksum policy failure, local file " + localFile.toAbsolutePath() + " does not exist to check." );
}
if ( FAIL.equals( policySetting ) )
{
- ChecksummedFile checksum = new ChecksummedFile( localFile.toPath() );
+ ChecksummedFile checksum = new ChecksummedFile( localFile );
if ( checksum.isValidChecksums( algorithms ) )
{
return;
for ( ChecksumAlgorithm algorithm : algorithms )
{
- File file = new File( localFile.getAbsolutePath() + "." + algorithm.getExt() );
- if ( file.exists() )
+ Path file = localFile.toAbsolutePath().resolveSibling( localFile.getFileName() + "." + algorithm.getExt() );
+ try
{
- file.delete();
+ Files.deleteIfExists( file );
+ }
+ catch ( IOException e )
+ {
+ log.error("Could not delete file {}", file);
}
}
- localFile.delete();
+ try
+ {
+ Files.deleteIfExists( localFile );
+ }
+ catch ( IOException e )
+ {
+ log.error("Could not delete file {}", localFile);
+ }
throw new PolicyViolationException(
"Checksums do not match, policy set to FAIL, " + "deleting checksum files and local file "
- + localFile.getAbsolutePath() + "." );
+ + localFile.toAbsolutePath() + "." );
}
if ( FIX.equals( policySetting ) )
{
- ChecksummedFile checksum = new ChecksummedFile( localFile.toPath() );
+ ChecksummedFile checksum = new ChecksummedFile( localFile );
if ( checksum.fixChecksums( algorithms ) )
{
log.debug( "Checksum policy set to FIX, checksum files have been updated." );
{
throw new PolicyViolationException(
"Checksum policy set to FIX, " + "yet unable to update checksums for local file "
- + localFile.getAbsolutePath() + "." );
+ + localFile.toAbsolutePath() + "." );
}
}
* under the License.
*/
-import java.io.File;
+import java.nio.file.Path;
import java.util.Map;
import java.util.Properties;
* @return whether to process the exception or not
* @throws PolicyConfigurationException if the policy is improperly configured
*/
- boolean applyPolicy( String policySetting, Properties request, File localFile, Exception exception,
- Map<String, Exception> previousExceptions )
+ boolean applyPolicy( String policySetting, Properties request, Path localFile, Exception exception,
+ Map<String, Exception> previousExceptions )
throws PolicyConfigurationException;
}
* under the License.
*/
-import java.io.File;
+import java.nio.file.Path;
import java.util.Properties;
/**
*
* @throws PolicyViolationException if the policy has been violated.
*/
- void applyPolicy( String policySetting, Properties request, File localFile )
+ void applyPolicy( String policySetting, Properties request, Path localFile )
throws PolicyViolationException, PolicyConfigurationException;
}
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
}
@Override
- public boolean applyPolicy( String policySetting, Properties request, File localFile, Exception exception,
+ public boolean applyPolicy( String policySetting, Properties request, Path localFile, Exception exception,
Map<String, Exception> previousExceptions )
throws PolicyConfigurationException
{
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
-import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
}
@Override
- public boolean applyPolicy( String policySetting, Properties request, File localFile, Exception exception,
+ public boolean applyPolicy( String policySetting, Properties request, Path localFile, Exception exception,
Map<String, Exception> previousExceptions )
throws PolicyConfigurationException
{
if ( NOT_PRESENT.equals( policySetting ) )
{
// cancel the exception if the file exists
- return !localFile.exists();
+ return !Files.exists(localFile);
}
throw new PolicyConfigurationException(
import junit.framework.TestCase;
import org.apache.archiva.policies.urlcache.UrlFailureCache;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import javax.inject.Named;
-import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Properties;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
* CachedFailuresPolicyTest
return downloadPolicy;
}
- private File getFile()
+ private Path getFile()
{
- return new File( "target/cache-failures/" + getName() + ".txt" );
+ return Paths.get( "target/cache-failures/" + getName() + ".txt" );
}
private Properties createRequest()
throws Exception
{
DownloadPolicy policy = lookupPolicy();
- File localFile = getFile();
+ Path localFile = getFile();
Properties request = createRequest();
request.setProperty( "url", "http://a.bad.hostname.maven.org/path/to/resource.txt" );
{
DownloadPolicy policy = lookupPolicy();
- File localFile = getFile();
+ Path localFile = getFile();
Properties request = createRequest();
// make unique name
String url = "http://a.bad.hostname.maven.org/path/to/resource"+ System.currentTimeMillis() +".txt";
import org.springframework.test.context.ContextConfiguration;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Properties;
import javax.inject.Inject;
import javax.inject.Named;
throws Exception
{
PostDownloadPolicy policy = lookupPolicy();
- File localFile = createTestableFiles( null, null );
+ Path localFile = createTestableFiles( null, null );
Properties request = createRequest();
policy.applyPolicy( ChecksumPolicy.IGNORE, request, localFile );
throws Exception
{
PostDownloadPolicy policy = lookupPolicy();
- File localFile = createTestableFiles( md5State, sha1State );
+ Path localFile = createTestableFiles( md5State, sha1State );
Properties request = createRequest();
boolean actualResult;
actualResult = false;
String msg = createMessage( ChecksumPolicy.FAIL, md5State, sha1State );
- assertFalse( msg + " local file should not exist:", localFile.exists() );
- File md5File = new File( localFile.getAbsolutePath() + ".sha1" );
- File sha1File = new File( localFile.getAbsolutePath() + ".md5" );
- assertFalse( msg + " local md5 file should not exist:", md5File.exists() );
- assertFalse( msg + " local sha1 file should not exist:", sha1File.exists() );
+ assertFalse( msg + " local file should not exist:", Files.exists(localFile) );
+ Path md5File = localFile.toAbsolutePath().resolveSibling( localFile.getFileName() + ".sha1" );
+ Path sha1File = localFile.toAbsolutePath().resolveSibling( localFile.getFileName() + ".md5" );
+ assertFalse( msg + " local md5 file should not exist:", Files.exists(md5File) );
+ assertFalse( msg + " local sha1 file should not exist:", Files.exists(sha1File) );
}
assertEquals( createMessage( ChecksumPolicy.FAIL, md5State, sha1State ), expectedResult, actualResult );
throws Exception
{
PostDownloadPolicy policy = lookupPolicy();
- File localFile = createTestableFiles( md5State, sha1State );
+ Path localFile = createTestableFiles( md5State, sha1State );
Properties request = createRequest();
boolean actualResult;
assertEquals( createMessage( ChecksumPolicy.FIX, md5State, sha1State ), expectedResult, actualResult );
// End result should be legitimate SHA1 and MD5 files.
- File md5File = new File( localFile.getAbsolutePath() + ".md5" );
- File sha1File = new File( localFile.getAbsolutePath() + ".sha1" );
+ Path md5File = localFile.toAbsolutePath().resolveSibling( localFile.getFileName() + ".md5" );
+ Path sha1File = localFile.toAbsolutePath().resolveSibling( localFile.getFileName() + ".sha1" );
- assertTrue( "ChecksumPolicy.apply(FIX) md5 should exist.", md5File.exists() && md5File.isFile() );
- assertTrue( "ChecksumPolicy.apply(FIX) sha1 should exist.", sha1File.exists() && sha1File.isFile() );
+ assertTrue( "ChecksumPolicy.apply(FIX) md5 should exist.", Files.exists(md5File) && Files.isRegularFile(md5File) );
+ assertTrue( "ChecksumPolicy.apply(FIX) sha1 should exist.", Files.exists(sha1File) && Files.isRegularFile(sha1File) );
String actualMd5Contents = readChecksumFile( md5File );
String actualSha1Contents = readChecksumFile( sha1File );
/**
* Read the first line from the checksum file, and return it (trimmed).
*/
- private String readChecksumFile( File checksumFile )
+ private String readChecksumFile( Path checksumFile )
throws Exception
{
FileReader freader = null;
try
{
- freader = new FileReader( checksumFile );
+ freader = new FileReader( checksumFile.toFile() );
buf = new BufferedReader( freader );
return buf.readLine();
}
return request;
}
- private File createTestableFiles( String md5State, String sha1State )
+ private Path createTestableFiles( String md5State, String sha1State )
throws Exception
{
- File sourceDir = getTestFile( "src/test/resources/checksums/" );
- File destDir = getTestFile( "target/checksum-tests/" + name.getMethodName() + "/" );
+ Path sourceDir = getTestFile( "src/test/resources/checksums/" );
+ Path destDir = getTestFile( "target/checksum-tests/" + name.getMethodName() + "/" );
- FileUtils.copyFileToDirectory( new File( sourceDir, "artifact.jar" ), destDir );
+ FileUtils.copyFileToDirectory( sourceDir.resolve("artifact.jar" ).toFile(), destDir.toFile() );
if ( md5State != null )
{
- File md5File = new File( sourceDir, "artifact.jar.md5-" + md5State );
- assertTrue( "Testable file exists: " + md5File.getName() + ":", md5File.exists() && md5File.isFile() );
- File destFile = new File( destDir, "artifact.jar.md5" );
- FileUtils.copyFile( md5File, destFile );
+ Path md5File = sourceDir.resolve("artifact.jar.md5-" + md5State );
+ assertTrue( "Testable file exists: " + md5File.getFileName() + ":", Files.exists(md5File) && Files.isRegularFile(md5File) );
+ Path destFile = destDir.resolve("artifact.jar.md5" );
+ FileUtils.copyFile( md5File.toFile(), destFile.toFile() );
}
if ( sha1State != null )
{
- File sha1File = new File( sourceDir, "artifact.jar.sha1-" + sha1State );
- assertTrue( "Testable file exists: " + sha1File.getName() + ":", sha1File.exists() && sha1File.isFile() );
- File destFile = new File( destDir, "artifact.jar.sha1" );
- FileUtils.copyFile( sha1File, destFile );
+ Path sha1File = sourceDir.resolve("artifact.jar.sha1-" + sha1State );
+ assertTrue( "Testable file exists: " + sha1File.getFileName() + ":", Files.exists(sha1File) && Files.isRegularFile(sha1File) );
+ Path destFile = destDir.resolve("artifact.jar.sha1" );
+ FileUtils.copyFile( sha1File.toFile(), destFile.toFile() );
}
- File localFile = new File( destDir, "artifact.jar" );
+ Path localFile = destDir.resolve("artifact.jar" );
return localFile;
}
- public static File getTestFile( String path )
+ public static Path getTestFile( String path )
{
- return new File( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
+ return Paths.get( org.apache.archiva.common.utils.FileUtils.getBasedir(), path );
}
}
import javax.inject.Inject;
import javax.inject.Named;
-import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileTime;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
public class ReleasePolicyTest
extends TestCase
{
+
+ private static final Charset FILE_ENCODING = Charset.forName( "UTF-8" );
+
private static final String PATH_VERSION_METADATA = "org/apache/archiva/archiva-testable/1.0-SNAPSHOT/maven-metadata.xml";
private static final String PATH_PROJECT_METADATA = "org/apache/archiva/archiva-testable/maven-metadata.xml";
request.setProperty( "version", "2.0" );
}
- File targetDir = ChecksumPolicyTest.getTestFile( "target/test-policy/" );
- File localFile = new File( targetDir, path );
+ Path targetDir = ChecksumPolicyTest.getTestFile( "target/test-policy/" );
+ Path localFile = targetDir.resolve( path );
- if ( localFile.exists() )
- {
- localFile.delete();
- }
+ Files.deleteIfExists( localFile );
if ( createLocalFile )
{
- localFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( localFile, "random-junk" );
- localFile.setLastModified( localFile.lastModified() - generatedLocalFileUpdateDelta );
+ Files.createDirectories( localFile.getParent());
+ org.apache.archiva.common.utils.FileUtils.writeStringToFile( localFile, FILE_ENCODING, "random-junk" );
+ Files.setLastModifiedTime( localFile,
+ FileTime.fromMillis(Files.getLastModifiedTime(localFile).toMillis() - generatedLocalFileUpdateDelta));
}
policy.applyPolicy( setting, request, localFile );
*/
import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import javax.inject.Named;
-import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileTime;
import java.util.Properties;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
* SnapshotsPolicyTest
public class SnapshotsPolicyTest
extends TestCase
{
+ private static final Charset FILE_ENCODING = Charset.forName( "UTF-8" );
+
private static final String PATH_VERSION_METADATA = "org/apache/archiva/archiva-testable/1.0-SNAPSHOT/maven-metadata.xml";
private static final String PATH_PROJECT_METADATA = "org/apache/archiva/archiva-testable/maven-metadata.xml";
request.setProperty( "version", "2.0" );
}
- File targetDir = ChecksumPolicyTest.getTestFile( "target/test-policy/" );
- File localFile = new File( targetDir, path );
+ Path targetDir = ChecksumPolicyTest.getTestFile( "target/test-policy/" );
+ Path localFile = targetDir.resolve( path );
- if ( localFile.exists() )
- {
- localFile.delete();
- }
+ Files.deleteIfExists( localFile );
if ( createLocalFile )
{
- localFile.getParentFile().mkdirs();
- FileUtils.writeStringToFile( localFile, "random-junk" );
- localFile.setLastModified( localFile.lastModified() - generatedLocalFileUpdateDelta );
+ Files.createDirectories( localFile.getParent());
+ org.apache.archiva.common.utils.FileUtils.writeStringToFile( localFile, FILE_ENCODING, "random-junk" );
+ Files.setLastModifiedTime( localFile,
+ FileTime.fromMillis( Files.getLastModifiedTime( localFile ).toMillis() - generatedLocalFileUpdateDelta ));
}
policy.applyPolicy( setting, request, localFile );
* @param policies the map of policies to execute. (Map of String policy keys, to {@link DownloadPolicy} objects)
* @param settings the map of settings for the policies to execute. (Map of String policy keys, to String policy
* setting)
- * @param request the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)}
+ * @param request the request properties (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, Path)}
* )
- * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, File)})
+ * @param localFile the local file (utilized by the {@link DownloadPolicy#applyPolicy(String, Properties, Path)})
* @throws PolicyViolationException
*/
private void validatePolicies( Map<String, ? extends DownloadPolicy> policies, Map<String, String> settings,
log.debug( "Applying [{}] policy with [{}]", key, setting );
try
{
- policy.applyPolicy( setting, request, localFile.toFile() );
+ policy.applyPolicy( setting, request, localFile );
}
catch ( PolicyConfigurationException e )
{
try
{
// all policies must approve the exception, any can cancel
- process = policy.applyPolicy( setting, request, localFile.toFile(), exception, previousExceptions );
+ process = policy.applyPolicy( setting, request, localFile, exception, previousExceptions );
if ( !process )
{
break;
assertTrue( "Actual file exists.", Files.exists(actualFile) );
StringWriter actualContents = new StringWriter();
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( actualFile.toFile() );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( actualFile );
RepositoryMetadataWriter.write( metadata, actualContents );
DetailedDiff detailedDiff = new DetailedDiff( new Diff( expectedMetadataXml, actualContents.toString() ) );
try
{
- return MavenMetadataReader.read( metadataFile.toFile() );
+ return MavenMetadataReader.read( metadataFile );
}
catch ( XMLException e )
{
try
{
- return MavenMetadataReader.read( metadataFile.toFile() );
+ return MavenMetadataReader.read( metadataFile );
}
catch ( XMLException e )
{
try
{
- return MavenMetadataReader.read( metadataFile.toFile() );
+ return MavenMetadataReader.read( metadataFile );
}
catch ( XMLException e )
{
{
try
{
- ArchivaRepositoryMetadata existingMetadata = MavenMetadataReader.read( file.toFile() );
+ ArchivaRepositoryMetadata existingMetadata = MavenMetadataReader.read( file );
if ( existingMetadata != null )
{
metadatas.add( existingMetadata );
{
try
{
- allPlugins = new LinkedHashSet<Plugin>( MavenMetadataReader.read( metadataFile.toFile() ).getPlugins() );
+ allPlugins = new LinkedHashSet<Plugin>( MavenMetadataReader.read( metadataFile ).getPlugins() );
}
catch ( XMLException e )
{
try
{
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toFile() );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
return getLastUpdated( metadata );
}
try
{
ArchivaRepositoryMetadata archivaRepositoryMetadata =
- MavenMetadataReader.read( metadataFile.toFile() );
+ MavenMetadataReader.read( metadataFile );
int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
String timeStamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
// rebuild file name with timestamped version and build number
{
try
{
- metadata = MavenMetadataReader.read( metadataFile );
+ metadata = MavenMetadataReader.read( metadataFile.toPath() );
}
catch ( XMLException e )
{
{
try
{
- metadata = MavenMetadataReader.read( metadataFile );
+ metadata = MavenMetadataReader.read( metadataFile.toPath() );
}
catch ( XMLException e )
{
try
{
File metadataFile = new File( resourceAbsPath );
- ArchivaRepositoryMetadata repoMetadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata repoMetadata = MavenMetadataReader.read( metadataFile.toPath() );
mergedMetadata = RepositoryMetadataMerge.merge( mergedMetadata, repoMetadata );
}
catch ( XMLException e )
File returnedMetadata = new File( "target/test-classes/retrievedMetadataFile.xml" );
FileUtils.writeStringToFile( returnedMetadata, response.getContentAsString() );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( returnedMetadata );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( returnedMetadata.toPath() );
assertResponseOK( response );
{
try
{
- ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( metadataFile.toPath() );
int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
String timeStamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
// rebuild file name with timestamped version and build number
METADATA_FILENAME );
try
{
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
// re-adjust to timestamp if present, otherwise retain the original -SNAPSHOT filename
SnapshotVersion snapshotVersion = metadata.getSnapshotVersion();
{
return filePath;
}
- ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( metadataFile.toPath() );
int buildNumber = archivaRepositoryMetadata.getSnapshotVersion().getBuildNumber();
String timestamp = archivaRepositoryMetadata.getSnapshotVersion().getTimestamp();
{
try
{
- metadata = MavenMetadataReader.read( metadataFile );
+ metadata = MavenMetadataReader.read( metadataFile.toPath() );
}
catch ( XMLException e )
{
{
try
{
- ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( mavenMetadata );
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( mavenMetadata.toPath() );
SnapshotVersion snapshotVersion = archivaRepositoryMetadata.getSnapshotVersion();
if ( snapshotVersion != null )
{
log.debug( "Successfully downloaded metadata." );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( tmpMetadataResource );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( tmpMetadataResource.toPath() );
// re-adjust to timestamp if present, otherwise retain the original -SNAPSHOT filename
SnapshotVersion snapshotVersion = metadata.getSnapshotVersion();
{
File metadataFile = new File( defaultRepoDir, "org/apache/maven/plugins/maven-metadata.xml" );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
assertNotNull( metadata );
assertEquals( "org.apache.maven.plugins", metadata.getGroupId() );
{
File metadataFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
assertNotNull( metadata );
assertEquals( "org.apache.maven.shared", metadata.getGroupId() );
{
File metadataFile = new File( defaultRepoDir, "org/apache/apache/5-SNAPSHOT/maven-metadata.xml" );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
assertNotNull( metadata );
assertEquals( "org.apache", metadata.getGroupId() );
File defaultRepoDir = new File( "src/test/repositories/default-repository" );
File metadataFile = new File( defaultRepoDir, "org/apache/maven/shared/maven-downloader/maven-metadata.xml" );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
assertNotNull( metadata );
assertEquals( "Group Id", "org.apache.maven.shared", metadata.getGroupId() );
File defaultRepoDir = new File( "src/test/repositories/default-repository" );
File metadataFile = new File( defaultRepoDir, "org/apache/maven/samplejar/maven-metadata.xml" );
- ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile );
+ ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile.toPath() );
assertNotNull( metadata );
assertEquals( "Group Id", "org.apache.maven", metadata.getGroupId() );
{
try
{
- metadata = MavenMetadataReader.read( metadataFile );
+ metadata = MavenMetadataReader.read( metadataFile.toPath() );
}
catch ( XMLException e )
{