import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
-import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
import org.slf4j.Logger;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.policies.*;
+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.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.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexingContext;
import org.apache.maven.wagon.Wagon;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
-import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import java.nio.file.attribute.FileTime;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryCheckPath;
import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.metadata.model.facets.AuditEvent;
-import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.PasswordCredentials;
+import org.apache.archiva.repository.RemoteRepository;
import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
-import org.apache.archiva.repository.features.IndexCreationEvent;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
-import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
-import org.apache.maven.index_shaded.lucene.index.IndexFormatTooOldException;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
import javax.inject.Inject;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Inject
RepositoryRegistry repositoryRegistry;
- @Inject
- private List<? extends IndexCreator> indexCreators;
-
- @Inject
- private NexusIndexer indexer;
@PostConstruct
private void initialize()
}
}
- @PreDestroy
- private void shutdown()
- throws RepositoryAdminException
- {
- try
- {
- List<org.apache.archiva.admin.model.beans.RemoteRepository> remoteRepositories = getRemoteRepositories();
- // close index on shutdown
- for ( org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository : remoteRepositories )
- {
- IndexingContext context = indexer.getIndexingContexts().get( remoteRepository.getId() );
- if ( context != null )
- {
- indexer.removeIndexingContext( context, false );
- }
- }
- }
- catch ( IOException e )
- {
- throw new RepositoryAdminException( e.getMessage(), e );
- }
- }
-
-
/*
* Conversion between the repository from the registry and the serialized DTO for the admin API
*/
{
RemoteRepository repo = repositoryRegistry.getRemoteRepository(remoteRepository.getId());
return repo.getIndexingContext().getBaseContext(IndexingContext.class);
- /*String appServerBase = getRegistry().getString( "appserver.base" );
-
- String contextKey = "remote-" + remoteRepository.getId();
- IndexingContext indexingContext = indexer.getIndexingContexts().get( contextKey );
- if ( indexingContext != null )
- {
- return indexingContext;
- }
- // create remote repository path
- Path repoDir = Paths.get( appServerBase, "data/remotes/" + remoteRepository.getId() );
- if ( !Files.exists(repoDir) )
- {
- Files.createDirectories(repoDir);
- }
-
- Path indexDirectory = null;
-
- // is there configured indexDirectory ?
- String indexDirectoryPath = remoteRepository.getIndexDirectory();
-
- if ( StringUtils.isNotBlank( indexDirectoryPath ) )
- {
- repoDir.resolve( indexDirectoryPath );
- }
- // if not configured use a default value
- if ( indexDirectory == null )
- {
- indexDirectory = repoDir.resolve(".index" );
- }
- if ( !Files.exists(indexDirectory) )
- {
- Files.createDirectories(indexDirectory);
- }
-
- try
- {
-
- return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir.toFile(), indexDirectory.toFile(),
- remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
- indexCreators );
- }
- catch ( IndexFormatTooOldException e )
- {
- // existing index with an old lucene format so we need to delete it!!!
- // 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 );
- return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir.toFile(), indexDirectory.toFile(),
- remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ),
- indexCreators );
-
- }*/
} catch (UnsupportedBaseContextException e) {
throw new RepositoryAdminException( e.getMessage(), e);
}
+++ /dev/null
-package org.apache.archiva.rest.services.utils;
-/*
- * 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.plexusbridge.PlexusSisuBridge;
-import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexingContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-
-/**
- * @author Olivier Lamy
- */
-@Service
-public class MavenIndexerCleaner
-{
- Logger log = LoggerFactory.getLogger( getClass() );
-
- @Inject
- private NexusIndexer nexusIndexer;
-
- @PreDestroy
- public void shutdown()
- throws Exception
- {
-
- log.info( "cleanup IndexingContext" );
- for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() )
- {
- nexusIndexer.removeIndexingContext( context, true );
- }
- }
-}
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest;
-import org.apache.archiva.webdav.util.MavenIndexerCleaner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
CacheManager.getInstance().clearAll();
- applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
-
}
import org.apache.archiva.security.ServletAuthenticator;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.archiva.webdav.util.MavenIndexerCleaner;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.webdav.DavSessionProvider;
FileUtils.deleteDirectory( repoRootInternal );
}*/
- applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
-
super.tearDown();
}
+++ /dev/null
-package org.apache.archiva.webdav.util;
-/*
- * 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.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexingContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-/**
- * @author Olivier Lamy
- */
-@Service
-public class MavenIndexerCleaner
- implements ServletContextListener
-{
- Logger log = LoggerFactory.getLogger( getClass() );
-
-
-
- @Inject
- private ApplicationContext applicationContext;
-
- @Inject
- NexusIndexer nexusIndexer;
-
- @PostConstruct
- public void startup()
- {
- cleanupIndex();
- }
-
- @PreDestroy
- public void shutdown()
- {
- cleanupIndex();
- }
-
-
- @Override
- public void contextInitialized( ServletContextEvent servletContextEvent )
- {
- try
- {
- cleanupIndex();
-
- }
- catch ( Exception e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- }
-
- @Override
- public void contextDestroyed( ServletContextEvent servletContextEvent )
- {
- try
- {
- cleanupIndex();
-
- }
- catch ( Exception e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- }
-
- public void cleanupIndex()
- {
- log.info( "cleanup IndexingContext" );
- try
- {
- for ( IndexingContext context : nexusIndexer.getIndexingContexts().values() )
- {
- nexusIndexer.removeIndexingContext( context, true );
- }
- }
- catch ( Exception e )
- {
- log.warn( "fail to cleanupIndex: {}", e.getMessage(), e );
- }
-
- }
-
-
-}
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
- <listener>
- <listener-class>org.apache.archiva.webdav.util.MavenIndexerCleaner</listener-class>
- </listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
- <listener>
- <listener-class>org.apache.archiva.webdav.util.MavenIndexerCleaner</listener-class>
- </listener>
<context-param>
<param-name>contextConfigLocation</param-name>