aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-scheduler/archiva-scheduler-repository
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-scheduler/archiva-scheduler-repository
parent8e4acdc82a875ca32e39eb216b879c002d228de3 (diff)
downloadarchiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.tar.gz
archiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.zip
Refactoring to StorageAsset access
Diffstat (limited to 'archiva-modules/archiva-scheduler/archiva-scheduler-repository')
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/ArchivaIndexManagerMock.java24
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MavenIndexContextMock.java15
2 files changed, 27 insertions, 12 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/ArchivaIndexManagerMock.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/ArchivaIndexManagerMock.java
index 60f0a7b75..90d742475 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/ArchivaIndexManagerMock.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/ArchivaIndexManagerMock.java
@@ -19,6 +19,7 @@ package org.apache.archiva.mock;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
import org.apache.archiva.common.utils.FileUtils;
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.ArchivaConfiguration;
@@ -27,7 +28,6 @@ import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.indexer.IndexCreationFailedException;
import org.apache.archiva.indexer.IndexUpdateFailedException;
import org.apache.archiva.indexer.UnsupportedBaseContextException;
-import org.apache.archiva.proxy.ProxyRegistry;
import org.apache.archiva.proxy.maven.WagonFactory;
import org.apache.archiva.proxy.maven.WagonFactoryException;
import org.apache.archiva.proxy.maven.WagonFactoryRequest;
@@ -39,10 +39,12 @@ import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.Repository;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.UnsupportedRepositoryTypeException;
-import org.apache.archiva.repository.content.FilesystemAsset;
-import org.apache.archiva.repository.content.StorageAsset;
+import org.apache.archiva.repository.storage.FilesystemAsset;
+import org.apache.archiva.repository.storage.FilesystemStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
+import org.apache.archiva.repository.storage.StorageUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
@@ -140,7 +142,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
private Path getIndexPath( ArchivaIndexingContext ctx )
{
- return PathUtil.getPathFromUri( ctx.getPath( ) );
+ return ctx.getPath().getFilePath();
}
@FunctionalInterface
@@ -365,9 +367,9 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
@Override
public void addArtifactsToIndex( final ArchivaIndexingContext context, final Collection<URI> artifactReference ) throws IndexUpdateFailedException
{
- final URI ctxUri = context.getPath();
+ StorageAsset ctxUri = context.getPath();
executeUpdateFunction(context, indexingContext -> {
- Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.resolve(r)).toFile())).collect(Collectors.toList());
+ Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.getFilePath().toUri().resolve(r)).toFile())).collect(Collectors.toList());
try {
indexer.addArtifactsToIndex(artifacts, indexingContext);
} catch (IOException e) {
@@ -381,9 +383,9 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
@Override
public void removeArtifactsFromIndex( ArchivaIndexingContext context, Collection<URI> artifactReference ) throws IndexUpdateFailedException
{
- final URI ctxUri = context.getPath();
+ final StorageAsset ctxUri = context.getPath();
executeUpdateFunction(context, indexingContext -> {
- Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.resolve(r)).toFile())).collect(Collectors.toList());
+ Collection<ArtifactContext> artifacts = artifactReference.stream().map(r -> artifactContextProducer.getArtifactContext(indexingContext, Paths.get(ctxUri.getFilePath().toUri().resolve(r)).toFile())).collect(Collectors.toList());
try {
indexer.deleteArtifactsFromIndex(artifacts, indexingContext);
} catch (IOException e) {
@@ -442,7 +444,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
log.warn("Index close failed");
}
try {
- FileUtils.deleteDirectory(Paths.get(context.getPath()));
+ StorageUtil.deleteRecursively(context.getPath());
} catch (IOException e) {
throw new IndexUpdateFailedException("Could not delete index files");
}
@@ -517,6 +519,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
URI indexDir = icf.getIndexPath();
String indexPath = indexDir.getPath();
Path indexDirectory = null;
+ FilesystemStorage filesystemStorage = (FilesystemStorage) repo.getAsset("").getStorage();
if ( ! StringUtils.isEmpty(indexDir.toString( ) ) )
{
@@ -525,6 +528,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
if ( indexDirectory.isAbsolute( ) )
{
indexPath = indexDirectory.getFileName().toString();
+ filesystemStorage = new FilesystemStorage(indexDirectory, new DefaultFileLockManager());
}
else
{
@@ -541,7 +545,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager {
{
Files.createDirectories( indexDirectory );
}
- return new FilesystemAsset( indexPath, indexDirectory);
+ return new FilesystemAsset( filesystemStorage, indexPath, indexDirectory);
}
private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MavenIndexContextMock.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MavenIndexContextMock.java
index b3ae99c7b..fa070a7d9 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MavenIndexContextMock.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MavenIndexContextMock.java
@@ -19,8 +19,12 @@ package org.apache.archiva.mock;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
import org.apache.archiva.indexer.ArchivaIndexingContext;
import org.apache.archiva.repository.Repository;
+import org.apache.archiva.repository.storage.FilesystemAsset;
+import org.apache.archiva.repository.storage.FilesystemStorage;
+import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.index.context.IndexingContext;
import java.io.IOException;
@@ -38,10 +42,16 @@ public class MavenIndexContextMock implements ArchivaIndexingContext {
private IndexingContext delegate;
private Repository repository;
+ private FilesystemStorage filesystemStorage;
MavenIndexContextMock( Repository repository, IndexingContext delegate) {
this.delegate = delegate;
this.repository = repository;
+ try {
+ filesystemStorage = new FilesystemStorage(delegate.getIndexDirectoryFile().toPath().getParent(), new DefaultFileLockManager());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
@@ -56,8 +66,9 @@ public class MavenIndexContextMock implements ArchivaIndexingContext {
}
@Override
- public URI getPath() {
- return delegate.getIndexDirectoryFile().toURI();
+ public StorageAsset getPath() {
+ return new FilesystemAsset(filesystemStorage, delegate.getIndexDirectoryFile().toPath().getFileName().toString(), delegate.getIndexDirectoryFile().toPath());
+
}
@Override