aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webdav/src/main
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/archiva-webdav/src/main
parent8e4acdc82a875ca32e39eb216b879c002d228de3 (diff)
downloadarchiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.tar.gz
archiva-bb3b074aaf5a2be0d81c950ecf1588fe8efa3316.zip
Refactoring to StorageAsset access
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav/src/main')
-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
6 files changed, 30 insertions, 34 deletions
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 );
}
}