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;
* @plexus.requirement role-hint="jdo"
*/
private ArtifactDAO artifactDAO;
-
- /**
- * @plexus.requirement
- */
- private BidirectionalRepositoryLayoutFactory layoutFactory;
/**
* @plexus.requirement
{
ManagedRepositoryContent repositoryContent =
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() )
{
artifactDAO.deleteArtifact( artifact );
{
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;
- }
- }
-
+ }
}
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;
/**
* @plexus.requirement role-hint="jdo"
*/
private ProjectModelDAO projectModelDAO;
-
- /**
- * @plexus.requirement
- */
- private BidirectionalRepositoryLayoutFactory layoutFactory;
/**
* @plexus.requirement
ManagedRepositoryContent repositoryContent =
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() )
{
ArchivaProjectModel projectModel = projectModelDAO.getProjectModel(
{
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 )
{
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;
extends PlexusTestCase
{
ArchivaConfiguration archivaConfig;
-
- BidirectionalRepositoryLayoutFactory layoutFactory;
RepositoryContentFactory repositoryFactory;
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 );
}
dbCleanupRemoveArtifactConsumer.setArtifactDAO( artifactDAOMock );
- dbCleanupRemoveArtifactConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
-
dbCleanupRemoveArtifactConsumer.setRepositoryFactory( repositoryFactory );
}
dbCleanupRemoveProjectConsumer.setProjectModelDAO( projectModelDAOMock );
- dbCleanupRemoveProjectConsumer.setBidirectionalRepositoryLayoutFactory( layoutFactory );
-
dbCleanupRemoveProjectConsumer.setRepositoryFactory( repositoryFactory );
}
<component-set>
<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>
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
<role-hint>database-cleanup</role-hint>
</properties>
</configuration>
</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>
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
</properties>
</configuration>
</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>
<role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>