diff options
author | Martin Stockhammer <martin.stockhammer@ars.de> | 2018-03-29 23:47:13 +0200 |
---|---|---|
committer | Martin Stockhammer <martin.stockhammer@ars.de> | 2018-03-29 23:47:13 +0200 |
commit | 9cd3c61340d8c62df6c88c82b4dfdce429eb947e (patch) | |
tree | 03c88d9b706e77ab63fb81e6bf0f49d543fa814c /archiva-modules/archiva-base | |
parent | f18aa86c68f475c5932d818446f6dec644be635b (diff) | |
download | archiva-9cd3c61340d8c62df6c88c82b4dfdce429eb947e.tar.gz archiva-9cd3c61340d8c62df6c88c82b4dfdce429eb947e.zip |
Adding packedIndexDir
Diffstat (limited to 'archiva-modules/archiva-base')
10 files changed, 82 insertions, 46 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index d687ba6af..746f2c472 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -471,6 +471,15 @@ </description> </field> <field> + <name>packedIndexDir</name> + <version>3.0.0+</version> + <type>String</type> + <defaultValue></defaultValue> + <description> + The directory for the packed indexes of this repository. + </description> + </field> + <field> <name>description</name> <version>1.0.0+</version> <type>String</type> diff --git a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java index 718cd7dcb..f80e39baf 100644 --- a/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java +++ b/archiva-modules/archiva-base/archiva-maven2-indexer/src/main/java/org/apache/archiva/indexer/maven/MavenIndexManager.java @@ -123,10 +123,9 @@ public class MavenIndexManager implements ArchivaIndexManager { @Inject private ArtifactContextProducer artifactContextProducer; - @Inject - RepositoryRegistry repositoryRegistry; public static final String DEFAULT_INDEXER_DIR = ".indexer"; + public static final String DEFAULT_PACKED_INDEX_DIR = ".index"; private ConcurrentSkipListSet<Path> activeContexts = new ConcurrentSkipListSet<>( ); @@ -523,6 +522,7 @@ public class MavenIndexManager implements ArchivaIndexManager { IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); try { icf.setLocalIndexPath(getIndexPath(repo)); + icf.setLocalPackedIndexPath(getPackedIndexPath(repo)); } catch (IOException e) { log.error("Could not set local index path for {}. New URI: {}", repo.getId(), icf.getIndexPath()); } @@ -556,6 +556,33 @@ public class MavenIndexManager implements ArchivaIndexManager { return indexDirectory; } + private Path getPackedIndexPath(Repository repo) throws IOException { + IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); + Path repoDir = repo.getLocalPath(); + URI indexDir = icf.getPackedIndexPath(); + Path indexDirectory = null; + if ( ! StringUtils.isEmpty(indexDir.toString( ) ) ) + { + + indexDirectory = PathUtil.getPathFromUri( indexDir ); + // not absolute so create it in repository directory + if ( !indexDirectory.isAbsolute( ) ) + { + indexDirectory = repoDir.resolve( indexDirectory ); + } + } + else + { + indexDirectory = repoDir.resolve( DEFAULT_PACKED_INDEX_DIR ); + } + + if ( !Files.exists( indexDirectory ) ) + { + Files.createDirectories( indexDirectory ); + } + return indexDirectory; + } + private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException { Path appServerBase = archivaConfiguration.getAppServerBaseDir( ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java index 3ab65bcb2..2bb82d50d 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java @@ -20,27 +20,19 @@ package org.apache.archiva.proxy; */ import net.sf.ehcache.CacheManager; -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; -import org.apache.archiva.policies.CachedFailuresPolicy; -import org.apache.archiva.policies.ChecksumPolicy; -import org.apache.archiva.policies.PropagateErrorsDownloadPolicy; -import org.apache.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy; -import org.apache.archiva.policies.ReleasesPolicy; -import org.apache.archiva.policies.SnapshotsPolicy; +import org.apache.archiva.policies.*; import org.apache.archiva.proxy.model.RepositoryProxyConnectors; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentProvider; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; -import org.apache.commons.io.FileUtils; import org.apache.maven.index.NexusIndexer; import org.apache.maven.index.context.IndexingContext; import org.apache.maven.wagon.Wagon; @@ -124,10 +116,6 @@ public abstract class AbstractProxyTestCase WagonDelegate delegate; - - @Inject - protected NexusIndexer nexusIndexer; - @Before public void setUp() throws Exception @@ -155,9 +143,6 @@ public abstract class AbstractProxyTestCase applicationContext.getBean( RepositoryRegistry.class ).putRepository( repoConfig ); - // to prevent windauze file leaking - removeMavenIndexes(); - repositoryRegistry.setArchivaConfiguration( config ); // Setup target (proxied to) repository. @@ -199,25 +184,6 @@ public abstract class AbstractProxyTestCase log.info( "\n.\\ {}() \\._________________________________________\n", name ); } - @After - public void shutdown() - throws Exception - { - removeMavenIndexes(); - } - - - protected void removeMavenIndexes() - throws Exception - { - - for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() ) - { - nexusIndexer.removeIndexingContext( indexingContext, false ); - } - } - - protected void assertChecksums( Path expectedFile, String expectedSha1Contents, String expectedMd5Contents ) throws Exception { diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java index 0f2ce93b8..fb50b8421 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java @@ -54,6 +54,11 @@ public class AbstractRepository private String indexDirectory; + /* + * @since 3.0.0 + */ + private String packedIndexDirectory; + private String toStringCache = null; @@ -136,6 +141,7 @@ public class AbstractRepository public void setIndexDirectory( String indexDirectory ) { + this.toStringCache=null; this.indexDirectory = indexDirectory; } @@ -202,9 +208,19 @@ public class AbstractRepository } public void setType(String type) { + toStringCache=null; this.type = type; } + public String getPackedIndexDirectory() { + return packedIndexDirectory; + } + + public void setPackedIndexDirectory(String packedIndexDirectory) { + toStringCache=null; + this.packedIndexDirectory = packedIndexDirectory; + } + @Override public String toString() { @@ -214,12 +230,13 @@ public class AbstractRepository { final StringBuilder sb = new StringBuilder( ); sb.append( "AbstractRepository" ); - sb.append( "{id='" ).append( id ).append( '\'' ); - sb.append(", type='").append(type).append('\''); - sb.append( ", name='" ).append( getLocaleString( name ) ).append( '\'' ); - sb.append( ", layout='" ).append( layout ).append( '\'' ); - sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' ); - sb.append( ", description='" ).append( getLocaleString( description ) ).append( '\'' ); + sb.append( "{ id=\"" ).append( id ).append( '"' ); + sb.append( ", type=\"").append(type).append('"'); + sb.append( ", name=\"" ).append( getLocaleString( name ) ).append( '"' ); + sb.append( ", layout=\"" ).append( layout ).append( '"' ); + sb.append( ", indexDirectory=\"" ).append( indexDirectory ).append( '"' ); + sb.append( ", packedIndexDirectory=\"").append(packedIndexDirectory).append('"'); + sb.append( ", description=\"" ).append( getLocaleString( description ) ).append( '"' ); sb.append( '}' ); toStringCache=sb.toString( ); return toStringCache; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java index 1a8ccc712..8041817a5 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java @@ -125,6 +125,7 @@ public abstract class AbstractRepositoryAdmin if (repo.supportsFeature( IndexCreationFeature.class )) { IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get(); adminRepo.setIndexDirectory( convertUriToString( icf.getIndexPath() ) ); + adminRepo.setPackedIndexDirectory(convertUriToString(icf.getPackedIndexPath())); } } @@ -134,6 +135,7 @@ public abstract class AbstractRepositoryAdmin repoConfig.setLayout( repo.getLayout() ); repoConfig.setDescription( repo.getDescription() ); repoConfig.setIndexDir( repo.getIndexDirectory() ); + repoConfig.setPackedIndexDir(repo.getPackedIndexDirectory()); repoConfig.setType( StringUtils.isEmpty( repo.getType() ) ? "MAVEN" : repo.getType() ); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index 9e47f1004..7d87e048f 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -145,7 +145,6 @@ public class DefaultManagedRepositoryAdmin adminRepo.setCronExpression( repo.getSchedulingDefinition() ); if (repo.supportsFeature( IndexCreationFeature.class )) { IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get(); - adminRepo.setIndexDirectory(convertUriToString( icf.getIndexPath() )); adminRepo.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation() ); } adminRepo.setScanned( repo.isScanned() ); @@ -180,6 +179,7 @@ public class DefaultManagedRepositoryAdmin repoConfig.setDeleteReleasedSnapshots( repo.isDeleteReleasedSnapshots() ); repoConfig.setSkipPackedIndexCreation( repo.isSkipPackedIndexCreation()); repoConfig.setStageRepoNeeded( repo.isStageRepoNeeded() ); + return repoConfig; } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index add16ee83..6b063e36e 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -216,6 +216,7 @@ public class DefaultRemoteRepositoryAdmin Configuration configuration = getArchivaConfiguration().getConfiguration(); RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration( remoteRepository ); + log.debug("Adding remote repo {}", remoteRepositoryConfiguration); try { diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java index dca455a7f..660f3e4ce 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/features/RemoteIndexFeature.java @@ -133,4 +133,13 @@ public class RemoteIndexFeature implements RepositoryFeature<RemoteIndexFeature> public boolean hasIndex() { return this.indexUri!=null && !StringUtils.isEmpty( this.indexUri.getPath() ); } + + @Override + public String toString() { + StringBuilder str = new StringBuilder(); + return str.append("RemoteIndexFeature:{downloadRemoteIndex=").append(downloadRemoteIndex) + .append(",indexURI=").append(indexUri) + .append(",downloadOnStartup=").append(downloadRemoteIndexOnStartup) + .append(",timeout=").append(downloadTimeout).append("}").toString(); + } } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java index 131aad664..26a3fb50a 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java @@ -151,4 +151,10 @@ public abstract class AbstractRemoteRepository extends AbstractRepository implem return repositoryBase.resolve(getId()); } + @Override + public String toString() { + StringBuilder str = new StringBuilder(); + return str.append("checkPath=").append(checkPath) + .append(",creds:").append(credentials).toString(); + } } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java index 984a2f6f6..8843ce623 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java @@ -21,7 +21,6 @@ package org.apache.archiva.repository; import org.apache.archiva.configuration.*; import org.apache.archiva.indexer.*; -import org.apache.archiva.metadata.model.facets.AuditEvent; import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.repository.features.IndexCreationEvent; import org.apache.archiva.repository.features.IndexCreationFeature; @@ -1017,7 +1016,7 @@ public class RepositoryRegistry implements ConfigurationListener, RepositoryEven @Override public <T> void raise(RepositoryEvent<T> event) { - if (event.getType().equals(IndexCreationEvent.Index.URI_CHANGE)) { + if (event instanceof IndexCreationEvent ) { if (managedRepositories.containsKey(event.getRepository().getId()) || remoteRepositories.containsKey(event.getRepository().getId())) { EditableRepository repo = (EditableRepository) event.getRepository(); |