mirror of
https://github.com/apache/archiva.git
synced 2025-02-21 01:15:08 +00:00
Using storageAsset for Index API
This commit is contained in:
parent
240292077e
commit
380c152114
@ -21,10 +21,12 @@
|
||||
|
||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
|
||||
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
|
||||
import org.apache.archiva.repository.BasicManagedRepository;
|
||||
import org.apache.archiva.repository.BasicRemoteRepository;
|
||||
import org.apache.archiva.repository.EditableManagedRepository;
|
||||
import org.apache.archiva.repository.EditableRemoteRepository;
|
||||
import org.apache.archiva.repository.EditableRepositoryGroup;
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.PasswordCredentials;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
@ -32,6 +34,7 @@
|
||||
import org.apache.archiva.repository.RepositoryCredentials;
|
||||
import org.apache.archiva.repository.RepositoryEvent;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryGroup;
|
||||
import org.apache.archiva.repository.RepositoryProvider;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
|
||||
@ -80,6 +83,13 @@ public EditableRemoteRepository createRemoteInstance( String id, String name )
|
||||
return new BasicRemoteRepository( id, name, Paths.get("target/remotes") );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditableRepositoryGroup createRepositoryGroup( String id, String name )
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
|
||||
{
|
||||
@ -175,6 +185,18 @@ public void updateRemoteInstance( EditableRemoteRepository remoteRepository, Rem
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryGroup createRepositoryGroup( RepositoryGroupConfiguration configuration ) throws RepositoryException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRepositoryGroupInstance( EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration ) throws RepositoryException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository managedRepository )
|
||||
{
|
||||
@ -201,6 +223,12 @@ public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryGroupConfiguration getRepositoryGroupConfiguration( RepositoryGroup repositoryGroup ) throws RepositoryException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RemoteRepositoryConfiguration getRemoteConfiguration( RemoteRepository remoteRepository )
|
||||
|
@ -30,6 +30,7 @@
|
||||
import org.apache.archiva.metadata.model.facets.AuditEvent;
|
||||
import org.apache.archiva.indexer.merger.MergedRemoteIndexesScheduler;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -394,7 +395,11 @@ public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryA
|
||||
|
||||
private RepositoryGroup convertRepositoryGroupObject( org.apache.archiva.repository.RepositoryGroup group ) {
|
||||
RepositoryGroup rg = new RepositoryGroup( group.getId( ), group.getRepositories().stream().map(r -> r.getId()).collect( Collectors.toList()) );
|
||||
rg.setMergedIndexPath( group.getMergedIndexPath().getPath() );
|
||||
if (group.supportsFeature( IndexCreationFeature.class ))
|
||||
{
|
||||
IndexCreationFeature indexCreationFeature = group.getFeature( IndexCreationFeature.class ).get();
|
||||
rg.setMergedIndexPath( indexCreationFeature.getIndexPath().getPath() );
|
||||
}
|
||||
rg.setCronExpression( group.getSchedulingDefinition() );
|
||||
rg.setMergedIndexTtl( group.getMergedIndexTTL() );
|
||||
return rg;
|
||||
|
@ -40,6 +40,8 @@
|
||||
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.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RemoteIndexFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -477,7 +479,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
}
|
||||
if (context.supports(IndexingContext.class)) {
|
||||
try {
|
||||
Path newPath = getIndexPath(repo);
|
||||
StorageAsset newPath = getIndexPath(repo);
|
||||
IndexingContext ctx = context.getBaseContext(IndexingContext.class);
|
||||
Path oldPath = ctx.getIndexDirectoryFile().toPath();
|
||||
if (oldPath.equals(newPath)) {
|
||||
@ -491,7 +493,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
return createContext(repo);
|
||||
} else {
|
||||
context.close(false);
|
||||
Files.move(oldPath, newPath);
|
||||
Files.move(oldPath, newPath.getFilePath());
|
||||
return createContext(repo);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -517,17 +519,22 @@ public void updateLocalIndexPath(Repository repo) {
|
||||
}
|
||||
}
|
||||
|
||||
private Path getIndexPath(Repository repo) throws IOException {
|
||||
private StorageAsset getIndexPath( Repository repo) throws IOException {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
Path repoDir = repo.getLocalPath();
|
||||
URI indexDir = icf.getIndexPath();
|
||||
String indexPath = indexDir.getPath();
|
||||
Path indexDirectory = null;
|
||||
if ( ! StringUtils.isEmpty(indexDir.toString( ) ) )
|
||||
{
|
||||
|
||||
indexDirectory = PathUtil.getPathFromUri( indexDir );
|
||||
// not absolute so create it in repository directory
|
||||
if ( !indexDirectory.isAbsolute( ) )
|
||||
if ( indexDirectory.isAbsolute( ) )
|
||||
{
|
||||
indexPath = indexDirectory.getFileName().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( indexDirectory );
|
||||
}
|
||||
@ -535,13 +542,14 @@ private Path getIndexPath(Repository repo) throws IOException {
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( ".index" );
|
||||
indexPath = ".index";
|
||||
}
|
||||
|
||||
if ( !Files.exists( indexDirectory ) )
|
||||
{
|
||||
Files.createDirectories( indexDirectory );
|
||||
}
|
||||
return indexDirectory;
|
||||
return new FilesystemAsset( indexPath, indexDirectory);
|
||||
}
|
||||
|
||||
private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
|
||||
@ -558,7 +566,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
Files.createDirectories( repoDir );
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
// is there configured indexDirectory ?
|
||||
if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) )
|
||||
@ -577,7 +585,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
remoteRepository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
return getIndexingContext( remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl );
|
||||
|
||||
}
|
||||
@ -588,9 +596,9 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
}
|
||||
}
|
||||
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, Path indexDirectory, String indexUrl ) throws IOException
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, StorageAsset indexDirectory, String indexUrl ) throws IOException
|
||||
{
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.toFile( ),
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.getFilePath().toFile( ),
|
||||
repository.getLocation( ) == null ? null : repository.getLocation( ).toString( ),
|
||||
indexUrl,
|
||||
true, false,
|
||||
@ -616,7 +624,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
}
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
if ( repository.supportsFeature( IndexCreationFeature.class ) )
|
||||
{
|
||||
@ -634,7 +642,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
repository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl );
|
||||
context.setSearchable( repository.isScanned( ) );
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.beans.RepositoryGroup;
|
||||
import org.apache.archiva.indexer.merger.MergedRemoteIndexesScheduler;
|
||||
import org.apache.archiva.repository.RepositoryGroup;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
@ -1,128 +0,0 @@
|
||||
package org.apache.archiva.indexer;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.common.utils.PathUtil;
|
||||
import org.apache.archiva.repository.Repository;
|
||||
import org.apache.archiva.repository.RepositoryType;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
|
||||
@Service("indexManager#none")
|
||||
public class GenericIndexManager implements ArchivaIndexManager {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(GenericIndexManager.class);
|
||||
|
||||
public static final String DEFAULT_INDEXER_DIR = ".indexer";
|
||||
|
||||
@Override
|
||||
public void pack(ArchivaIndexingContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scan(ArchivaIndexingContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ArchivaIndexingContext context, boolean fullUpdate) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArtifactsToIndex(ArchivaIndexingContext context, Collection<URI> artifactReference) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeArtifactsFromIndex(ArchivaIndexingContext context, Collection<URI> artifactReference) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRepository(RepositoryType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArchivaIndexingContext createContext(Repository repository) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArchivaIndexingContext reset(ArchivaIndexingContext context) throws IndexUpdateFailedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo) throws IndexCreationFailedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocalIndexPath(Repository repo) {
|
||||
if (repo.supportsFeature(IndexCreationFeature.class)) {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
try {
|
||||
icf.setLocalIndexPath(getIndexPath(repo));
|
||||
} catch (IOException e) {
|
||||
log.error("Could not set local index path for {}. New URI: {}", repo.getId(), icf.getIndexPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Path getIndexPath(Repository repo) throws IOException {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
Path repoDir = repo.getLocalPath();
|
||||
URI indexDir = icf.getIndexPath();
|
||||
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_INDEXER_DIR);
|
||||
}
|
||||
|
||||
if ( !Files.exists( indexDirectory ) )
|
||||
{
|
||||
Files.createDirectories( indexDirectory );
|
||||
}
|
||||
return indexDirectory;
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,5 @@ public interface EditableRepositoryGroup extends EditableRepository,RepositoryGr
|
||||
|
||||
ManagedRepository removeRepository(String repoId);
|
||||
|
||||
void setMergedIndexPath(String path);
|
||||
|
||||
void setMergedIndexTTL(int timeInSeconds);
|
||||
}
|
||||
|
@ -1,4 +1,22 @@
|
||||
package org.apache.archiva.repository;
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
|
@ -63,12 +63,6 @@ public interface RepositoryGroup extends Repository, RepositoryStorage {
|
||||
*/
|
||||
boolean contains(String id);
|
||||
|
||||
/**
|
||||
* Returns the path to the merged index
|
||||
* @return
|
||||
*/
|
||||
StorageAsset getMergedIndexPath();
|
||||
|
||||
/**
|
||||
* Returns the time to live in seconds for the merged index.
|
||||
*
|
||||
|
@ -1,4 +1,22 @@
|
||||
package org.apache.archiva.repository;
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
import org.apache.archiva.repository.Repository;
|
||||
import org.apache.archiva.repository.RepositoryEventListener;
|
||||
import org.apache.archiva.repository.content.StorageAsset;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.net.URI;
|
||||
@ -44,9 +45,9 @@ public class IndexCreationFeature extends AbstractFeature implements RepositoryF
|
||||
|
||||
private URI packedIndexPath;
|
||||
|
||||
private Path localIndexPath;
|
||||
private StorageAsset localIndexPath;
|
||||
|
||||
private Path localPackedIndexPath;
|
||||
private StorageAsset localPackedIndexPath;
|
||||
|
||||
private Repository repo;
|
||||
|
||||
@ -126,7 +127,7 @@ public boolean hasIndex() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Path getLocalIndexPath() {
|
||||
public StorageAsset getLocalIndexPath() {
|
||||
return localIndexPath;
|
||||
}
|
||||
|
||||
@ -136,7 +137,7 @@ public Path getLocalIndexPath() {
|
||||
*
|
||||
* @param localIndexPath
|
||||
*/
|
||||
public void setLocalIndexPath(Path localIndexPath) {
|
||||
public void setLocalIndexPath(StorageAsset localIndexPath) {
|
||||
this.localIndexPath = localIndexPath;
|
||||
}
|
||||
|
||||
@ -163,7 +164,7 @@ public void setPackedIndexPath(URI packedIndexPath) {
|
||||
* Returns the directory where the packed index is stored.
|
||||
* @return
|
||||
*/
|
||||
public Path getLocalPackedIndexPath() {
|
||||
public StorageAsset getLocalPackedIndexPath() {
|
||||
return localPackedIndexPath;
|
||||
}
|
||||
|
||||
@ -173,7 +174,7 @@ public Path getLocalPackedIndexPath() {
|
||||
*
|
||||
* @param localPackedIndexPath
|
||||
*/
|
||||
public void setLocalPackedIndexPath(Path localPackedIndexPath) {
|
||||
public void setLocalPackedIndexPath(StorageAsset localPackedIndexPath) {
|
||||
this.localPackedIndexPath = localPackedIndexPath;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,156 @@
|
||||
package org.apache.archiva.indexer.merger;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.common.utils.FileUtils;
|
||||
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.commons.lang.time.StopWatch;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Martin Stockhammer <martin_s@apache.org>
|
||||
*/
|
||||
public class BasicIndexMerger implements IndexMerger
|
||||
{
|
||||
@Inject
|
||||
RepositoryRegistry repositoryRegistry;
|
||||
|
||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
|
||||
private List<TemporaryGroupIndex> temporaryGroupIndexes = new CopyOnWriteArrayList<>();
|
||||
|
||||
private List<String> runningGroups = new CopyOnWriteArrayList<>();
|
||||
|
||||
@Inject
|
||||
public BasicIndexMerger( )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArchivaIndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
||||
throws IndexMergerException
|
||||
{
|
||||
String groupId = indexMergerRequest.getGroupId();
|
||||
|
||||
if ( runningGroups.contains( groupId ) )
|
||||
{
|
||||
log.info( "skip build merge remote indexes for id: '{}' as already running", groupId );
|
||||
return null;
|
||||
}
|
||||
|
||||
runningGroups.add( groupId );
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.reset();
|
||||
stopWatch.start();
|
||||
|
||||
Path mergedIndexDirectory = indexMergerRequest.getMergedIndexDirectory();
|
||||
|
||||
String tempRepoId = mergedIndexDirectory.getFileName().toString();
|
||||
|
||||
try
|
||||
{
|
||||
Path indexLocation = mergedIndexDirectory.resolve( indexMergerRequest.getMergedIndexPath() );
|
||||
|
||||
List<ArchivaIndexingContext> members = indexMergerRequest.getRepositoriesIds( ).stream( ).map( id ->
|
||||
repositoryRegistry.getRepository( id ) )
|
||||
.map( repo -> repo.getIndexingContext() ).filter( Objects::nonNull ).collect( Collectors.toList() );
|
||||
|
||||
members.get( 0 ).
|
||||
if ( indexMergerRequest.isPackIndex() )
|
||||
{
|
||||
IndexPackingRequest request = new IndexPackingRequest( mergedCtx, //
|
||||
mergedCtx.acquireIndexSearcher().getIndexReader(), //
|
||||
indexLocation.toFile() );
|
||||
indexPacker.packIndex( request );
|
||||
}
|
||||
|
||||
if ( indexMergerRequest.isTemporary() )
|
||||
{
|
||||
temporaryGroupIndexes.add( new TemporaryGroupIndex( mergedIndexDirectory, tempRepoId, groupId,
|
||||
indexMergerRequest.getMergedIndexTtl() ) );
|
||||
}
|
||||
stopWatch.stop();
|
||||
log.info( "merged index for repos {} in {} s", indexMergerRequest.getRepositoriesIds(),
|
||||
stopWatch.getTime() );
|
||||
return new MavenIndexContext(repositoryRegistry.getRepositoryGroup(groupId), mergedCtx);
|
||||
}
|
||||
catch ( IOException e)
|
||||
{
|
||||
throw new IndexMergerException( e.getMessage(), e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
runningGroups.remove( groupId );
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex )
|
||||
{
|
||||
if ( temporaryGroupIndex == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Optional<IndexingContext> ctxOpt = temporaryContextes.stream( ).filter( ctx -> ctx.getId( ).equals( temporaryGroupIndex.getIndexId( ) ) ).findFirst( );
|
||||
if (ctxOpt.isPresent()) {
|
||||
IndexingContext ctx = ctxOpt.get();
|
||||
indexer.closeIndexingContext( ctx, true );
|
||||
temporaryGroupIndexes.remove( temporaryGroupIndex );
|
||||
temporaryContextes.remove( ctx );
|
||||
Path directory = temporaryGroupIndex.getDirectory();
|
||||
if ( directory != null && Files.exists(directory) )
|
||||
{
|
||||
FileUtils.deleteDirectory( directory );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
log.warn( "fail to delete temporary group index {}", temporaryGroupIndex.getIndexId(), e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TemporaryGroupIndex> getTemporaryGroupIndexes()
|
||||
{
|
||||
return this.temporaryGroupIndexes;
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.RepositoryGroup;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -68,20 +69,33 @@ public void schedule(RepositoryGroup repositoryGroup, Path directory )
|
||||
|
||||
List<ManagedRepository> repositories = repositoryGroup.getRepositories();
|
||||
|
||||
IndexMergerRequest indexMergerRequest =
|
||||
new IndexMergerRequest( repositories.stream().map(r -> r.getId()).collect(Collectors.toList()), true, repositoryGroup.getId(),
|
||||
repositoryGroup.getMergedIndexPath().getFilePath().toString(),
|
||||
repositoryGroup.getMergedIndexTTL() ).mergedIndexDirectory( directory );
|
||||
if (repositoryGroup.supportsFeature( IndexCreationFeature.class ))
|
||||
{
|
||||
|
||||
MergedRemoteIndexesTaskRequest taskRequest =
|
||||
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
Path indexPath = indexCreationFeature.getLocalIndexPath().getFilePath();
|
||||
if (indexPath!=null)
|
||||
{
|
||||
IndexMergerRequest indexMergerRequest =
|
||||
new IndexMergerRequest( repositories.stream( ).map( r -> r.getId( ) ).collect( Collectors.toList( ) ), true, repositoryGroup.getId( ),
|
||||
indexPath.toString( ),
|
||||
repositoryGroup.getMergedIndexTTL( ) ).mergedIndexDirectory( directory );
|
||||
|
||||
logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(),
|
||||
repositoryGroup.getSchedulingDefinition() );
|
||||
MergedRemoteIndexesTaskRequest taskRequest =
|
||||
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||
|
||||
ScheduledFuture scheduledFuture =
|
||||
taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger );
|
||||
scheduledFutureMap.put( repositoryGroup.getId(), scheduledFuture );
|
||||
logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId( ),
|
||||
repositoryGroup.getSchedulingDefinition( ) );
|
||||
|
||||
ScheduledFuture scheduledFuture =
|
||||
taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger );
|
||||
scheduledFutureMap.put( repositoryGroup.getId( ), scheduledFuture );
|
||||
} else {
|
||||
logger.error("Requested index merger for repository group {} with non local index path {}", repositoryGroup.getId(), indexCreationFeature.getLocalIndexPath());
|
||||
}
|
||||
} else {
|
||||
logger.error("Scheduling merged index for repository group {}, but it does not support IndexCreationFeature.", repositoryGroup.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,8 +40,6 @@ public class AbstractRepositoryGroup extends AbstractRepository implements Edita
|
||||
|
||||
private ListOrderedMap<String, ManagedRepository> repositories = new ListOrderedMap<>();
|
||||
|
||||
private String mergedIndexPath;
|
||||
|
||||
private int mergedIndexTTL;
|
||||
|
||||
private final ReadWriteLock rwl = new ReentrantReadWriteLock();
|
||||
@ -132,11 +130,6 @@ public ManagedRepository removeRepository(String repoId) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMergedIndexPath(String path) {
|
||||
this.mergedIndexPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMergedIndexTTL(int timeInSeconds) {
|
||||
this.mergedIndexTTL = timeInSeconds;
|
||||
@ -172,11 +165,6 @@ public boolean contains(String id) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageAsset getMergedIndexPath() {
|
||||
return storage.getAsset(mergedIndexPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMergedIndexTTL() {
|
||||
return mergedIndexTTL;
|
||||
|
@ -47,4 +47,11 @@
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="taskScheduler#mergeRemoteIndexes"
|
||||
class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler">
|
||||
<property name="poolSize" value="4"/>
|
||||
<property name="threadGroupName" value="mergeRemoteIndexes"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
@ -21,7 +21,6 @@
|
||||
import org.apache.archiva.common.utils.FileUtils;
|
||||
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||
import org.apache.archiva.indexer.UnsupportedBaseContextException;
|
||||
import org.apache.archiva.indexer.maven.MavenIndexContext;
|
||||
import org.apache.archiva.indexer.merger.IndexMerger;
|
||||
import org.apache.archiva.indexer.merger.IndexMergerException;
|
||||
import org.apache.archiva.indexer.merger.IndexMergerRequest;
|
||||
|
@ -40,6 +40,8 @@
|
||||
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.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RemoteIndexFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -492,7 +494,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
}
|
||||
if (context.supports(IndexingContext.class)) {
|
||||
try {
|
||||
Path newPath = getIndexPath(repo);
|
||||
StorageAsset newPath = getIndexPath(repo);
|
||||
IndexingContext ctx = context.getBaseContext(IndexingContext.class);
|
||||
Path oldPath = ctx.getIndexDirectoryFile().toPath();
|
||||
if (oldPath.equals(newPath)) {
|
||||
@ -506,7 +508,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
return createContext(repo);
|
||||
} else {
|
||||
context.close(false);
|
||||
Files.move(oldPath, newPath);
|
||||
Files.move(oldPath, newPath.getFilePath());
|
||||
return createContext(repo);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -533,58 +535,45 @@ public void updateLocalIndexPath(Repository repo) {
|
||||
}
|
||||
}
|
||||
|
||||
private Path getIndexPath(Repository repo) throws IOException {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
Path repoDir = repo.getLocalPath();
|
||||
URI indexDir = icf.getIndexPath();
|
||||
private StorageAsset getIndexPath(URI indexDir, Path repoDir, String defaultDir) throws IOException
|
||||
{
|
||||
String indexPath = indexDir.getPath();
|
||||
Path indexDirectory = null;
|
||||
if ( ! StringUtils.isEmpty(indexDir.toString( ) ) )
|
||||
{
|
||||
|
||||
indexDirectory = PathUtil.getPathFromUri( indexDir );
|
||||
// not absolute so create it in repository directory
|
||||
if ( !indexDirectory.isAbsolute( ) )
|
||||
if ( indexDirectory.isAbsolute( ) )
|
||||
{
|
||||
indexPath = indexDirectory.getFileName().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( indexDirectory );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( DEFAULT_INDEXER_DIR );
|
||||
indexDirectory = repoDir.resolve( defaultDir );
|
||||
indexPath = defaultDir;
|
||||
}
|
||||
|
||||
if ( !Files.exists( indexDirectory ) )
|
||||
{
|
||||
Files.createDirectories( indexDirectory );
|
||||
}
|
||||
return indexDirectory;
|
||||
return new FilesystemAsset( indexPath, indexDirectory);
|
||||
}
|
||||
|
||||
private Path getPackedIndexPath(Repository repo) throws IOException {
|
||||
private StorageAsset getIndexPath( 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( ) ) )
|
||||
{
|
||||
return getIndexPath( icf.getIndexPath(), repo.getLocalPath(), DEFAULT_INDEXER_DIR );
|
||||
}
|
||||
|
||||
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 StorageAsset getPackedIndexPath(Repository repo) throws IOException {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
return getIndexPath(icf.getPackedIndexPath(), repo.getLocalPath(), DEFAULT_PACKED_INDEX_DIR);
|
||||
}
|
||||
|
||||
private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
|
||||
@ -601,7 +590,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
Files.createDirectories( repoDir );
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
// is there configured indexDirectory ?
|
||||
if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) )
|
||||
@ -620,7 +609,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
remoteRepository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
return getIndexingContext( remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl );
|
||||
|
||||
}
|
||||
@ -631,9 +620,9 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
}
|
||||
}
|
||||
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, Path indexDirectory, String indexUrl ) throws IOException
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, StorageAsset indexDirectory, String indexUrl ) throws IOException
|
||||
{
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.toFile( ),
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.getFilePath().toFile( ),
|
||||
repository.getLocation( ) == null ? null : repository.getLocation( ).toString( ),
|
||||
indexUrl,
|
||||
true, false,
|
||||
@ -659,7 +648,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
}
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
if ( repository.supportsFeature( IndexCreationFeature.class ) )
|
||||
{
|
||||
@ -677,7 +666,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
repository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl );
|
||||
context.setSearchable( repository.isScanned( ) );
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.archiva.common.filelock.FileLockManager;
|
||||
import org.apache.archiva.repository.*;
|
||||
import org.apache.archiva.repository.content.FilesystemStorage;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -36,7 +37,7 @@ public class MavenRepositoryGroup extends AbstractRepositoryGroup implements Edi
|
||||
new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
|
||||
new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
|
||||
new String[] {},
|
||||
new String[] {},
|
||||
new String[] {IndexCreationFeature.class.getName()},
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@ -48,6 +49,8 @@ public class MavenRepositoryGroup extends AbstractRepositoryGroup implements Edi
|
||||
|
||||
private FileLockManager lockManager;
|
||||
private FilesystemStorage fsStorage;
|
||||
private IndexCreationFeature indexCreationFeature;
|
||||
|
||||
|
||||
public MavenRepositoryGroup(String id, String name, Path repositoryBase, FileLockManager lockManager) {
|
||||
super(RepositoryType.MAVEN, id, name, repositoryBase);
|
||||
@ -78,5 +81,7 @@ private void init() {
|
||||
throw new RuntimeException("Fatal error while accessing repository path "+ getRepositoryBase(), e);
|
||||
}
|
||||
setStorage(fsStorage);
|
||||
this.indexCreationFeature = new IndexCreationFeature(this, this);
|
||||
addFeature( this.indexCreationFeature );
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.apache.archiva.common.filelock.FileLockManager;
|
||||
import org.apache.archiva.configuration.*;
|
||||
import org.apache.archiva.repository.*;
|
||||
import org.apache.archiva.repository.content.FilesystemAsset;
|
||||
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RemoteIndexFeature;
|
||||
@ -252,9 +253,26 @@ public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration config
|
||||
@Override
|
||||
public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException {
|
||||
repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), configuration.getName());
|
||||
repositoryGroup.setMergedIndexPath(configuration.getMergedIndexPath());
|
||||
repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl());
|
||||
repositoryGroup.setSchedulingDefinition(configuration.getCronExpression());
|
||||
if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) {
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
try
|
||||
{
|
||||
indexCreationFeature.setIndexPath( new URI(configuration.getMergedIndexPath()) );
|
||||
Path localPath = Paths.get(indexCreationFeature.getIndexPath());
|
||||
if (localPath.isAbsolute()) {
|
||||
indexCreationFeature.setLocalIndexPath( new FilesystemAsset(localPath.getFileName().toString(), localPath) );
|
||||
} else
|
||||
{
|
||||
indexCreationFeature.setLocalIndexPath( new FilesystemAsset(localPath.toString(), archivaConfiguration.getRepositoryGroupBaseDir( ).resolve( localPath )));
|
||||
}
|
||||
}
|
||||
catch ( URISyntaxException e )
|
||||
{
|
||||
log.error("Could not set the index path for repository group {}", repositoryGroup.getId());
|
||||
}
|
||||
}
|
||||
// References to other repositories are set filled by the registry
|
||||
}
|
||||
|
||||
@ -351,7 +369,12 @@ public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGr
|
||||
RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration();
|
||||
cfg.setId(repositoryGroup.getId());
|
||||
cfg.setName(repositoryGroup.getName());
|
||||
cfg.setMergedIndexPath(repositoryGroup.getMergedIndexPath().getPath());
|
||||
if (repositoryGroup.supportsFeature( IndexCreationFeature.class ))
|
||||
{
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
|
||||
cfg.setMergedIndexPath( indexCreationFeature.getIndexPath().toString() );
|
||||
}
|
||||
cfg.setMergedIndexTtl(repositoryGroup.getMergedIndexTTL());
|
||||
cfg.setRepositories(repositoryGroup.getRepositories().stream().map(r -> r.getId()).collect(Collectors.toList()));
|
||||
cfg.setCronExpression(repositoryGroup.getSchedulingDefinition());
|
||||
|
@ -40,6 +40,8 @@
|
||||
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.features.IndexCreationFeature;
|
||||
import org.apache.archiva.repository.features.RemoteIndexFeature;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -479,7 +481,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
}
|
||||
if (context.supports(IndexingContext.class)) {
|
||||
try {
|
||||
Path newPath = getIndexPath(repo);
|
||||
StorageAsset newPath = getIndexPath(repo);
|
||||
IndexingContext ctx = context.getBaseContext(IndexingContext.class);
|
||||
Path oldPath = ctx.getIndexDirectoryFile().toPath();
|
||||
if (oldPath.equals(newPath)) {
|
||||
@ -493,7 +495,7 @@ public ArchivaIndexingContext move(ArchivaIndexingContext context, Repository re
|
||||
return createContext(repo);
|
||||
} else {
|
||||
context.close(false);
|
||||
Files.move(oldPath, newPath);
|
||||
Files.move(oldPath, newPath.getFilePath());
|
||||
return createContext(repo);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -520,17 +522,22 @@ public void updateLocalIndexPath(Repository repo) {
|
||||
}
|
||||
|
||||
|
||||
private Path getIndexPath(Repository repo) throws IOException {
|
||||
private StorageAsset getIndexPath( Repository repo) throws IOException {
|
||||
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
|
||||
Path repoDir = repo.getLocalPath();
|
||||
URI indexDir = icf.getIndexPath();
|
||||
String indexPath = indexDir.getPath();
|
||||
Path indexDirectory = null;
|
||||
if ( ! StringUtils.isEmpty(indexDir.toString( ) ) )
|
||||
{
|
||||
|
||||
indexDirectory = PathUtil.getPathFromUri( indexDir );
|
||||
// not absolute so create it in repository directory
|
||||
if ( !indexDirectory.isAbsolute( ) )
|
||||
if ( indexDirectory.isAbsolute( ) )
|
||||
{
|
||||
indexPath = indexDirectory.getFileName().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( indexDirectory );
|
||||
}
|
||||
@ -538,13 +545,14 @@ private Path getIndexPath(Repository repo) throws IOException {
|
||||
else
|
||||
{
|
||||
indexDirectory = repoDir.resolve( ".index" );
|
||||
indexPath = ".index";
|
||||
}
|
||||
|
||||
if ( !Files.exists( indexDirectory ) )
|
||||
{
|
||||
Files.createDirectories( indexDirectory );
|
||||
}
|
||||
return indexDirectory;
|
||||
return new FilesystemAsset( indexPath, indexDirectory );
|
||||
}
|
||||
|
||||
private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
|
||||
@ -561,7 +569,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
Files.createDirectories( repoDir );
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
// is there configured indexDirectory ?
|
||||
if ( remoteRepository.supportsFeature( RemoteIndexFeature.class ) )
|
||||
@ -580,7 +588,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
remoteRepository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
return getIndexingContext( remoteRepository, contextKey, repoDir, indexDirectory, remoteIndexUrl );
|
||||
|
||||
}
|
||||
@ -591,9 +599,9 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
|
||||
}
|
||||
}
|
||||
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, Path indexDirectory, String indexUrl ) throws IOException
|
||||
private IndexingContext getIndexingContext( Repository repository, String contextKey, Path repoDir, StorageAsset indexDirectory, String indexUrl ) throws IOException
|
||||
{
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.toFile( ),
|
||||
return indexer.createIndexingContext( contextKey, repository.getId( ), repoDir.toFile( ), indexDirectory.getFilePath().toFile( ),
|
||||
repository.getLocation( ) == null ? null : repository.getLocation( ).toString( ),
|
||||
indexUrl,
|
||||
true, false,
|
||||
@ -619,7 +627,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
}
|
||||
}
|
||||
|
||||
Path indexDirectory = null;
|
||||
StorageAsset indexDirectory = null;
|
||||
|
||||
if ( repository.supportsFeature( IndexCreationFeature.class ) )
|
||||
{
|
||||
@ -637,7 +645,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
|
||||
// delete it first then recreate it.
|
||||
log.warn( "the index of repository {} is too old we have to delete and recreate it", //
|
||||
repository.getId( ) );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory );
|
||||
org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory.getFilePath() );
|
||||
context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl );
|
||||
context.setSearchable( repository.isScanned( ) );
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -295,7 +296,8 @@ public void getRemoteConfiguration() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRepositoryGroupConfiguration() throws RepositoryException {
|
||||
public void getRepositoryGroupConfiguration() throws RepositoryException, URISyntaxException
|
||||
{
|
||||
MavenRepositoryGroup repositoryGroup = new MavenRepositoryGroup("group1","group1",Paths.get("target/groups"),
|
||||
new DefaultFileLockManager());
|
||||
MavenManagedRepository repo1 = new MavenManagedRepository( "test01", "My Test repo", Paths.get("target/repositories") );
|
||||
@ -304,7 +306,8 @@ public void getRepositoryGroupConfiguration() throws RepositoryException {
|
||||
|
||||
repositoryGroup.setDescription(repositoryGroup.getPrimaryLocale(), "Repository group");
|
||||
repositoryGroup.setLayout("non-default");
|
||||
repositoryGroup.setMergedIndexPath(".index2");
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
indexCreationFeature.setIndexPath( new URI(".index2") );
|
||||
repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), "Repo Group 1");
|
||||
repositoryGroup.setMergedIndexTTL(1005);
|
||||
repositoryGroup.setSchedulingDefinition("0 0 04 ? * THU");
|
||||
@ -351,7 +354,8 @@ public void createRepositoryGroupWithCfg() throws RepositoryException {
|
||||
assertEquals("group2", grp.getId());
|
||||
assertEquals("Group 2", grp.getName());
|
||||
assertEquals("0 0 03 ? * MON", grp.getSchedulingDefinition());
|
||||
assertEquals(".index-abc", grp.getMergedIndexPath().getName());
|
||||
IndexCreationFeature indexCreationFeature = grp.getFeature( IndexCreationFeature.class ).get();
|
||||
assertEquals(".index-abc", indexCreationFeature.getIndexPath());
|
||||
assertEquals(504, grp.getMergedIndexTTL());
|
||||
assertEquals(0, grp.getRepositories().size());
|
||||
// assertTrue(grp.getRepositories().stream().anyMatch(r -> "test01".equals(r.getId())));
|
||||
|
@ -262,14 +262,14 @@ private void finishIndexingTask( ArtifactIndexingTask indexingTask, ManagedRepos
|
||||
if ( repository.supportsFeature( IndexCreationFeature.class ) )
|
||||
{
|
||||
IndexCreationFeature icf = repository.getFeature( IndexCreationFeature.class ).get( );
|
||||
if ( !icf.isSkipPackedIndexCreation( ) && icf.getLocalPackedIndexPath( ) != null )
|
||||
if ( !icf.isSkipPackedIndexCreation( ) && icf.getLocalPackedIndexPath( ) != null && icf.getLocalIndexPath().getFilePath()!=null )
|
||||
{
|
||||
|
||||
log.debug( "Creating packed index from {} on {}", context.getIndexDirectoryFile( ), icf.getLocalPackedIndexPath( ) );
|
||||
IndexPackingRequest request = new IndexPackingRequest( context, //
|
||||
context.acquireIndexSearcher( ).getIndexReader( ),
|
||||
//
|
||||
icf.getLocalPackedIndexPath( ).toFile( ) );
|
||||
icf.getLocalPackedIndexPath( ).getFilePath().toFile( ) );
|
||||
|
||||
indexPacker.packIndex( request );
|
||||
context.updateTimestamp( true );
|
||||
|
@ -26,6 +26,7 @@
|
||||
import org.apache.archiva.repository.ManagedRepository;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.content.StorageAsset;
|
||||
import org.apache.archiva.repository.features.IndexCreationFeature;
|
||||
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
@ -275,20 +276,27 @@ public void testPackagedIndex()
|
||||
|
||||
Path basePath = repo.getLocalPath();
|
||||
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get();
|
||||
Path packedIndexDirectory = icf.getLocalPackedIndexPath();
|
||||
Path indexerDirectory = icf.getLocalIndexPath();
|
||||
StorageAsset packedIndexDirectory = icf.getLocalPackedIndexPath();
|
||||
StorageAsset indexerDirectory = icf.getLocalIndexPath();
|
||||
|
||||
for (Path dir : new Path[] { packedIndexDirectory, indexerDirectory }) {
|
||||
Files.list(dir).filter(path -> path.getFileName().toString().startsWith("nexus-maven-repository-index"))
|
||||
.forEach(path ->
|
||||
for (StorageAsset dir : new StorageAsset[] { packedIndexDirectory, indexerDirectory }) {
|
||||
if (dir.getFilePath()!=null)
|
||||
{
|
||||
Path localDirPath = dir.getFilePath();
|
||||
Files.list( localDirPath ).filter( path -> path.getFileName( ).toString( ).startsWith( "nexus-maven-repository-index" ) )
|
||||
.forEach( path ->
|
||||
{
|
||||
try {
|
||||
System.err.println("Deleting " + path);
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
System.err.println( "Deleting " + path );
|
||||
Files.delete( path );
|
||||
}
|
||||
});
|
||||
catch ( IOException e )
|
||||
{
|
||||
e.printStackTrace( );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -310,20 +318,20 @@ public void testPackagedIndex()
|
||||
|
||||
indexingExecutor.executeTask( task );
|
||||
|
||||
assertTrue( Files.exists(packedIndexDirectory) );
|
||||
assertTrue( Files.exists(indexerDirectory) );
|
||||
assertTrue( Files.exists(packedIndexDirectory.getFilePath()) );
|
||||
assertTrue( Files.exists(indexerDirectory.getFilePath()) );
|
||||
|
||||
// test packed index file creation
|
||||
//no more zip
|
||||
//Assertions.assertThat(new File( indexerDirectory, "nexus-maven-repository-index.zip" )).exists();
|
||||
Assertions.assertThat( Files.exists(packedIndexDirectory.resolve("nexus-maven-repository-index.properties" ) ));
|
||||
Assertions.assertThat( Files.exists(packedIndexDirectory.resolve("nexus-maven-repository-index.gz" ) ));
|
||||
assertFalse( Files.exists(packedIndexDirectory.resolve("nexus-maven-repository-index.1.gz" ) ));
|
||||
Assertions.assertThat( Files.exists(packedIndexDirectory.getFilePath().resolve("nexus-maven-repository-index.properties" ) ));
|
||||
Assertions.assertThat( Files.exists(packedIndexDirectory.getFilePath().resolve("nexus-maven-repository-index.gz" ) ));
|
||||
assertFalse( Files.exists(packedIndexDirectory.getFilePath().resolve("nexus-maven-repository-index.1.gz" ) ));
|
||||
|
||||
// unpack .zip index
|
||||
//unzipIndex( indexerDirectory.getPath(), destDir.getPath() );
|
||||
|
||||
DefaultIndexUpdater.FileFetcher fetcher = new DefaultIndexUpdater.FileFetcher( packedIndexDirectory.toFile() );
|
||||
DefaultIndexUpdater.FileFetcher fetcher = new DefaultIndexUpdater.FileFetcher( packedIndexDirectory.getFilePath().toFile() );
|
||||
IndexUpdateRequest updateRequest = new IndexUpdateRequest( getIndexingContext(), fetcher );
|
||||
//updateRequest.setLocalIndexCacheDir( indexerDirectory );
|
||||
indexUpdater.fetchAndUpdateIndex( updateRequest );
|
||||
|
@ -223,7 +223,7 @@ public void spool( OutputContext outputContext )
|
||||
}
|
||||
else if ( outputContext.hasStream() )
|
||||
{
|
||||
IndexWriter writer = new IndexWriter( getContent(), asset, logicalResource );
|
||||
IndexWriter writer = new IndexWriter( asset, logicalResource );
|
||||
writer.write( outputContext );
|
||||
}
|
||||
}
|
||||
|
@ -176,12 +176,6 @@ public class ArchivaDavResourceFactory
|
||||
*/
|
||||
private final LockManager lockManager = new SimpleLockManager();
|
||||
|
||||
private ChecksummedFile checksum;
|
||||
|
||||
private Digester digestSha1;
|
||||
|
||||
private Digester digestMd5;
|
||||
|
||||
@Inject
|
||||
@Named( value = "archivaTaskScheduler#repository" )
|
||||
private RepositoryArchivaTaskScheduler scheduler;
|
||||
@ -193,8 +187,7 @@ public class ArchivaDavResourceFactory
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Inject
|
||||
public ArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
|
||||
ArchivaConfiguration archivaConfiguration )
|
||||
public ArchivaDavResourceFactory( ApplicationContext applicationContext, ArchivaConfiguration archivaConfiguration )
|
||||
throws PlexusSisuBridgeException
|
||||
{
|
||||
this.archivaConfiguration = archivaConfiguration;
|
||||
@ -420,7 +413,12 @@ private DavResource processRepositoryGroup( final DavServletRequest request,
|
||||
|
||||
String rootPath = StringUtils.substringBeforeLast( pathInfo, "/" );
|
||||
|
||||
if ( StringUtils.endsWith( rootPath, repoGroup.getMergedIndexPath().getPath() ) )
|
||||
String mergedIndexPath = "/";
|
||||
if (repoGroup.supportsFeature( IndexCreationFeature.class )) {
|
||||
mergedIndexPath = repoGroup.getFeature( IndexCreationFeature.class ).get().getIndexPath().getPath();
|
||||
}
|
||||
|
||||
if ( StringUtils.endsWith( rootPath, mergedIndexPath ) )
|
||||
{
|
||||
// we are in the case of index file request
|
||||
String requestedFileName = StringUtils.substringAfterLast( pathInfo, "/" );
|
||||
@ -1044,11 +1042,16 @@ private DavResource getResourceFromGroup( DavServletRequest request,
|
||||
|
||||
// remove last /
|
||||
String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
|
||||
String mergedIndexPath = "/";
|
||||
if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) {
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
mergedIndexPath = indexCreationFeature.getIndexPath().getPath();
|
||||
}
|
||||
|
||||
if ( allow )
|
||||
{
|
||||
|
||||
if ( StringUtils.endsWith( pathInfo, repositoryGroup.getMergedIndexPath().getPath() ) )
|
||||
if ( StringUtils.endsWith( pathInfo, mergedIndexPath ) )
|
||||
{
|
||||
Path mergedRepoDirPath =
|
||||
buildMergedIndexDirectory( activePrincipal, request, repositoryGroup );
|
||||
@ -1061,7 +1064,7 @@ private DavResource getResourceFromGroup( DavServletRequest request,
|
||||
{
|
||||
Path tmpDirectory = Paths.get( SystemUtils.getJavaIoTmpDir().toString(),
|
||||
id,
|
||||
repositoryGroup.getMergedIndexPath().getFilePath().toString() );
|
||||
mergedIndexPath );
|
||||
if ( !Files.exists(tmpDirectory) )
|
||||
{
|
||||
synchronized ( tmpDirectory.toAbsolutePath().toString() )
|
||||
@ -1101,25 +1104,9 @@ private DavResource getResourceFromGroup( DavServletRequest request,
|
||||
{
|
||||
// in case of group displaying index directory doesn't have sense !!
|
||||
IndexCreationFeature idf = managedRepository.getRepository().getFeature(IndexCreationFeature.class).get();
|
||||
String repoIndexDirectory = idf.getIndexPath().toString();
|
||||
if ( StringUtils.isNotEmpty( repoIndexDirectory ) )
|
||||
{
|
||||
if ( !Paths.get( repoIndexDirectory ).isAbsolute() )
|
||||
{
|
||||
repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve(
|
||||
StringUtils.isEmpty( repoIndexDirectory )
|
||||
? ".indexer"
|
||||
: repoIndexDirectory ).toAbsolutePath().toString();
|
||||
}
|
||||
}
|
||||
if ( StringUtils.isEmpty( repoIndexDirectory ) )
|
||||
{
|
||||
repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve(
|
||||
".indexer" ).toAbsolutePath().toString();
|
||||
}
|
||||
|
||||
if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory ),
|
||||
FilenameUtils.normalize( resourceFile.toAbsolutePath().toString() ) ) )
|
||||
StorageAsset repoIndexDirectory = idf.getLocalIndexPath();
|
||||
if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory.getPath() ),
|
||||
FilenameUtils.normalize( logicalResource.getPath() ) ) )
|
||||
{
|
||||
// for prompted authentication
|
||||
if ( httpAuth.getSecuritySession( request.getSession( true ) ) != null )
|
||||
@ -1368,34 +1355,43 @@ protected Path buildMergedIndexDirectory( String activePrincipal,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
|
||||
id, authzRepos );
|
||||
|
||||
Path tempRepoFile = Files.createTempDirectory( "temp" );
|
||||
tempRepoFile.toFile().deleteOnExit();
|
||||
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
|
||||
Path indexPath = indexCreationFeature.getLocalIndexPath().getFilePath();
|
||||
if (indexPath!=null)
|
||||
{
|
||||
Path tempRepoFile = Files.createTempDirectory( "temp" );
|
||||
tempRepoFile.toFile( ).deleteOnExit( );
|
||||
|
||||
IndexMergerRequest indexMergerRequest =
|
||||
new IndexMergerRequest( authzRepos, true, id,
|
||||
repositoryGroup.getMergedIndexPath().getFilePath().toString(),
|
||||
repositoryGroup.getMergedIndexTTL() ).mergedIndexDirectory(
|
||||
tempRepoFile ).temporary( true );
|
||||
IndexMergerRequest indexMergerRequest =
|
||||
new IndexMergerRequest( authzRepos, true, id,
|
||||
indexPath.toString( ),
|
||||
repositoryGroup.getMergedIndexTTL( ) ).mergedIndexDirectory(
|
||||
tempRepoFile ).temporary( true );
|
||||
|
||||
MergedRemoteIndexesTaskRequest taskRequest =
|
||||
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||
MergedRemoteIndexesTaskRequest taskRequest =
|
||||
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||
|
||||
MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );
|
||||
MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );
|
||||
|
||||
ArchivaIndexingContext indexingContext = job.execute().getIndexingContext();
|
||||
ArchivaIndexingContext indexingContext = job.execute( ).getIndexingContext( );
|
||||
|
||||
Path mergedRepoDir = Paths.get(indexingContext.getPath());
|
||||
TemporaryGroupIndex temporaryGroupIndex =
|
||||
new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), id,
|
||||
repositoryGroup.getMergedIndexTTL() ) //
|
||||
.setCreationTime( new Date().getTime() );
|
||||
temporaryGroupIndexMap.put( id, temporaryGroupIndex );
|
||||
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
|
||||
temporaryGroupIndexMap );
|
||||
return mergedRepoDir;
|
||||
Path mergedRepoDir = Paths.get( indexingContext.getPath( ) );
|
||||
TemporaryGroupIndex temporaryGroupIndex =
|
||||
new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId( ), id,
|
||||
repositoryGroup.getMergedIndexTTL( ) ) //
|
||||
.setCreationTime( new Date( ).getTime( ) );
|
||||
temporaryGroupIndexMap.put( id, temporaryGroupIndex );
|
||||
session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
|
||||
temporaryGroupIndexMap );
|
||||
return mergedRepoDir;
|
||||
} else {
|
||||
log.error("Local index path for repository group {} does not exist.", repositoryGroup.getId());
|
||||
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
|
||||
}
|
||||
}
|
||||
catch ( RepositorySearchException e )
|
||||
{
|
||||
|
@ -718,7 +718,7 @@ class OverridingArchivaDavResourceFactory
|
||||
ArchivaConfiguration archivaConfiguration )
|
||||
throws PlexusSisuBridgeException
|
||||
{
|
||||
super( applicationContext, plexusSisuBridge, archivaConfiguration );
|
||||
super( applicationContext, archivaConfiguration );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,8 @@
|
||||
import junit.framework.TestCase;
|
||||
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.content.FilesystemAsset;
|
||||
import org.apache.archiva.repository.events.AuditListener;
|
||||
import org.apache.archiva.repository.maven2.MavenManagedRepository;
|
||||
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
|
||||
@ -47,6 +49,7 @@
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -116,10 +119,10 @@ public void tearDown()
|
||||
}
|
||||
}
|
||||
|
||||
private DavResource getDavResource( String logicalPath, Path file )
|
||||
private DavResource getDavResource( String logicalPath, Path file ) throws LayoutException
|
||||
{
|
||||
return new ArchivaDavResource( file.toAbsolutePath().toString(), logicalPath, repository, session, resourceLocator,
|
||||
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null, fileLockManager );
|
||||
return new ArchivaDavResource( new FilesystemAsset( logicalPath, file.toAbsolutePath()) , logicalPath, repository, session, resourceLocator,
|
||||
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -338,9 +341,16 @@ public DavResource createResource( DavResourceLocator locator, DavServletRequest
|
||||
public DavResource createResource( DavResourceLocator locator, DavSession session )
|
||||
throws DavException
|
||||
{
|
||||
return new ArchivaDavResource( baseDir.toAbsolutePath().toString(), "/", repository, session, resourceLocator,
|
||||
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(),
|
||||
null, fileLockManager );
|
||||
try
|
||||
{
|
||||
return new ArchivaDavResource( new FilesystemAsset( "/" , baseDir.toAbsolutePath()), "/", repository, session, resourceLocator,
|
||||
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(),
|
||||
null );
|
||||
}
|
||||
catch ( LayoutException e )
|
||||
{
|
||||
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public UnauthenticatedDavResourceFactory( ApplicationContext applicationContext,
|
||||
ArchivaConfiguration archivaConfiguration )
|
||||
throws PlexusSisuBridgeException
|
||||
{
|
||||
super( applicationContext, plexusSisuBridge, archivaConfiguration );
|
||||
super( applicationContext, archivaConfiguration );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,6 +115,12 @@ public Path getRemoteRepositoryBaseDir() {
|
||||
return getDataDirectory().resolve("remotes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getRepositoryGroupBaseDir( )
|
||||
{
|
||||
return getDataDirectory().resolve("group");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getDataDirectory() {
|
||||
if (configuration!=null && StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user