mirror of https://github.com/apache/archiva.git
[MRM-1027] Indices are not cleaned up when deleting artifact via web services
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@722439 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5b04d5d6f7
commit
c035dcf3ae
|
@ -174,6 +174,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
|
||||||
versionRef.setVersion( version );
|
versionRef.setVersion( version );
|
||||||
repository.deleteVersion( versionRef );
|
repository.deleteVersion( versionRef );
|
||||||
|
|
||||||
|
// TODO: looks incomplete, might not delete related artifacts?
|
||||||
for ( RepositoryListener listener : listeners )
|
for ( RepositoryListener listener : listeners )
|
||||||
{
|
{
|
||||||
listener.deleteArtifact( repository, artifact );
|
listener.deleteArtifact( repository, artifact );
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.apache.maven.archiva.repository.events;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.util.List;
|
||||||
|
|
||||||
|
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo though we will eventually remove this altogether, an interim cleanup would be to genericise this
|
||||||
|
* and replace the calls in RepositoryContentConsumers with calls to the same thing
|
||||||
|
*/
|
||||||
|
public class RepositoryListenerFactoryBean
|
||||||
|
implements FactoryBean, ApplicationContextAware
|
||||||
|
{
|
||||||
|
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public void setApplicationContext( ApplicationContext applicationContext )
|
||||||
|
throws BeansException
|
||||||
|
{
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getObject()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
return applicationContext.getBeansOfType( RepositoryListener.class ).values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class getObjectType()
|
||||||
|
{
|
||||||
|
return List.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingleton()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -57,9 +57,10 @@
|
||||||
<constructor-arg ref="databaseConsumers"/>
|
<constructor-arg ref="databaseConsumers"/>
|
||||||
<constructor-arg ref="repositoryContentFactory"/>
|
<constructor-arg ref="repositoryContentFactory"/>
|
||||||
<constructor-arg ref="artifactDAO#jdo"/>
|
<constructor-arg ref="artifactDAO#jdo"/>
|
||||||
<constructor-arg ref="databaseCleanupConsumer#not-present-remove-db-artifact"/>
|
<constructor-arg ref="archivaTaskScheduler"/>
|
||||||
<constructor-arg ref="databaseCleanupConsumer#not-present-remove-db-project"/>
|
<constructor-arg>
|
||||||
<constructor-arg ref="archivaTaskScheduler"/>
|
<bean class="org.apache.maven.archiva.repository.events.RepositoryListenerFactoryBean" />
|
||||||
|
</constructor-arg>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="xmlrpcServicesList" lazy-init="true" scope="singleton" class="java.util.ArrayList">
|
<bean name="xmlrpcServicesList" lazy-init="true" scope="singleton" class="java.util.ArrayList">
|
||||||
|
|
|
@ -45,12 +45,12 @@
|
||||||
<mainClass>org.apache.archiva.web.xmlrpc.client.SampleClient</mainClass>
|
<mainClass>org.apache.archiva.web.xmlrpc.client.SampleClient</mainClass>
|
||||||
<arguments>
|
<arguments>
|
||||||
<!--
|
<!--
|
||||||
URL: ex. http://127.0.0.1:8080/archiva/xmlrpc
|
URL: ex. http://127.0.0.1:9091/xmlrpc
|
||||||
USERNAME & PASSWORD: Archiva credentials
|
USERNAME & PASSWORD: Archiva credentials
|
||||||
-->
|
-->
|
||||||
<argument>http://127.0.0.1:8080/archiva/xmlrpc</argument>
|
<argument>http://127.0.0.1:9091/xmlrpc</argument>
|
||||||
<argument>username</argument>
|
<argument>admin</argument>
|
||||||
<argument>password</argument>
|
<argument>${password}</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.web.xmlrpc.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
||||||
|
@ -33,7 +34,6 @@ import org.apache.maven.archiva.configuration.IndeterminateConfigurationExceptio
|
||||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
||||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
|
||||||
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
|
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
|
||||||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
|
||||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
|
@ -49,6 +49,7 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
import org.apache.maven.archiva.repository.RepositoryException;
|
import org.apache.maven.archiva.repository.RepositoryException;
|
||||||
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
||||||
|
import org.apache.maven.archiva.repository.events.RepositoryListener;
|
||||||
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
|
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
|
||||||
import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
|
import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler;
|
||||||
import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
|
import org.apache.maven.archiva.scheduled.tasks.ArchivaTask;
|
||||||
|
@ -74,25 +75,22 @@ public class AdministrationServiceImpl
|
||||||
|
|
||||||
private ArtifactDAO artifactDAO;
|
private ArtifactDAO artifactDAO;
|
||||||
|
|
||||||
private DatabaseCleanupConsumer cleanupArtifacts;
|
|
||||||
|
|
||||||
private DatabaseCleanupConsumer cleanupProjects;
|
|
||||||
|
|
||||||
private ArchivaTaskScheduler taskScheduler;
|
private ArchivaTaskScheduler taskScheduler;
|
||||||
|
|
||||||
|
private Collection<RepositoryListener> listeners;
|
||||||
|
|
||||||
public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil,
|
public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil,
|
||||||
DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory,
|
DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory,
|
||||||
ArtifactDAO artifactDAO, DatabaseCleanupConsumer cleanupArtifacts,
|
ArtifactDAO artifactDAO, ArchivaTaskScheduler taskScheduler,
|
||||||
DatabaseCleanupConsumer cleanupProjects, ArchivaTaskScheduler taskScheduler )
|
Collection<RepositoryListener> listeners )
|
||||||
{
|
{
|
||||||
this.archivaConfiguration = archivaConfig;
|
this.archivaConfiguration = archivaConfig;
|
||||||
this.repoConsumersUtil = repoConsumersUtil;
|
this.repoConsumersUtil = repoConsumersUtil;
|
||||||
this.dbConsumersUtil = dbConsumersUtil;
|
this.dbConsumersUtil = dbConsumersUtil;
|
||||||
this.repoFactory = repoFactory;
|
this.repoFactory = repoFactory;
|
||||||
this.artifactDAO = artifactDAO;
|
this.artifactDAO = artifactDAO;
|
||||||
this.cleanupArtifacts = cleanupArtifacts;
|
|
||||||
this.cleanupProjects = cleanupProjects;
|
|
||||||
this.taskScheduler = taskScheduler;
|
this.taskScheduler = taskScheduler;
|
||||||
|
this.listeners = listeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,7 +228,7 @@ public class AdministrationServiceImpl
|
||||||
ref.setGroupId( groupId );
|
ref.setGroupId( groupId );
|
||||||
ref.setArtifactId( artifactId );
|
ref.setArtifactId( artifactId );
|
||||||
ref.setVersion( version );
|
ref.setVersion( version );
|
||||||
|
|
||||||
// delete from file system
|
// delete from file system
|
||||||
repoContent.deleteVersion( ref );
|
repoContent.deleteVersion( ref );
|
||||||
|
|
||||||
|
@ -240,31 +238,23 @@ public class AdministrationServiceImpl
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifacts = artifactDAO.queryArtifacts( constraint );
|
artifacts = artifactDAO.queryArtifacts( constraint );
|
||||||
if( artifacts == null )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch ( ArchivaDatabaseException e )
|
catch ( ArchivaDatabaseException e )
|
||||||
{
|
{
|
||||||
throw new Exception( "Error occurred while cleaning up database." );
|
throw new Exception( "Error occurred while cleaning up database." );
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup db manually? or use the cleanup consumers as what is done now?
|
if ( artifacts != null )
|
||||||
for( ArchivaArtifact artifact : artifacts )
|
|
||||||
{
|
{
|
||||||
if( artifact.getVersion().equals( version ) )
|
for ( ArchivaArtifact artifact : artifacts )
|
||||||
{
|
{
|
||||||
try
|
if ( artifact.getVersion().equals( version ) )
|
||||||
{
|
{
|
||||||
cleanupArtifacts.processArchivaArtifact( artifact );
|
for ( RepositoryListener listener : listeners )
|
||||||
cleanupProjects.processArchivaArtifact( artifact );
|
{
|
||||||
|
listener.deleteArtifact( repoContent, artifact );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( ConsumerException ce )
|
|
||||||
{
|
|
||||||
// log error
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,5 +426,5 @@ public class AdministrationServiceImpl
|
||||||
{
|
{
|
||||||
throw new Exception( "Error occurred while saving the configuration." );
|
throw new Exception( "Error occurred while saving the configuration." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,16 @@ package org.apache.archiva.web.xmlrpc.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
|
||||||
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
||||||
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.filefilter.FileFilterUtils;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration;
|
import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration;
|
||||||
|
@ -46,6 +50,7 @@ import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.content.PathParser;
|
import org.apache.maven.archiva.repository.content.PathParser;
|
||||||
|
import org.apache.maven.archiva.repository.events.RepositoryListener;
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||||
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
|
import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
|
||||||
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
|
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
|
||||||
|
@ -100,16 +105,10 @@ public class AdministrationServiceImplTest
|
||||||
|
|
||||||
private MockControl unprocessedConsumersControl;
|
private MockControl unprocessedConsumersControl;
|
||||||
|
|
||||||
private MockControl cleanupConsumersControl;
|
|
||||||
|
|
||||||
private DatabaseUnprocessedArtifactConsumer processArtifactConsumer;
|
private DatabaseUnprocessedArtifactConsumer processArtifactConsumer;
|
||||||
|
|
||||||
private DatabaseUnprocessedArtifactConsumer processPomConsumer;
|
private DatabaseUnprocessedArtifactConsumer processPomConsumer;
|
||||||
|
|
||||||
private DatabaseCleanupConsumer cleanupIndexConsumer;
|
|
||||||
|
|
||||||
private DatabaseCleanupConsumer cleanupDbConsumer;
|
|
||||||
|
|
||||||
// delete artifact
|
// delete artifact
|
||||||
private MockControl repoFactoryControl;
|
private MockControl repoFactoryControl;
|
||||||
|
|
||||||
|
@ -119,9 +118,15 @@ public class AdministrationServiceImplTest
|
||||||
|
|
||||||
private ArtifactDAO artifactDao;
|
private ArtifactDAO artifactDao;
|
||||||
|
|
||||||
private MockControl cleanupControl;
|
private MockControl listenerControl;
|
||||||
|
|
||||||
private DatabaseCleanupConsumer cleanupConsumer;
|
private RepositoryListener listener;
|
||||||
|
|
||||||
|
private DatabaseCleanupConsumer cleanupIndexConsumer;
|
||||||
|
|
||||||
|
private DatabaseCleanupConsumer cleanupDbConsumer;
|
||||||
|
|
||||||
|
private MockControl cleanupConsumersControl;
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -154,9 +159,9 @@ public class AdministrationServiceImplTest
|
||||||
dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock();
|
dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock();
|
||||||
|
|
||||||
cleanupConsumersControl = MockControl.createControl( DatabaseCleanupConsumer.class );
|
cleanupConsumersControl = MockControl.createControl( DatabaseCleanupConsumer.class );
|
||||||
cleanupIndexConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock();
|
cleanupIndexConsumer = (DatabaseCleanupConsumer) cleanupConsumersControl.getMock();
|
||||||
cleanupDbConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock();
|
cleanupDbConsumer = (DatabaseCleanupConsumer) cleanupConsumersControl.getMock();
|
||||||
|
|
||||||
unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class );
|
unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class );
|
||||||
processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
|
processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
|
||||||
processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
|
processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
|
||||||
|
@ -168,11 +173,12 @@ public class AdministrationServiceImplTest
|
||||||
artifactDaoControl = MockControl.createControl( ArtifactDAO.class );
|
artifactDaoControl = MockControl.createControl( ArtifactDAO.class );
|
||||||
artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock();
|
artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock();
|
||||||
|
|
||||||
cleanupControl = MockClassControl.createControl( DatabaseCleanupConsumer.class );
|
listenerControl = MockControl.createControl( RepositoryListener.class );
|
||||||
cleanupConsumer = ( DatabaseCleanupConsumer ) cleanupControl.getMock();
|
listener = (RepositoryListener) listenerControl.getMock();
|
||||||
|
|
||||||
service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil,
|
service =
|
||||||
repositoryFactory, artifactDao, cleanupConsumer, cleanupConsumer, taskScheduler );
|
new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, repositoryFactory,
|
||||||
|
artifactDao, taskScheduler, Collections.singletonList( listener ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests for database consumers */
|
/* Tests for database consumers */
|
||||||
|
@ -210,7 +216,7 @@ public class AdministrationServiceImplTest
|
||||||
|
|
||||||
recordDbConsumers();
|
recordDbConsumers();
|
||||||
|
|
||||||
// test enable "process-pom" db consumer
|
// test enable "process-pom" db consumer
|
||||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
||||||
configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );
|
configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );
|
||||||
|
|
||||||
|
@ -243,7 +249,7 @@ public class AdministrationServiceImplTest
|
||||||
archivaConfigControl.verify();
|
archivaConfigControl.verify();
|
||||||
configControl.verify();
|
configControl.verify();
|
||||||
|
|
||||||
// test disable "process-pom" db consumer
|
// test disable "process-pom" db consumer
|
||||||
dbConsumersUtilControl.reset();
|
dbConsumersUtilControl.reset();
|
||||||
cleanupConsumersControl.reset();
|
cleanupConsumersControl.reset();
|
||||||
unprocessedConsumersControl.reset();
|
unprocessedConsumersControl.reset();
|
||||||
|
@ -454,11 +460,7 @@ public class AdministrationServiceImplTest
|
||||||
public void testDeleteM2ArtifactArtifactExists()
|
public void testDeleteM2ArtifactArtifactExists()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
File file = new File( getBasedir(), "/target/test-classes/default-repo/" );
|
ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo");
|
||||||
assertTrue( file.exists() );
|
|
||||||
|
|
||||||
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false );
|
|
||||||
managedRepo.setLocation( file.getAbsolutePath() );
|
|
||||||
|
|
||||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
||||||
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
||||||
|
@ -474,33 +476,26 @@ public class AdministrationServiceImplTest
|
||||||
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||||
artifactDaoControl.setReturnValue( artifacts );
|
artifactDaoControl.setReturnValue( artifacts );
|
||||||
|
|
||||||
cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) );
|
listener.deleteArtifact( repoContent, artifacts.get( 0 ) );
|
||||||
cleanupControl.setVoidCallable( 2 );
|
listenerControl.setVoidCallable( 1 );
|
||||||
|
|
||||||
archivaConfigControl.replay();
|
archivaConfigControl.replay();
|
||||||
configControl.replay();
|
configControl.replay();
|
||||||
repoFactoryControl.replay();
|
repoFactoryControl.replay();
|
||||||
artifactDaoControl.replay();
|
artifactDaoControl.replay();
|
||||||
cleanupControl.replay();
|
listenerControl.replay();
|
||||||
|
|
||||||
try
|
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
|
||||||
{
|
assertTrue( success );
|
||||||
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
|
|
||||||
assertTrue( success );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
fail( "An exception should not have been thrown." );
|
|
||||||
}
|
|
||||||
|
|
||||||
archivaConfigControl.verify();
|
archivaConfigControl.verify();
|
||||||
configControl.verify();
|
configControl.verify();
|
||||||
repoFactoryControl.verify();
|
repoFactoryControl.verify();
|
||||||
artifactDaoControl.verify();
|
artifactDaoControl.verify();
|
||||||
cleanupControl.verify();
|
listenerControl.verify();
|
||||||
|
|
||||||
assertFalse( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.0" ).exists() );
|
assertFalse( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.0" ).exists() );
|
||||||
assertTrue( new File( getBasedir(), "/target/test-classes/default-repo/org/apache/archiva/archiva-test/1.1" ).exists() );
|
assertTrue( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.1" ).exists() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteM1ArtifactArtifactExists()
|
public void testDeleteM1ArtifactArtifactExists()
|
||||||
|
@ -512,11 +507,7 @@ public class AdministrationServiceImplTest
|
||||||
MockControl pathParserControl = MockClassControl.createControl( PathParser.class );
|
MockControl pathParserControl = MockClassControl.createControl( PathParser.class );
|
||||||
PathParser parser = ( PathParser ) pathParserControl.getMock();
|
PathParser parser = ( PathParser ) pathParserControl.getMock();
|
||||||
|
|
||||||
File file = new File( getBasedir(), "/target/test-classes/legacy-repo/" );
|
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" );
|
||||||
assertTrue( file.exists() );
|
|
||||||
|
|
||||||
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "legacy", "Internal Repository", true, false );
|
|
||||||
managedRepo.setLocation( file.getAbsolutePath() );
|
|
||||||
|
|
||||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
||||||
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
||||||
|
@ -536,52 +527,42 @@ public class AdministrationServiceImplTest
|
||||||
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||||
artifactDaoControl.setReturnValue( artifacts );
|
artifactDaoControl.setReturnValue( artifacts );
|
||||||
|
|
||||||
cleanupConsumer.processArchivaArtifact( artifacts.get( 0 ) );
|
listener.deleteArtifact( repoContent, artifacts.get( 0 ) );
|
||||||
cleanupControl.setVoidCallable( 2 );
|
listenerControl.setVoidCallable( 1 );
|
||||||
|
|
||||||
archivaConfigControl.replay();
|
archivaConfigControl.replay();
|
||||||
configControl.replay();
|
configControl.replay();
|
||||||
repoFactoryControl.replay();
|
repoFactoryControl.replay();
|
||||||
artifactDaoControl.replay();
|
artifactDaoControl.replay();
|
||||||
cleanupControl.replay();
|
listenerControl.replay();
|
||||||
fileTypesControl.replay();
|
fileTypesControl.replay();
|
||||||
pathParserControl.replay();
|
pathParserControl.replay();
|
||||||
|
|
||||||
try
|
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
|
||||||
{
|
assertTrue( success );
|
||||||
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
|
|
||||||
assertTrue( success );
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
fail( "An exception should not have been thrown." );
|
|
||||||
}
|
|
||||||
|
|
||||||
archivaConfigControl.verify();
|
archivaConfigControl.verify();
|
||||||
configControl.verify();
|
configControl.verify();
|
||||||
repoFactoryControl.verify();
|
repoFactoryControl.verify();
|
||||||
artifactDaoControl.verify();
|
artifactDaoControl.verify();
|
||||||
cleanupControl.verify();
|
listenerControl.verify();
|
||||||
fileTypesControl.verify();
|
fileTypesControl.verify();
|
||||||
pathParserControl.verify();
|
pathParserControl.verify();
|
||||||
|
|
||||||
assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() );
|
File repo = new File( managedRepo.getLocation() );
|
||||||
assertFalse( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() );
|
assertFalse( new File( repo, "org.apache.archiva/jars/archiva-test-1.0.jar" ).exists() );
|
||||||
|
assertFalse( new File( repo, "org.apache.archiva/poms/archiva-test-1.0.pom" ).exists() );
|
||||||
|
|
||||||
assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() );
|
assertTrue( new File( repo, "org.apache.archiva/jars/archiva-test-1.1.jar" ).exists() );
|
||||||
assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() );
|
assertTrue( new File( repo, "org.apache.archiva/jars/archiva-diff-1.0.jar" ).exists() );
|
||||||
assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() );
|
assertTrue( new File( repo, "org.apache.archiva/poms/archiva-test-1.1.pom" ).exists() );
|
||||||
assertTrue( new File( getBasedir(), "/target/test-classes/legacy-repo/org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() );
|
assertTrue( new File( repo, "org.apache.archiva/poms/archiva-diff-1.0.pom" ).exists() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteArtifactArtifactDoesNotExist()
|
public void testDeleteArtifactArtifactDoesNotExist()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
File file = new File( getBasedir(), "/target/test-classes/default-repo/" );
|
ManagedRepositoryConfiguration managedRepo = createManagedRepo("default", "default-repo");
|
||||||
assertTrue( file.exists() );
|
|
||||||
|
|
||||||
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", "default", "Internal Repository", true, false );
|
|
||||||
managedRepo.setLocation( file.getAbsolutePath() );
|
|
||||||
|
|
||||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
|
||||||
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo );
|
||||||
|
@ -609,6 +590,23 @@ public class AdministrationServiceImplTest
|
||||||
configControl.verify();
|
configControl.verify();
|
||||||
repoFactoryControl.verify();
|
repoFactoryControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ManagedRepositoryConfiguration createManagedRepo(String layout, String directory)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
File srcDir = new File( getBasedir(), "src/test/repositories/"+ directory );
|
||||||
|
|
||||||
|
File repoDir = getTestFile( "target/test-repos/" + directory );
|
||||||
|
|
||||||
|
FileUtils.deleteDirectory( repoDir );
|
||||||
|
|
||||||
|
FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) );
|
||||||
|
|
||||||
|
ManagedRepositoryConfiguration managedRepo =
|
||||||
|
createManagedRepo( "internal", layout, "Internal Repository", true, false );
|
||||||
|
managedRepo.setLocation( repoDir.getAbsolutePath() );
|
||||||
|
return managedRepo;
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeleteArtifacRepositoryDoesNotExist()
|
public void testDeleteArtifacRepositoryDoesNotExist()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
Loading…
Reference in New Issue