diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java
index 33df01ac4..6d462c2fb 100644
--- a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumer.java
@@ -23,13 +23,23 @@ import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
+import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
import java.util.List;
+import java.io.File;
/**
- * DatabaseCleanupRemoveArtifactConsumer
+ * Consumer for cleaning up the database of artifacts that are no longer existing in the repository.
*
* @author Joakim Erdfelt
+ * Maria Odea Ching
* @version $Id$
*
* @plexus.component role="org.apache.maven.archiva.consumers.DatabaseCleanupConsumer"
@@ -50,6 +60,21 @@ public class DatabaseCleanupRemoveArtifactConsumer
*/
private String description;
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private ArtifactDAO artifactDAO;
+
+ /**
+ * @plexus.requirement
+ */
+ private BidirectionalRepositoryLayoutFactory layoutFactory;
+
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryContentFactory repositoryFactory;
+
public void beginScan()
{
// TODO Auto-generated method stub
@@ -59,21 +84,38 @@ public class DatabaseCleanupRemoveArtifactConsumer
public void completeScan()
{
// TODO Auto-generated method stub
-
}
public List getIncludedTypes()
- {
- // TODO Auto-generated method stub
- return null;
+ {
+ return null;
}
public void processArchivaArtifact( ArchivaArtifact artifact )
throws ConsumerException
- {
- // TODO Auto-generated method stub
-
- }
+ {
+ try
+ {
+ ManagedRepositoryContent repositoryContent =
+ repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
+
+ File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) );
+
+ if( !file.exists() )
+ {
+ artifactDAO.deleteArtifact( artifact );
+ }
+ }
+ catch ( RepositoryException re )
+ {
+ throw new ConsumerException( "Can't run database cleanup remove artifact consumer: " +
+ re.getMessage() );
+ }
+ catch ( ArchivaDatabaseException e )
+ {
+ throw new ConsumerException( e.getMessage() );
+ }
+ }
public String getDescription()
{
@@ -90,4 +132,34 @@ public class DatabaseCleanupRemoveArtifactConsumer
return false;
}
+ public void setArtifactDAO( ArtifactDAO artifactDAO)
+ {
+ this.artifactDAO = artifactDAO;
+ }
+
+ public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory )
+ {
+ this.layoutFactory = layoutFactory;
+ }
+
+ public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+ {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ private String toPath( ArchivaArtifact artifact )
+ {
+ try
+ {
+ BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
+
+ return layout.toPath( artifact );
+ }
+ catch ( LayoutException e )
+ {
+ getLogger().warn( "Unable to calculate path for artifact: " + artifact );
+ return null;
+ }
+ }
+
}
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java
index 2aa21c96e..6203fc9ea 100644
--- a/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumer.java
@@ -19,17 +19,31 @@ package org.apache.maven.archiva.consumers.database;
* under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
+import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
+import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
import java.util.List;
+import java.util.ArrayList;
+import java.io.File;
/**
- * DatabaseCleanupRemoveProjectConsumer
+ * Consumer for removing or deleting from the database the project models fo artifacts that have been
+ * deleted/removed from the repository.
*
* @author Joakim Erdfelt
+ * Maria Odea Ching
* @version $Id$
*
* @plexus.component role="org.apache.maven.archiva.consumers.DatabaseCleanupConsumer"
@@ -50,29 +64,72 @@ public class DatabaseCleanupRemoveProjectConsumer
*/
private String description;
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private ProjectModelDAO projectModelDAO;
+
+ /**
+ * @plexus.requirement
+ */
+ private BidirectionalRepositoryLayoutFactory layoutFactory;
+
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryContentFactory repositoryFactory;
+
public void beginScan()
{
// TODO Auto-generated method stub
-
}
public void completeScan()
{
// TODO Auto-generated method stub
-
}
public List getIncludedTypes()
- {
- // TODO Auto-generated method stub
- return null;
+ {
+ return null;
}
public void processArchivaArtifact( ArchivaArtifact artifact )
throws ConsumerException
- {
- // TODO Auto-generated method stub
-
+ {
+ if ( !StringUtils.equals( "pom", artifact.getType() ) )
+ {
+ // Not a pom. Skip it.
+ return;
+ }
+
+ try
+ {
+ ManagedRepositoryContent repositoryContent =
+ repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
+
+ File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) );
+
+ if( !file.exists() )
+ {
+ ArchivaProjectModel projectModel = projectModelDAO.getProjectModel(
+ artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
+
+ projectModelDAO.deleteProjectModel( projectModel );
+ }
+ }
+ catch ( RepositoryException re )
+ {
+ re.printStackTrace();
+ throw new ConsumerException( "Can't run database cleanup remove artifact consumer: " +
+ re.getMessage() );
+ }
+ catch ( ArchivaDatabaseException e )
+ {
+ e.printStackTrace();
+ throw new ConsumerException( e.getMessage() );
+ }
+
}
public String getDescription()
@@ -88,6 +145,36 @@ public class DatabaseCleanupRemoveProjectConsumer
public boolean isPermanent()
{
return false;
+ }
+
+ private String toPath( ArchivaArtifact artifact )
+ {
+ try
+ {
+ BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
+
+ return layout.toPath( artifact );
+ }
+ catch ( LayoutException e )
+ {
+ getLogger().warn( "Unable to calculate path for artifact: " + artifact );
+ return null;
+ }
}
+ public void setProjectModelDAO( ProjectModelDAO projectModelDAO )
+ {
+ this.projectModelDAO = projectModelDAO;
+ }
+
+ public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory )
+ {
+ this.layoutFactory = layoutFactory;
+ }
+
+ public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+ {
+ this.repositoryFactory = repositoryFactory;
+ }
+
}
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java
new file mode 100644
index 000000000..e49ff497b
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java
@@ -0,0 +1,104 @@
+package org.apache.maven.archiva.consumers.database;
+
+/*
+ * 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.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaArtifactModel;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+
+import java.io.File;
+
+/**
+ * @author Maria Odea Ching
+ */
+public class AbstractDatabaseCleanupTest
+ extends PlexusTestCase
+{
+ ArchivaConfiguration archivaConfig;
+
+ BidirectionalRepositoryLayoutFactory layoutFactory;
+
+ RepositoryContentFactory repositoryFactory;
+
+ public static final String TEST_GROUP_ID = "org.apache.maven.archiva";
+
+ public static final String TEST_ARTIFACT_ID = "cleanup-artifact-test";
+
+ public static final String TEST_VERSION = "1.0";
+
+ public static final String TEST_REPO_ID = "test-repo";
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ // archiva configuration (need to update the repository url)
+ File userFile = getTestFile( "target/test/repository-manager.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ userFile.getParentFile().mkdirs();
+ FileUtils.copyFileToDirectory( getTestFile( "src/test/conf/repository-manager.xml" ),
+ userFile.getParentFile() );
+
+ archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "database-cleanup" );
+
+ Configuration configuration = archivaConfig.getConfiguration();
+ ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( TEST_REPO_ID );
+ repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
+
+ archivaConfig.save( configuration );
+
+ // set bidirectional repository layout factory
+ layoutFactory = (BidirectionalRepositoryLayoutFactory) lookup( BidirectionalRepositoryLayoutFactory.class );
+
+ repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
+ }
+
+ protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
+ {
+ ArchivaArtifactModel model = new ArchivaArtifactModel();
+ model.setGroupId( groupId );
+ model.setArtifactId( artifactId );
+ model.setVersion( version );
+ model.setType( type );
+ model.setRepositoryId( TEST_REPO_ID );
+
+ return new ArchivaArtifact( model );
+ }
+
+ protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
+ {
+ ArchivaProjectModel projectModel = new ArchivaProjectModel();
+ projectModel.setGroupId( groupId );
+ projectModel.setArtifactId( artifactId );
+ projectModel.setVersion( version );
+
+ return projectModel;
+ }
+}
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java
new file mode 100644
index 000000000..1e4932129
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.java
@@ -0,0 +1,84 @@
+package org.apache.maven.archiva.consumers.database;
+
+/*
+ * 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.easymock.MockControl;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.database.ArtifactDAO;
+
+/**
+ * Test for DatabaseCleanupRemoveArtifactConsumerTest
+ *
+ * @author Maria Odea Ching
+ */
+public class DatabaseCleanupRemoveArtifactConsumerTest
+ extends AbstractDatabaseCleanupTest
+{
+ private MockControl artifactDAOControl;
+
+ private ArtifactDAO artifactDAOMock;
+
+ private DatabaseCleanupRemoveArtifactConsumer dbCleanupRemoveArtifactConsumer;
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ dbCleanupRemoveArtifactConsumer = new DatabaseCleanupRemoveArtifactConsumer();
+
+ artifactDAOControl = MockControl.createControl( ArtifactDAO.class );
+
+ artifactDAOMock = (ArtifactDAO) artifactDAOControl.getMock();
+
+ dbCleanupRemoveArtifactConsumer.setArtifactDAO( artifactDAOMock );
+
+ dbCleanupRemoveArtifactConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
+
+ dbCleanupRemoveArtifactConsumer.setRepositoryFactory( repositoryFactory );
+ }
+
+ public void testIfArtifactWasNotDeleted()
+ throws Exception
+ {
+ ArchivaArtifact artifact = createArtifact( TEST_GROUP_ID, "do-not-cleanup-artifact-test", TEST_VERSION, "jar" );
+
+ artifactDAOControl.replay();
+
+ dbCleanupRemoveArtifactConsumer.processArchivaArtifact( artifact );
+
+ artifactDAOControl.verify();
+ }
+
+ public void testIfArtifactWasDeleted()
+ throws Exception
+ {
+ ArchivaArtifact artifact = createArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "jar" );
+
+ artifactDAOMock.deleteArtifact( artifact );
+
+ artifactDAOControl.replay();
+
+ dbCleanupRemoveArtifactConsumer.processArchivaArtifact( artifact );
+
+ artifactDAOControl.verify();
+ }
+
+}
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java
new file mode 100644
index 000000000..646d3b0c8
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.java
@@ -0,0 +1,110 @@
+package org.apache.maven.archiva.consumers.database;
+
+/*
+ * 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.easymock.MockControl;
+import org.apache.maven.archiva.database.ProjectModelDAO;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
+
+/**
+ * Test for DatabaseCleanupRemoveProjectConsumer
+ *
+ * @author Maria Odea Ching
+ */
+public class DatabaseCleanupRemoveProjectConsumerTest
+ extends AbstractDatabaseCleanupTest
+{
+ private MockControl projectModelDAOControl;
+
+ private ProjectModelDAO projectModelDAOMock;
+
+ private DatabaseCleanupRemoveProjectConsumer dbCleanupRemoveProjectConsumer;
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ dbCleanupRemoveProjectConsumer = new DatabaseCleanupRemoveProjectConsumer();
+
+ projectModelDAOControl = MockControl.createControl( ProjectModelDAO.class );
+
+ projectModelDAOMock = (ProjectModelDAO) projectModelDAOControl.getMock();
+
+ dbCleanupRemoveProjectConsumer.setProjectModelDAO( projectModelDAOMock );
+
+ dbCleanupRemoveProjectConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
+
+ dbCleanupRemoveProjectConsumer.setRepositoryFactory( repositoryFactory );
+ }
+
+ public void testIfArtifactWasNotDeleted()
+ throws Exception
+ {
+ ArchivaArtifact artifact = createArtifact( TEST_GROUP_ID, "do-not-cleanup-artifact-test", TEST_VERSION, "pom" );
+
+ projectModelDAOControl.replay();
+
+ dbCleanupRemoveProjectConsumer.processArchivaArtifact( artifact );
+
+ projectModelDAOControl.verify();
+ }
+
+ public void testIfArtifactWasDeleted()
+ throws Exception
+ {
+ ArchivaArtifact artifact = createArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "pom" );
+
+ ArchivaProjectModel projectModel = createProjectModel( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION );
+
+ //this should return a value
+ projectModelDAOControl.expectAndReturn(
+ projectModelDAOMock.getProjectModel( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ),
+ (ArchivaProjectModel) projectModel );
+
+ projectModelDAOMock.deleteProjectModel( projectModel );
+
+ projectModelDAOControl.replay();
+
+ dbCleanupRemoveProjectConsumer.processArchivaArtifact( artifact );
+
+ projectModelDAOControl.verify();
+ }
+
+ public void testIfArtifactWasNotAPom()
+ throws Exception
+ {
+ ArchivaArtifact artifact = createArtifact( TEST_GROUP_ID, "do-not-cleanup-artifact-test", TEST_VERSION, "jar" );
+
+ projectModelDAOControl.replay();
+
+ dbCleanupRemoveProjectConsumer.processArchivaArtifact( artifact );
+
+ projectModelDAOControl.verify();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+}
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml
new file mode 100644
index 000000000..1a2bc2093
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveArtifactConsumerTest.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+ org.apache.maven.archiva.consumers.DatabaseCleanupConsumer
+ not-present-remove-db-artifact
+ org.apache.maven.archiva.consumers.database.DatabaseCleanupRemoveArtifactConsumer
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory
+
+
+ org.apache.maven.archiva.database.ArtifactDAO
+ jdo
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ database-cleanup
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ database-cleanup
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout
+ layouts
+
+
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout
+ default
+ org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout
+
+
+
+ org.apache.maven.archiva.repository.RepositoryContentFactory
+ org.apache.maven.archiva.repository.RepositoryContentFactory
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+
+
+
+
+
\ No newline at end of file
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml
new file mode 100644
index 000000000..ded662447
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/DatabaseCleanupRemoveProjectConsumerTest.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+ org.apache.maven.archiva.configuration.DefaultArchivaConfiguration
+
+
+ org.codehaus.plexus.registry.Registry
+ database-cleanup
+
+
+
+
+ org.codehaus.plexus.registry.Registry
+ database-cleanup
+ org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry
+
+
+
+
+
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout
+ layouts
+
+
+
+
+ org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout
+ default
+ org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout
+
+
+
+ org.apache.maven.archiva.repository.RepositoryContentFactory
+ org.apache.maven.archiva.repository.RepositoryContentFactory
+
+
+ org.apache.maven.archiva.configuration.ArchivaConfiguration
+ database-cleanup
+
+
+
+
+
\ No newline at end of file
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.jar b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.jar
new file mode 100644
index 000000000..4201a06cb
Binary files /dev/null and b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.jar differ
diff --git a/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.pom b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.pom
new file mode 100644
index 000000000..94b5b2e98
--- /dev/null
+++ b/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/test-repo/org/apache/maven/archiva/do-not-cleanup-artifact-test/1.0/do-not-cleanup-artifact-test-1.0.pom
@@ -0,0 +1,5 @@
+
+ org.apache.maven.archiva
+ do-not-cleanup-artifact-test
+ 1.0
+
\ No newline at end of file
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java
index 4d5884968..01dee02fd 100644
--- a/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java
@@ -95,7 +95,7 @@ public class DatabaseConsumers
DatabaseCleanupConsumer consumer = (DatabaseCleanupConsumer) object;
DatabaseScanningConfiguration config = archivaConfiguration.getConfiguration().getDatabaseScanning();
- return config.getUnprocessedConsumers().contains( consumer.getId() );
+ return config.getCleanupConsumers().contains( consumer.getId() );
}
return satisfies;
diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java
index b30f9cef4..0062a8945 100644
--- a/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java
+++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseCleanupConsumer.java
@@ -70,12 +70,12 @@ public class TestDatabaseCleanupConsumer
public String getDescription()
{
- return "Test Consumer for Database Unprocessed";
+ return "Test Consumer for Database Cleanup";
}
public String getId()
{
- return "test-db-unprocessed";
+ return "test-db-cleanup";
}
public boolean isPermanent()
diff --git a/archiva-database/src/test/resources/archiva-test.xml b/archiva-database/src/test/resources/archiva-test.xml
index 66021220b..838e6fc67 100644
--- a/archiva-database/src/test/resources/archiva-test.xml
+++ b/archiva-database/src/test/resources/archiva-test.xml
@@ -146,9 +146,6 @@
test-db-cleanup
- not-present-remove-db-artifact
- not-present-remove-db-project
- not-present-remove-indexed
diff --git a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java
index c15edb187..ff6979877 100644
--- a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java
+++ b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java
@@ -70,12 +70,12 @@ public class TestDatabaseCleanupConsumer
public String getDescription()
{
- return "Test Consumer for Database Unprocessed";
+ return "Test Consumer for Database Cleanup";
}
public String getId()
{
- return "test-db-unprocessed";
+ return "test-db-cleanup";
}
public boolean isPermanent()
diff --git a/archiva-scheduled/src/test/resources/archiva-test.xml b/archiva-scheduled/src/test/resources/archiva-test.xml
index 32b43b1bf..3f2310c7b 100644
--- a/archiva-scheduled/src/test/resources/archiva-test.xml
+++ b/archiva-scheduled/src/test/resources/archiva-test.xml
@@ -113,9 +113,6 @@
test-db-cleanup
- not-present-remove-db-artifact
- not-present-remove-db-project
- not-present-remove-indexed