]> source.dussan.org Git - archiva.git/commitdiff
Removing IndexerCleaners
authorMartin Stockhammer <martin_s@apache.org>
Fri, 30 Mar 2018 13:15:26 +0000 (15:15 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Fri, 30 Mar 2018 13:15:26 +0000 (15:15 +0200)
archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/MavenIndexerCleaner.java [deleted file]
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java [deleted file]
archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/repository-servlet-security-test/web.xml
archiva-modules/archiva-web/archiva-webdav/src/test/resources/WEB-INF/web.xml

index efd5e7e8ffffbef1258a1e02f485c722c15b7095..d8c482d1bbc9d2d121e7fd9708f331faa7bf132c 100644 (file)
@@ -36,7 +36,6 @@ import org.apache.archiva.repository.RepositoryRegistry;
 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;
index 2bb82d50d6b5b105c3dab11836668aa1f93f1ea7..30e17f92b793e02391eca2d1c01dbabc0bc1e8e9 100644 (file)
@@ -26,19 +26,21 @@ 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.*;
+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;
@@ -58,7 +60,11 @@ import java.nio.file.Paths;
 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;
 
index 6b063e36e8f1efb90cbe50781fb182ebbcaf2189..8759a027837adaa84cd09e75fab787c510129803 100644 (file)
@@ -24,36 +24,23 @@ import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
 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;
@@ -72,11 +59,6 @@ public class DefaultRemoteRepositoryAdmin
     @Inject
     RepositoryRegistry repositoryRegistry;
 
-    @Inject
-    private List<? extends IndexCreator> indexCreators;
-
-    @Inject
-    private NexusIndexer indexer;
 
     @PostConstruct
     private void initialize()
@@ -88,30 +70,6 @@ public class DefaultRemoteRepositoryAdmin
         }
     }
 
-    @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
  */
@@ -311,59 +269,6 @@ public class DefaultRemoteRepositoryAdmin
         {
             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);
         }
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/MavenIndexerCleaner.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/utils/MavenIndexerCleaner.java
deleted file mode 100644 (file)
index c633adb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-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 );
-        }
-    }
-}
index 1a65a35baf8c7215f3e71f1a1f8893a08ecfe7b2..96828aba7ffc46ab19fd2a656369005d53d6bf36 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
 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;
@@ -150,8 +149,6 @@ public abstract class AbstractRepositoryServletTestCase
 
         CacheManager.getInstance().clearAll();
 
-        applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
-
 
     }
 
index f6d6f2670aef616845cc31e58ae903cd65122478..41683c07cbad0212682de29f53ae7cb0e1d70c22 100644 (file)
@@ -38,7 +38,6 @@ import org.apache.archiva.repository.audit.TestAuditListener;
 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;
@@ -212,8 +211,6 @@ public class RepositoryServletSecurityTest
             FileUtils.deleteDirectory( repoRootInternal );
         }*/
 
-        applicationContext.getBean( MavenIndexerCleaner.class ).cleanupIndex();
-
         super.tearDown();
     }
 
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/util/MavenIndexerCleaner.java
deleted file mode 100644 (file)
index cd59302..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-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 );
-        }
-
-    }
-
-
-}
index 158e4724a4f666a82dff4672e8a53a11907c4433..4e83153aa0f12da259e637006ca7156b01491366 100644 (file)
@@ -27,9 +27,6 @@
   <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>
index d03192e4bdcc79830fdb40e4238481a988a415e7..1e7d54687e4e5a7d1f83bc6f02b99d186631534c 100644 (file)
@@ -27,9 +27,6 @@
   <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>