aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-07-28 15:24:13 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-07-28 15:24:13 +0200
commitbb3b074aaf5a2be0d81c950ecf1588fe8efa3316 (patch)
tree8f165780e4d81cfdb6ed4a73c40fbed3a6f39a69 /archiva-modules/archiva-web
parent8e4acdc82a875ca32e39eb216b879c002d228de3 (diff)
downloadarchiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.tar.gz
archiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.zip
Refactoring to StorageAsset access
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java49
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java27
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java10
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java26
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/ArtifactBuilderTest.java42
-rw-r--r--archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java11
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java68
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/pom.xml4
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java43
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java5
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/IndexWriter.java4
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java6
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/OverridingRepositoryProxyHandler.java5
17 files changed, 180 insertions, 136 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
index 1067fc24a..403377b42 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
@@ -46,6 +46,10 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-storage-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-api</artifactId>
</dependency>
<dependency>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
index 9488261b4..56117836d 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
@@ -43,6 +43,8 @@ import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.metadata.MetadataTools;
+import org.apache.archiva.repository.storage.StorageAsset;
+import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.archiva.rest.api.model.*;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.BrowseService;
@@ -62,6 +64,8 @@ import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -696,8 +700,8 @@ public class DefaultBrowseService
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
StringUtils.isEmpty( type ) ? "jar" : type,
repoId );
- Path file = managedRepositoryContent.toFile( archivaArtifact );
- if ( Files.exists(file) )
+ StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
+ if ( file.exists() )
{
return readFileEntries( file, path, repoId );
}
@@ -781,8 +785,8 @@ public class DefaultBrowseService
ArchivaArtifact archivaArtifact = new ArchivaArtifact( groupId, artifactId, version, classifier,
StringUtils.isEmpty( type ) ? "jar" : type,
repoId );
- Path file = managedRepositoryContent.toFile( archivaArtifact );
- if ( !Files.exists(file) )
+ StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
+ if ( !file.exists() )
{
log.debug( "file: {} not exists for repository: {} try next repository", file, repoId );
continue;
@@ -790,7 +794,8 @@ public class DefaultBrowseService
if ( StringUtils.isNotBlank( path ) )
{
// zip entry of the path -> path must a real file entry of the archive
- JarFile jarFile = new JarFile( file.toFile() );
+ StorageUtil.PathInformation pathInfo = StorageUtil.getAssetDataAsPath(file);
+ JarFile jarFile = new JarFile( pathInfo.getPath().toFile());
ZipEntry zipEntry = jarFile.getEntry( path );
try (InputStream inputStream = jarFile.getInputStream( zipEntry ))
{
@@ -799,9 +804,14 @@ public class DefaultBrowseService
finally
{
closeQuietly( jarFile );
+ if (pathInfo.isTmpFile()) {
+ Files.deleteIfExists(pathInfo.getPath());
+ }
}
}
- return new ArtifactContent( new String(Files.readAllBytes( file ), ARTIFACT_CONTENT_ENCODING), repoId );
+ try(InputStream readStream = file.getReadStream()) {
+ return new ArtifactContent(IOUtils.toString(readStream, ARTIFACT_CONTENT_ENCODING), repoId);
+ }
}
}
catch ( IOException e )
@@ -846,9 +856,9 @@ public class DefaultBrowseService
StringUtils.isEmpty( classifier )
? ""
: classifier, "jar", repoId );
- Path file = managedRepositoryContent.toFile( archivaArtifact );
+ StorageAsset file = managedRepositoryContent.toFile( archivaArtifact );
- if ( file != null && Files.exists(file) )
+ if ( file != null && file.exists() )
{
return true;
}
@@ -856,8 +866,8 @@ public class DefaultBrowseService
// in case of SNAPSHOT we can have timestamped version locally !
if ( StringUtils.endsWith( version, VersionUtil.SNAPSHOT ) )
{
- Path metadataFile = file.getParent().resolve(MetadataTools.MAVEN_METADATA );
- if ( Files.exists(metadataFile) )
+ StorageAsset metadataFile = file.getStorage().getAsset(file.getParent().getPath()+"/"+MetadataTools.MAVEN_METADATA );
+ if ( metadataFile.exists() )
{
try
{
@@ -873,14 +883,14 @@ public class DefaultBrowseService
.append( ( StringUtils.isEmpty( classifier ) ? "" : "-" + classifier ) ) //
.append( ".jar" ).toString();
- Path timeStampFile = file.getParent().resolve( timeStampFileName );
- log.debug( "try to find timestamped snapshot version file: {}", timeStampFile.toAbsolutePath() );
- if ( Files.exists(timeStampFile) )
+ StorageAsset timeStampFile = file.getStorage().getAsset(file.getParent().getPath() + "/" + timeStampFileName );
+ log.debug( "try to find timestamped snapshot version file: {}", timeStampFile.getPath() );
+ if ( timeStampFile.exists() )
{
return true;
}
}
- catch ( XMLException e )
+ catch (XMLException | IOException e )
{
log.warn( "skip fail to find timestamped snapshot file: {}", e.getMessage() );
}
@@ -891,7 +901,7 @@ public class DefaultBrowseService
file = proxyHandler.fetchFromProxies( managedRepositoryContent, path );
- if ( file != null && Files.exists(file) )
+ if ( file != null && file.exists() )
{
// download pom now
String pomPath = StringUtils.substringBeforeLast( path, ".jar" ) + ".pom";
@@ -1075,7 +1085,7 @@ public class DefaultBrowseService
}
}
- protected List<ArtifactContentEntry> readFileEntries(final Path file, final String filterPath, final String repoId )
+ protected List<ArtifactContentEntry> readFileEntries(final StorageAsset file, final String filterPath, final String repoId )
throws IOException
{
String cleanedfilterPath = filterPath==null ? "" : (StringUtils.startsWith(filterPath, "/") ?
@@ -1085,7 +1095,9 @@ public class DefaultBrowseService
if (!StringUtils.endsWith(cleanedfilterPath,"/") && !StringUtils.isEmpty(cleanedfilterPath)) {
filterDepth++;
}
- JarFile jarFile = new JarFile( file.toFile() );
+
+ StorageUtil.PathInformation pathInfo = StorageUtil.getAssetDataAsPath(file);
+ JarFile jarFile = new JarFile(pathInfo.getPath().toFile());
try
{
Enumeration<JarEntry> jarEntryEnumeration = jarFile.entries();
@@ -1141,6 +1153,9 @@ public class DefaultBrowseService
{
jarFile.close();
}
+ if (pathInfo.isTmpFile()) {
+ Files.deleteIfExists(pathInfo.getPath());
+ }
}
List<ArtifactContentEntry> sorted = new ArrayList<>( artifactContentEntryMap.values() );
Collections.sort( sorted, ArtifactContentEntryComparator.INSTANCE );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
index f3dd25569..b2d23dde8 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
@@ -54,9 +54,9 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryNotFoundException;
import org.apache.archiva.repository.RepositoryRegistry;
-import org.apache.archiva.repository.content.RepositoryStorage;
-import org.apache.archiva.repository.content.StorageAsset;
-import org.apache.archiva.repository.content.StorageUtil;
+import org.apache.archiva.repository.storage.RepositoryStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
+import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
@@ -89,11 +89,10 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.core.Response;
import java.io.IOException;
-import java.nio.file.FileSystems;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -522,7 +521,7 @@ public class DefaultRepositoriesService
{
metadata = MavenMetadataReader.read( metadataFile.getFilePath() );
}
- catch ( XMLException e )
+ catch (XMLException | IOException e )
{
throw new RepositoryMetadataException( e.getMessage(), e );
}
@@ -543,7 +542,7 @@ public class DefaultRepositoriesService
throws IOException
{
- StorageUtil.copyAsset( sourceStorage, sourceFile, targetStorage, targetPath, true );
+ StorageUtil.copyAsset( sourceFile, targetPath, true );
if ( fixChecksums )
{
fixChecksums( targetPath );
@@ -612,7 +611,11 @@ public class DefaultRepositoriesService
projectMetadata.setReleasedVersion( latestVersion );
}
- RepositoryMetadataWriter.write( projectMetadata, projectMetadataFile.getFilePath());
+ try(OutputStreamWriter writer = new OutputStreamWriter(projectMetadataFile.getWriteStream(true))) {
+ RepositoryMetadataWriter.write(projectMetadata, writer);
+ } catch (IOException e) {
+ throw new RepositoryMetadataException(e);
+ }
if ( fixChecksums )
{
@@ -1177,7 +1180,11 @@ public class DefaultRepositoriesService
metadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
metadata.setAvailableVersions( availableVersions );
- RepositoryMetadataWriter.write( metadata, metadataFile.getFilePath());
+ try (OutputStreamWriter writer = new OutputStreamWriter(metadataFile.getWriteStream(true))) {
+ RepositoryMetadataWriter.write(metadata, writer);
+ } catch (IOException e) {
+ throw new RepositoryMetadataException(e);
+ }
ChecksummedFile checksum = new ChecksummedFile( metadataFile.getFilePath() );
checksum.fixChecksums( algorithms );
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java
index 7544dd355..2c6db17bf 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java
@@ -23,6 +23,8 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.storage.StorageAsset;
+import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.commons.io.FilenameUtils;
import java.nio.file.Path;
@@ -79,7 +81,7 @@ public class ArtifactBuilder
ref.setClassifier( classifier );
ref.setType( type );
- Path file = managedRepositoryContent.toFile( ref );
+ StorageAsset file = managedRepositoryContent.toFile( ref );
String extension = getExtensionFromFile(file);
@@ -124,10 +126,10 @@ public class ArtifactBuilder
/**
* Extract file extension
*/
- String getExtensionFromFile( Path file )
+ String getExtensionFromFile( StorageAsset file )
{
// we are just interested in the section after the last -
- String[] parts = file.getFileName().toString().split( "-" );
+ String[] parts = file.getName().split( "-" );
if ( parts.length > 0 )
{
// get anything after a dot followed by a letter a-z, including other dots
@@ -139,7 +141,7 @@ public class ArtifactBuilder
}
}
// just in case
- return FilenameUtils.getExtension( file.toFile().getName() );
+ return StorageUtil.getExtension( file );
}
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java
index 1472de5d9..4cd630e3c 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java
@@ -19,6 +19,9 @@ package org.apache.archiva.rest.services;
*/
import junit.framework.TestCase;
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.repository.storage.FilesystemAsset;
+import org.apache.archiva.repository.storage.FilesystemStorage;
import org.apache.archiva.rest.api.model.ArtifactContentEntry;
import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
import org.junit.Test;
@@ -56,10 +59,11 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
- List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, null, "foo" );
+ List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( new FilesystemAsset(filesystemStorage, file.toString(), file), null, "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
@@ -74,10 +78,12 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
- List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, "", "foo" );
+ List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries(
+ new FilesystemAsset(filesystemStorage, file.toString(), file), "", "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
@@ -92,10 +98,12 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
+
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
- List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, "/", "foo" );
+ List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( new FilesystemAsset(filesystemStorage, file.toString(),file), "/", "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
@@ -110,10 +118,12 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
+
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
- List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( file, "org", "foo" );
+ List<ArtifactContentEntry> artifactContentEntries = browseService.readFileEntries( new FilesystemAsset(filesystemStorage, file.toString(), file), "org", "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
@@ -127,11 +137,13 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
+
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
List<ArtifactContentEntry> artifactContentEntries =
- browseService.readFileEntries( file, "org/apache/commons/logging/impl/", "foo" );
+ browseService.readFileEntries( new FilesystemAsset(filesystemStorage, file.toString(), file), "org/apache/commons/logging/impl/", "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
@@ -145,11 +157,13 @@ public class ArtifactContentEntriesTests
throws Exception
{
+ FilesystemStorage filesystemStorage = new FilesystemStorage(Paths.get(getBasedir()), new DefaultFileLockManager());
+
Path file = Paths.get( getBasedir(),
"src/test/repo-with-osgi/commons-logging/commons-logging/1.1/commons-logging-1.1.jar" );
List<ArtifactContentEntry> artifactContentEntries =
- browseService.readFileEntries( file, "org/apache/commons/logging/", "foo" );
+ browseService.readFileEntries( new FilesystemAsset(filesystemStorage, file.toString(), file), "org/apache/commons/logging/", "foo" );
log.info( "artifactContentEntries: {}", artifactContentEntries );
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/ArtifactBuilderTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/ArtifactBuilderTest.java
index f0e825b79..f95099252 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/ArtifactBuilderTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/ArtifactBuilderTest.java
@@ -18,9 +18,15 @@ package org.apache.archiva.rest.services.utils;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.repository.storage.FilesystemAsset;
+import org.apache.archiva.repository.storage.FilesystemStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.easymock.TestSubject;
import org.junit.Test;
+import java.io.IOException;
+import java.nio.file.Path;
import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
@@ -30,39 +36,39 @@ public class ArtifactBuilderTest
@TestSubject
private ArtifactBuilder builder = new ArtifactBuilder();
+ StorageAsset getFile(String path) throws IOException {
+ Path filePath = Paths.get(path);
+ FilesystemStorage filesystemStorage = new FilesystemStorage(filePath.getParent(), new DefaultFileLockManager());
+ return new FilesystemAsset(filesystemStorage, filePath.getFileName().toString(), filePath);
+ }
+
@Test
- public void testBuildSnapshot()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-2.3-20141119.064321-40.jar" ) ) ).isEqualTo( "jar" );
+ public void testBuildSnapshot() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-2.3-20141119.064321-40.jar" ) ) ).isEqualTo( "jar" );
}
@Test
- public void testBuildPom()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-1.0.pom" ) ) ).isEqualTo( "pom" );
+ public void testBuildPom() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.pom" ) ) ).isEqualTo( "pom" );
}
@Test
- public void testBuildJar()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-1.0-sources.jar" ) ) ).isEqualTo( "jar" );
+ public void testBuildJar() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0-sources.jar" ) ) ).isEqualTo( "jar" );
}
@Test
- public void testBuildTarGz()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-1.0.tar.gz" ) ) ).isEqualTo( "tar.gz" );
+ public void testBuildTarGz() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.tar.gz" ) ) ).isEqualTo( "tar.gz" );
}
@Test
- public void testBuildPomZip()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-1.0.pom.zip" ) ) ).isEqualTo( "pom.zip" );
+ public void testBuildPomZip() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.pom.zip" ) ) ).isEqualTo( "pom.zip" );
}
@Test
- public void testBuildR00()
- {
- assertThat( builder.getExtensionFromFile( Paths.get( "/tmp/foo-1.0.r00" ) ) ).isEqualTo( "r00" );
+ public void testBuildR00() throws IOException {
+ assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.r00" ) ) ).isEqualTo( "r00" );
}
}
diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java
index 5d61568e8..929921aee 100644
--- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java
+++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java
@@ -24,12 +24,7 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.filter.Filter;
-import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorage;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataException;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException;
-import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
+import org.apache.archiva.metadata.repository.storage.*;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.policies.ProxyDownloadException;
import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
@@ -37,7 +32,9 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryTask;
+import org.apache.archiva.xml.XMLException;
+import java.io.IOException;
import java.util.Collection;
/**
@@ -166,7 +163,7 @@ public class MockBeanServices
}
@Override
- public String getFilePathWithVersion( String requestPath, ManagedRepositoryContent managedRepositoryContent )
+ public String getFilePathWithVersion( String requestPath, ManagedRepositoryContent managedRepositoryContent ) throws RelocationException, XMLException, IOException
{
return null;
}
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
index afe40d285..33ca26512 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
@@ -42,6 +42,7 @@ import org.apache.archiva.repository.content.ArtifactUtil;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.services.AbstractRestService;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
@@ -68,9 +69,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.*;
import java.net.URLDecoder;
import java.nio.file.*;
import java.text.DateFormat;
@@ -368,10 +367,10 @@ public class DefaultFileUploadService
ArtifactReference artifactReference = createArtifactRef(fileMetadata, groupId, artifactId, version);
artifactReference.setType(packaging);
- Path pomPath = artifactUtil.getArtifactPath(repoConfig, artifactReference);
- Path targetPath = pomPath.getParent();
+ StorageAsset pomPath = artifactUtil.getArtifactAsset(repoConfig, artifactReference);
+ StorageAsset targetPath = pomPath.getParent();
- String pomFilename = pomPath.getFileName().toString();
+ String pomFilename = pomPath.getName();
if (StringUtils.isNotEmpty(fileMetadata.getClassifier())) {
pomFilename = StringUtils.remove(pomFilename, "-" + fileMetadata.getClassifier());
}
@@ -408,8 +407,8 @@ public class DefaultFileUploadService
artifactReference.setType(
StringUtils.isEmpty(fileMetadata.getPackaging()) ? packaging : fileMetadata.getPackaging());
- Path artifactPath = artifactUtil.getArtifactPath(repoConfig, artifactReference);
- Path targetPath = artifactPath.getParent();
+ StorageAsset artifactPath = artifactUtil.getArtifactAsset(repoConfig, artifactReference);
+ StorageAsset targetPath = artifactPath.getParent();
log.debug("artifactPath: {} found targetPath: {}", artifactPath, targetPath);
@@ -417,7 +416,7 @@ public class DefaultFileUploadService
int newBuildNumber = -1;
String timestamp = null;
- Path versionMetadataFile = targetPath.resolve(MetadataTools.MAVEN_METADATA);
+ StorageAsset versionMetadataFile = targetPath.resolve(MetadataTools.MAVEN_METADATA);
ArchivaRepositoryMetadata versionMetadata = getMetadata(versionMetadataFile);
if (VersionUtil.isSnapshot(version)) {
@@ -432,11 +431,11 @@ public class DefaultFileUploadService
}
}
- if (!Files.exists(targetPath)) {
- Files.createDirectories(targetPath);
+ if (!targetPath.exists()) {
+ targetPath.create();
}
- String filename = artifactPath.getFileName().toString();
+ String filename = artifactPath.getName().toString();
if (VersionUtil.isSnapshot(version)) {
filename = filename.replaceAll(VersionUtil.SNAPSHOT, timestamp + "-" + newBuildNumber);
}
@@ -446,8 +445,8 @@ public class DefaultFileUploadService
// !(archivaAdministration.getKnownContentConsumers().contains("create-missing-checksums"));
try {
- Path targetFile = targetPath.resolve(filename);
- if (Files.exists(targetFile) && !VersionUtil.isSnapshot(version) && repoConfig.blocksRedeployments()) {
+ StorageAsset targetFile = targetPath.resolve(filename);
+ if (targetFile.exists() && !VersionUtil.isSnapshot(version) && repoConfig.blocksRedeployments()) {
throw new ArchivaRestServiceException(
"Overwriting released artifacts in repository '" + repoConfig.getId() + "' is not allowed.",
Response.Status.BAD_REQUEST.getStatusCode(), null);
@@ -471,7 +470,7 @@ public class DefaultFileUploadService
pomFilename = FilenameUtils.removeExtension(pomFilename) + ".pom";
try {
- Path generatedPomFile =
+ StorageAsset generatedPomFile =
createPom(targetPath, pomFilename, fileMetadata, groupId, artifactId, version, packaging);
triggerAuditEvent(repoConfig.getId(), targetPath.resolve(pomFilename).toString(), AuditEvent.UPLOAD_FILE);
if (fixChecksums) {
@@ -487,7 +486,7 @@ public class DefaultFileUploadService
// explicitly update only if metadata-updater consumer is not enabled!
if (!archivaAdministration.getKnownContentConsumers().contains("metadata-updater")) {
- updateProjectMetadata(targetPath.toAbsolutePath().toString(), lastUpdatedTimestamp, timestamp, newBuildNumber,
+ updateProjectMetadata(targetPath, lastUpdatedTimestamp, timestamp, newBuildNumber,
fixChecksums, fileMetadata, groupId, artifactId, version, packaging);
if (VersionUtil.isSnapshot(version)) {
@@ -525,20 +524,20 @@ public class DefaultFileUploadService
return artifactReference;
}
- private ArchivaRepositoryMetadata getMetadata(Path metadataFile)
+ private ArchivaRepositoryMetadata getMetadata(StorageAsset metadataFile)
throws RepositoryMetadataException {
ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
- if (Files.exists(metadataFile)) {
+ if (metadataFile.exists()) {
try {
metadata = MavenMetadataReader.read(metadataFile);
- } catch (XMLException e) {
+ } catch (XMLException | IOException e) {
throw new RepositoryMetadataException(e.getMessage(), e);
}
}
return metadata;
}
- private Path createPom(Path targetPath, String filename, FileMetadata fileMetadata, String groupId,
+ private StorageAsset createPom(StorageAsset targetPath, String filename, FileMetadata fileMetadata, String groupId,
String artifactId, String version, String packaging)
throws IOException {
Model projectModel = new Model();
@@ -548,22 +547,22 @@ public class DefaultFileUploadService
projectModel.setVersion(version);
projectModel.setPackaging(packaging);
- Path pomFile = targetPath.resolve(filename);
+ StorageAsset pomFile = targetPath.resolve(filename);
MavenXpp3Writer writer = new MavenXpp3Writer();
- try (FileWriter w = new FileWriter(pomFile.toFile())) {
+ try (Writer w = new OutputStreamWriter(pomFile.getWriteStream(true))) {
writer.write(w, projectModel);
}
return pomFile;
}
- private void fixChecksums(Path file) {
- ChecksummedFile checksum = new ChecksummedFile(file);
+ private void fixChecksums(StorageAsset file) {
+ ChecksummedFile checksum = new ChecksummedFile(file.getFilePath());
checksum.fixChecksums(algorithms);
}
- private void queueRepositoryTask(String repositoryId, Path localFile) {
+ private void queueRepositoryTask(String repositoryId, StorageAsset localFile) {
RepositoryTask task = new RepositoryTask();
task.setRepositoryId(repositoryId);
task.setResourceFile(localFile);
@@ -574,15 +573,14 @@ public class DefaultFileUploadService
scheduler.queueTask(task);
} catch (TaskQueueException e) {
log.error("Unable to queue repository task to execute consumers on resource file ['{}"
- + "'].", localFile.getFileName());
+ + "'].", localFile.getName());
}
}
- private void copyFile(Path sourceFile, Path targetPath, String targetFilename, boolean fixChecksums)
+ private void copyFile(Path sourceFile, StorageAsset targetPath, String targetFilename, boolean fixChecksums)
throws IOException {
- Files.copy(sourceFile, targetPath.resolve(targetFilename), StandardCopyOption.REPLACE_EXISTING,
- StandardCopyOption.COPY_ATTRIBUTES);
+ targetPath.resolve(targetFilename).replaceDataFromFile(sourceFile);
if (fixChecksums) {
fixChecksums(targetPath.resolve(targetFilename));
@@ -592,19 +590,19 @@ public class DefaultFileUploadService
/**
* Update artifact level metadata. If it does not exist, create the metadata and fix checksums if necessary.
*/
- private void updateProjectMetadata(String targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
+ private void updateProjectMetadata(StorageAsset targetPath, Date lastUpdatedTimestamp, String timestamp, int buildNumber,
boolean fixChecksums, FileMetadata fileMetadata, String groupId,
String artifactId, String version, String packaging)
throws RepositoryMetadataException {
List<String> availableVersions = new ArrayList<>();
String latestVersion = version;
- Path projectDir = Paths.get(targetPath).getParent();
- Path projectMetadataFile = projectDir.resolve(MetadataTools.MAVEN_METADATA);
+ StorageAsset projectDir = targetPath.getParent();
+ StorageAsset projectMetadataFile = projectDir.resolve(MetadataTools.MAVEN_METADATA);
ArchivaRepositoryMetadata projectMetadata = getMetadata(projectMetadataFile);
- if (Files.exists(projectMetadataFile)) {
+ if (projectMetadataFile.exists()) {
availableVersions = projectMetadata.getAvailableVersions();
Collections.sort(availableVersions, VersionComparator.getInstance());
@@ -648,12 +646,12 @@ public class DefaultFileUploadService
* Update version level metadata for snapshot artifacts. If it does not exist, create the metadata and fix checksums
* if necessary.
*/
- private void updateVersionMetadata(ArchivaRepositoryMetadata metadata, Path metadataFile,
+ private void updateVersionMetadata(ArchivaRepositoryMetadata metadata, StorageAsset metadataFile,
Date lastUpdatedTimestamp, String timestamp, int buildNumber,
boolean fixChecksums, FileMetadata fileMetadata, String groupId,
String artifactId, String version, String packaging)
throws RepositoryMetadataException {
- if (!Files.exists(metadataFile)) {
+ if (!metadataFile.exists()) {
metadata.setGroupId(groupId);
metadata.setArtifactId(artifactId);
metadata.setVersion(version);
diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml
index 73dcd4a7f..79a8e9def 100644
--- a/archiva-modules/archiva-web/archiva-webdav/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml
@@ -60,6 +60,10 @@
-->
</dependency>
<dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-storage-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.archiva.maven</groupId>
<artifactId>archiva-maven-repository</artifactId>
</dependency>
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java
index b3843e513..26ef91881 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResource.java
@@ -22,8 +22,8 @@ package org.apache.archiva.webdav;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.archiva.metadata.model.facets.AuditEvent;
import org.apache.archiva.repository.LayoutException;
-import org.apache.archiva.repository.content.RepositoryStorage;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.RepositoryStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.events.AuditListener;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
index 30e14433d..71868d10c 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
@@ -25,6 +25,7 @@ import org.apache.archiva.audit.Auditable;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksumUtil;
import org.apache.archiva.checksum.StreamingChecksum;
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.archiva.common.utils.PathUtil;
@@ -65,8 +66,8 @@ import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryGroup;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.repository.RepositoryRequestInfo;
-import org.apache.archiva.repository.content.FilesystemAsset;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.FilesystemStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.events.AuditListener;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.metadata.MetadataTools;
@@ -343,7 +344,7 @@ public class ArchivaDavResourceFactory
ArchivaRepositoryMetadata repoMetadata = MavenMetadataReader.read( metadataFile );
mergedMetadata = RepositoryMetadataMerge.merge( mergedMetadata, repoMetadata );
}
- catch ( XMLException e )
+ catch (XMLException | IOException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Error occurred while reading metadata file." );
@@ -427,11 +428,10 @@ public class ArchivaDavResourceFactory
{
// we are in the case of index file request
String requestedFileName = StringUtils.substringAfterLast( pathInfo, "/" );
- Path temporaryIndexDirectory =
+ StorageAsset temporaryIndexDirectory =
buildMergedIndexDirectory( activePrincipal, request, repoGroup );
- FilesystemAsset asset = new FilesystemAsset( pathInfo, temporaryIndexDirectory.resolve(requestedFileName) );
+ StorageAsset asset = temporaryIndexDirectory.getStorage().getAsset(requestedFileName);
- Path resourceFile = temporaryIndexDirectory.resolve( requestedFileName );
try {
resource = new ArchivaDavResource( asset, requestedFileName, repoGroup,
request.getRemoteAddr(), activePrincipal, request.getDavSession(),
@@ -543,7 +543,7 @@ public class ArchivaDavResourceFactory
throw new BrowserRedirectException( addHrefPrefix( contextPath, path ), e.getRelocationType() );
}
- catch ( XMLException e )
+ catch (XMLException | IOException e )
{
log.error( e.getMessage(), e );
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
@@ -765,7 +765,7 @@ public class ArchivaDavResourceFactory
RepositoryProxyHandler proxyHandler = proxyRegistry.getHandler(managedRepository.getRepository().getType()).get(0);
if ( repositoryRequestInfo.isSupportFile( path ) )
{
- Path proxiedFile = proxyHandler.fetchFromProxies( managedRepository, path );
+ StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, path );
return ( proxiedFile != null );
}
@@ -780,7 +780,7 @@ public class ArchivaDavResourceFactory
if ( repositoryRequestInfo.isArchetypeCatalog( path ) )
{
// FIXME we must implement a merge of remote archetype catalog from remote servers.
- Path proxiedFile = proxyHandler.fetchFromProxies( managedRepository, path );
+ StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, path );
return ( proxiedFile != null );
}
@@ -799,7 +799,7 @@ public class ArchivaDavResourceFactory
this.applicationContext.getBean( "repositoryStorage#" + repositoryLayout, RepositoryStorage.class );
repositoryStorage.applyServerSideRelocation( managedRepository, artifact );
- Path proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact );
+ StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact );
resource.setPath( managedRepository.toPath( artifact ) );
@@ -1058,10 +1058,9 @@ public class ArchivaDavResourceFactory
if ( StringUtils.endsWith( pathInfo, mergedIndexPath ) )
{
- Path mergedRepoDirPath =
+ StorageAsset mergedRepoDirPath =
buildMergedIndexDirectory( activePrincipal, request, repositoryGroup );
- FilesystemAsset mergedRepoDir = new FilesystemAsset(pathInfo, mergedRepoDirPath);
- mergedRepositoryContents.add( mergedRepoDir );
+ mergedRepositoryContents.add( mergedRepoDirPath );
}
else
{
@@ -1087,8 +1086,12 @@ public class ArchivaDavResourceFactory
}
}
}
- FilesystemAsset parentDir = new FilesystemAsset(pathInfo, tmpDirectory.getParent());
- mergedRepositoryContents.add( parentDir );
+ try {
+ FilesystemStorage storage = new FilesystemStorage(tmpDirectory.getParent(), new DefaultFileLockManager());
+ mergedRepositoryContents.add( storage.getAsset("") );
+ } catch (IOException e) {
+ throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not create storage for " + tmpDirectory);
+ }
}
for ( ManagedRepository repo : repositories )
{
@@ -1298,7 +1301,7 @@ public class ArchivaDavResourceFactory
}
}
- protected Path buildMergedIndexDirectory( String activePrincipal,
+ protected StorageAsset buildMergedIndexDirectory( String activePrincipal,
DavServletRequest request,
RepositoryGroup repositoryGroup )
throws DavException
@@ -1320,7 +1323,7 @@ public class ArchivaDavResourceFactory
final String id = repositoryGroup.getId();
TemporaryGroupIndex tmp = temporaryGroupIndexMap.get(id);
- if ( tmp != null && tmp.getDirectory() != null && Files.exists(tmp.getDirectory()))
+ if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists())
{
if ( System.currentTimeMillis() - tmp.getCreationTime() > (
repositoryGroup.getMergedIndexTTL() * 60 * 1000 ) )
@@ -1370,12 +1373,14 @@ public class ArchivaDavResourceFactory
{
Path tempRepoFile = Files.createTempDirectory( "temp" );
tempRepoFile.toFile( ).deleteOnExit( );
+ FilesystemStorage storage = new FilesystemStorage(tempRepoFile, new DefaultFileLockManager());
+ StorageAsset tmpAsset = storage.getAsset("");
IndexMergerRequest indexMergerRequest =
new IndexMergerRequest( authzRepos, true, id,
indexPath.toString( ),
repositoryGroup.getMergedIndexTTL( ) ).mergedIndexDirectory(
- tempRepoFile ).temporary( true );
+ tmpAsset ).temporary( true );
MergedRemoteIndexesTaskRequest taskRequest =
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
@@ -1384,7 +1389,7 @@ public class ArchivaDavResourceFactory
ArchivaIndexingContext indexingContext = job.execute( ).getIndexingContext( );
- Path mergedRepoDir = Paths.get( indexingContext.getPath( ) );
+ StorageAsset mergedRepoDir = indexingContext.getPath( );
TemporaryGroupIndex temporaryGroupIndex =
new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId( ), id,
repositoryGroup.getMergedIndexTTL( ) ) //
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java
index 586eebc88..ca996f526 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java
@@ -19,8 +19,7 @@ package org.apache.archiva.webdav;
* under the License.
*/
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.webdav.util.IndexWriter;
import org.apache.archiva.webdav.util.MimeTypes;
import org.apache.jackrabbit.util.Text;
@@ -48,9 +47,6 @@ import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
index 8e09cd08c..800b81b26 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
@@ -26,7 +26,7 @@ import org.apache.archiva.configuration.ConfigurationListener;
import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
import org.apache.archiva.repository.ManagedRepository;
import org.apache.archiva.repository.RepositoryRegistry;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.security.ServletAuthenticator;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.DavLocatorFactory;
@@ -51,9 +51,6 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/IndexWriter.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/IndexWriter.java
index 3aa9b387b..2763d4d4c 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/IndexWriter.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/IndexWriter.java
@@ -19,10 +19,8 @@ package org.apache.archiva.webdav.util;
* under the License.
*/
-import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.lang.StringUtils;
-import org.apache.jackrabbit.webdav.DavResource;
import org.apache.jackrabbit.webdav.io.OutputContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
index 02c4125a4..1cfc42fb5 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/util/TemporaryGroupIndexSessionCleaner.java
@@ -75,7 +75,7 @@ public class TemporaryGroupIndexSessionCleaner
for ( TemporaryGroupIndex temporaryGroupIndex : tempFilesPerKey.values() )
{
log.info( "cleanup temporaryGroupIndex {} directory {}", temporaryGroupIndex.getIndexId(),
- temporaryGroupIndex.getDirectory().toAbsolutePath() );
+ temporaryGroupIndex.getDirectory().getPath() );
getIndexMerger( httpSessionEvent ).cleanTemporaryGroupIndex( temporaryGroupIndex );
}
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
index 6eb286729..715057212 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
@@ -24,7 +24,7 @@ import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.RepositoryRegistry;
-import org.apache.archiva.repository.content.FilesystemAsset;
+import org.apache.archiva.repository.storage.FilesystemAsset;
import org.apache.archiva.repository.events.AuditListener;
import org.apache.archiva.repository.maven2.MavenManagedRepository;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
@@ -127,7 +127,7 @@ public class DavResourceTest
private DavResource getDavResource( String logicalPath, Path file ) throws LayoutException
{
- return new ArchivaDavResource( new FilesystemAsset( logicalPath, file.toAbsolutePath()) , logicalPath, repository, session, resourceLocator,
+ return new ArchivaDavResource( new FilesystemAsset( repository, logicalPath, file.toAbsolutePath()) , logicalPath, repository, session, resourceLocator,
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null);
}
@@ -349,7 +349,7 @@ public class DavResourceTest
{
try
{
- return new ArchivaDavResource( new FilesystemAsset( "/" , baseDir.toAbsolutePath()), "/", repository, session, resourceLocator,
+ return new ArchivaDavResource( new FilesystemAsset(repository, "/" , baseDir.toAbsolutePath()), "/", repository, session, resourceLocator,
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(),
null );
}
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/OverridingRepositoryProxyHandler.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/OverridingRepositoryProxyHandler.java
index 75f6726b7..1343c9452 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/OverridingRepositoryProxyHandler.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/OverridingRepositoryProxyHandler.java
@@ -22,6 +22,7 @@ package org.apache.archiva.webdav;
import org.apache.archiva.proxy.maven.MavenRepositoryProxyHandler;
import org.apache.archiva.proxy.model.ProxyFetchResult;
import org.apache.archiva.repository.ManagedRepositoryContent;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.io.FileUtils;
import java.io.IOException;
@@ -40,10 +41,10 @@ class OverridingRepositoryProxyHandler
@Override
public ProxyFetchResult fetchMetadataFromProxies(ManagedRepositoryContent repository, String logicalPath )
{
- Path target = Paths.get(repository.getRepoRoot(), logicalPath );
+ StorageAsset target = repository.getRepository().getAsset( logicalPath );
try
{
- FileUtils.copyFile( archivaDavResourceFactoryTest.getProjectBase().resolve( "target/test-classes/maven-metadata.xml" ).toFile(), target.toFile() );
+ FileUtils.copyFile( archivaDavResourceFactoryTest.getProjectBase().resolve( "target/test-classes/maven-metadata.xml" ).toFile(), target.getFilePath().toFile() );
}
catch ( IOException e )
{