mirror of https://github.com/apache/archiva.git
removed usage of BidirectionalRepositoryLayout in database cleanup consumers, made use of the ManagedRepositoryContent instead
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585068 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc7e954a49
commit
657b328e5d
|
@ -28,9 +28,6 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
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.layout.BidirectionalRepositoryLayout;
|
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
|
||||||
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -64,11 +61,6 @@ public class DatabaseCleanupRemoveArtifactConsumer
|
||||||
* @plexus.requirement role-hint="jdo"
|
* @plexus.requirement role-hint="jdo"
|
||||||
*/
|
*/
|
||||||
private ArtifactDAO artifactDAO;
|
private ArtifactDAO artifactDAO;
|
||||||
|
|
||||||
/**
|
|
||||||
* @plexus.requirement
|
|
||||||
*/
|
|
||||||
private BidirectionalRepositoryLayoutFactory layoutFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
|
@ -98,9 +90,9 @@ public class DatabaseCleanupRemoveArtifactConsumer
|
||||||
{
|
{
|
||||||
ManagedRepositoryContent repositoryContent =
|
ManagedRepositoryContent repositoryContent =
|
||||||
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
|
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
|
||||||
|
|
||||||
File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) );
|
File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) );
|
||||||
|
|
||||||
if( !file.exists() )
|
if( !file.exists() )
|
||||||
{
|
{
|
||||||
artifactDAO.deleteArtifact( artifact );
|
artifactDAO.deleteArtifact( artifact );
|
||||||
|
@ -136,30 +128,9 @@ public class DatabaseCleanupRemoveArtifactConsumer
|
||||||
{
|
{
|
||||||
this.artifactDAO = artifactDAO;
|
this.artifactDAO = artifactDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory )
|
|
||||||
{
|
|
||||||
this.layoutFactory = layoutFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
|
public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
|
||||||
{
|
{
|
||||||
this.repositoryFactory = 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,10 @@ import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
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.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.ProjectModelDAO;
|
||||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,11 +64,6 @@ public class DatabaseCleanupRemoveProjectConsumer
|
||||||
* @plexus.requirement role-hint="jdo"
|
* @plexus.requirement role-hint="jdo"
|
||||||
*/
|
*/
|
||||||
private ProjectModelDAO projectModelDAO;
|
private ProjectModelDAO projectModelDAO;
|
||||||
|
|
||||||
/**
|
|
||||||
* @plexus.requirement
|
|
||||||
*/
|
|
||||||
private BidirectionalRepositoryLayoutFactory layoutFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
|
@ -108,8 +99,8 @@ public class DatabaseCleanupRemoveProjectConsumer
|
||||||
ManagedRepositoryContent repositoryContent =
|
ManagedRepositoryContent repositoryContent =
|
||||||
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
|
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
|
||||||
|
|
||||||
File file = new File( repositoryContent.getRepoRoot(), toPath( artifact ) );
|
File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) );
|
||||||
|
|
||||||
if( !file.exists() )
|
if( !file.exists() )
|
||||||
{
|
{
|
||||||
ArchivaProjectModel projectModel = projectModelDAO.getProjectModel(
|
ArchivaProjectModel projectModel = projectModelDAO.getProjectModel(
|
||||||
|
@ -144,31 +135,11 @@ public class DatabaseCleanupRemoveProjectConsumer
|
||||||
{
|
{
|
||||||
return false;
|
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 )
|
public void setProjectModelDAO( ProjectModelDAO projectModelDAO )
|
||||||
{
|
{
|
||||||
this.projectModelDAO = projectModelDAO;
|
this.projectModelDAO = projectModelDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBidirectionalRepositoryLayoutFactory( BidirectionalRepositoryLayoutFactory layoutFactory )
|
|
||||||
{
|
|
||||||
this.layoutFactory = layoutFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
|
public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,6 @@ 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.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
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.ArchivaArtifact;
|
||||||
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
||||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||||
|
@ -39,8 +38,6 @@ public class AbstractDatabaseCleanupTest
|
||||||
extends PlexusTestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
ArchivaConfiguration archivaConfig;
|
ArchivaConfiguration archivaConfig;
|
||||||
|
|
||||||
BidirectionalRepositoryLayoutFactory layoutFactory;
|
|
||||||
|
|
||||||
RepositoryContentFactory repositoryFactory;
|
RepositoryContentFactory repositoryFactory;
|
||||||
|
|
||||||
|
@ -73,9 +70,6 @@ public class AbstractDatabaseCleanupTest
|
||||||
repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
|
repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
|
||||||
|
|
||||||
archivaConfig.save( configuration );
|
archivaConfig.save( configuration );
|
||||||
|
|
||||||
// set bidirectional repository layout factory
|
|
||||||
layoutFactory = (BidirectionalRepositoryLayoutFactory) lookup( BidirectionalRepositoryLayoutFactory.class );
|
|
||||||
|
|
||||||
repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
|
repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,6 @@ public class DatabaseCleanupRemoveArtifactConsumerTest
|
||||||
|
|
||||||
dbCleanupRemoveArtifactConsumer.setArtifactDAO( artifactDAOMock );
|
dbCleanupRemoveArtifactConsumer.setArtifactDAO( artifactDAOMock );
|
||||||
|
|
||||||
dbCleanupRemoveArtifactConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
|
|
||||||
|
|
||||||
dbCleanupRemoveArtifactConsumer.setRepositoryFactory( repositoryFactory );
|
dbCleanupRemoveArtifactConsumer.setRepositoryFactory( repositoryFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,6 @@ public class DatabaseCleanupRemoveProjectConsumerTest
|
||||||
|
|
||||||
dbCleanupRemoveProjectConsumer.setProjectModelDAO( projectModelDAOMock );
|
dbCleanupRemoveProjectConsumer.setProjectModelDAO( projectModelDAOMock );
|
||||||
|
|
||||||
dbCleanupRemoveProjectConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
|
|
||||||
|
|
||||||
dbCleanupRemoveProjectConsumer.setRepositoryFactory( repositoryFactory );
|
dbCleanupRemoveProjectConsumer.setRepositoryFactory( repositoryFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,24 +20,6 @@
|
||||||
|
|
||||||
<component-set>
|
<component-set>
|
||||||
<components>
|
<components>
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.archiva.consumers.DatabaseCleanupConsumer</role>
|
|
||||||
<role-hint>not-present-remove-db-artifact</role-hint>
|
|
||||||
<implementation>org.apache.maven.archiva.consumers.database.DatabaseCleanupRemoveArtifactConsumer</implementation>
|
|
||||||
<requirements>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
|
||||||
<role-hint>database-cleanup</role-hint>
|
|
||||||
</requirement>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</role>
|
|
||||||
</requirement>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.database.ArtifactDAO</role>
|
|
||||||
<role-hint>jdo</role-hint>
|
|
||||||
</requirement>
|
|
||||||
</requirements>
|
|
||||||
</component>
|
|
||||||
<component>
|
<component>
|
||||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
||||||
<role-hint>database-cleanup</role-hint>
|
<role-hint>database-cleanup</role-hint>
|
||||||
|
@ -60,25 +42,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</role>
|
|
||||||
<implementation>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</implementation>
|
|
||||||
<requirements>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
|
||||||
<role-hint>database-cleanup</role-hint>
|
|
||||||
</requirement>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout</role>
|
|
||||||
<field-name>layouts</field-name>
|
|
||||||
</requirement>
|
|
||||||
</requirements>
|
|
||||||
</component>
|
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout</role>
|
|
||||||
<role-hint>default</role-hint>
|
|
||||||
<implementation>org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout</implementation>
|
|
||||||
</component>
|
|
||||||
|
|
||||||
<component>
|
<component>
|
||||||
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
|
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
|
||||||
|
|
|
@ -42,25 +42,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</role>
|
|
||||||
<implementation>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory</implementation>
|
|
||||||
<requirements>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
|
||||||
<role-hint>database-cleanup</role-hint>
|
|
||||||
</requirement>
|
|
||||||
<requirement>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout</role>
|
|
||||||
<field-name>layouts</field-name>
|
|
||||||
</requirement>
|
|
||||||
</requirements>
|
|
||||||
</component>
|
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout</role>
|
|
||||||
<role-hint>default</role-hint>
|
|
||||||
<implementation>org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout</implementation>
|
|
||||||
</component>
|
|
||||||
|
|
||||||
<component>
|
<component>
|
||||||
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
|
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
|
||||||
|
|
Loading…
Reference in New Issue