aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-scheduled
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-10-08 22:07:39 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-10-08 22:07:39 +0000
commit8af86cd884b34ecfa98c6a42d2975fdd45c48fff (patch)
tree3747df8c304e8c84090f325abab84775e961db6e /archiva-scheduled
parent4b9cf4b9298b9906ae4975146706e6a870349e43 (diff)
downloadarchiva-8af86cd884b34ecfa98c6a42d2975fdd45c48fff.tar.gz
archiva-8af86cd884b34ecfa98c6a42d2975fdd45c48fff.zip
Finishing the Repository split work that brett started.
ArchivaRepository has been removed from model. This work was needed before repository layout/detection proposal work is started. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@582987 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-scheduled')
-rw-r--r--archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java32
-rw-r--r--archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java29
-rw-r--r--archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java36
-rw-r--r--archiva-scheduled/src/test/resources/archiva-test.xml10
-rw-r--r--archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml5
5 files changed, 53 insertions, 59 deletions
diff --git a/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java b/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
index e435afddb..885c9d530 100644
--- a/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
+++ b/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
@@ -21,13 +21,13 @@ package org.apache.maven.archiva.scheduled.executors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.RepositoryDAO;
import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
-import org.apache.maven.archiva.model.ArchivaRepository;
import org.apache.maven.archiva.model.RepositoryContentStatistics;
import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics;
import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -57,11 +57,11 @@ public class ArchivaRepositoryScanningTaskExecutor
* @plexus.requirement role-hint="jdo"
*/
private ArchivaDAO dao;
-
+
/**
- * @plexus.requirement role-hint="jdo"
+ * @plexus.requirement
*/
- private RepositoryDAO repositoryDAO;
+ private ArchivaConfiguration archivaConfiguration;
/**
* The repository scanner component.
@@ -90,11 +90,11 @@ public class ArchivaRepositoryScanningTaskExecutor
try
{
- ArchivaRepository arepo = repositoryDAO.getRepository( repoTask.getRepositoryId() );
+ ManagedRepositoryConfiguration arepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoTask.getRepositoryId() );
long sinceWhen = RepositoryScanner.FRESH_SCAN;
- List results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
+ List<RepositoryContentStatistics> results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
if ( CollectionUtils.isNotEmpty( results ) )
{
@@ -102,15 +102,19 @@ public class ArchivaRepositoryScanningTaskExecutor
sinceWhen = lastStats.getWhenGathered().getTime() + lastStats.getDuration();
}
- RepositoryContentStatistics stats = repoScanner.scan( arepo, sinceWhen );
+ RepositoryScanStatistics stats = repoScanner.scan( arepo, sinceWhen );
getLogger().info( "Finished repository task: " + stats.toDump( arepo ) );
- stats = (RepositoryContentStatistics) dao.save( stats );
- }
- catch ( ArchivaDatabaseException e )
- {
- throw new TaskExecutionException( "Database error when executing repository job.", e );
+ // I hate jpox and modello
+ RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
+ dbstats.setDuration( stats.getDuration() );
+ dbstats.setNewFileCount( stats.getNewFileCount() );
+ dbstats.setRepositoryId( stats.getRepositoryId() );
+ dbstats.setTotalFileCount( stats.getTotalFileCount() );
+ dbstats.setWhenGathered( stats.getWhenGathered() );
+
+ dao.save( dbstats );
}
catch ( RepositoryException e )
{
diff --git a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
index bfa8ab963..ebdb592c3 100644
--- a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
+++ b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java
@@ -20,12 +20,11 @@ package org.apache.maven.archiva.scheduled.executors;
*/
import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.RepositoryDAO;
import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint;
import org.apache.maven.archiva.model.ArchivaArtifact;
-import org.apache.maven.archiva.model.ArchivaRepository;
import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
@@ -142,28 +141,13 @@ public class ArchivaDatabaseUpdateTaskExecutorTest
public void testExecutor()
throws Exception
{
- RepositoryDAO repoDao = dao.getRepositoryDAO();
-
File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
- String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" );
-
- // Create it
- ArchivaRepository repo = repoDao.createRepository( "testRepo", "Test Repository", repoUri );
+ ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
assertNotNull( repo );
- // Set some mandatory values
- repo.getModel().setCreationSource( "Test Case" );
- repo.getModel().setLayoutName( "default" );
-
- // Save it.
- ArchivaRepository repoSaved = repoDao.saveRepository( repo );
- assertNotNull( repoSaved );
- assertNotNull( repoSaved.getModel() );
- assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() );
-
ArtifactDAO adao = dao.getArtifactDAO();
ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar" );
@@ -205,4 +189,13 @@ public class ArchivaDatabaseUpdateTaskExecutorTest
assertNotNull( "Processed Results should not be null.", processedResultList );
assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
}
+
+ protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLocation( location.getAbsolutePath() );
+ return repo;
+ }
}
diff --git a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
index 7824462e3..8f935289f 100644
--- a/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
+++ b/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java
@@ -19,12 +19,12 @@ package org.apache.maven.archiva.scheduled.executors;
* under the License.
*/
-import org.apache.commons.lang.StringUtils;
+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.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.RepositoryDAO;
import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint;
-import org.apache.maven.archiva.model.ArchivaRepository;
import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
@@ -39,7 +39,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
@@ -140,28 +139,18 @@ public class ArchivaRepositoryScanningTaskExecutorTest
public void testExecutor() throws Exception
{
- RepositoryDAO repoDao = dao.getRepositoryDAO();
-
File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
- String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" );
+ ArchivaConfiguration archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
+ assertNotNull( archivaConfig );
// Create it
- ArchivaRepository repo =
- repoDao.createRepository( "testRepo", "Test Repository", repoUri );
+ ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
assertNotNull( repo );
-
- // Set some mandatory values
- repo.getModel().setCreationSource( "Test Case" );
- repo.getModel().setLayoutName( "default" );
-
- // Save it.
- ArchivaRepository repoSaved = repoDao.saveRepository( repo );
- assertNotNull( repoSaved );
- assertNotNull( repoSaved.getModel() );
- assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() );
+ archivaConfig.getConfiguration().getManagedRepositories().clear();
+ archivaConfig.getConfiguration().addManagedRepository( repo );
RepositoryTask repoTask = new RepositoryTask();
@@ -176,4 +165,13 @@ public class ArchivaRepositoryScanningTaskExecutorTest
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
}
+
+ protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLocation( location.getAbsolutePath() );
+ return repo;
+ }
}
diff --git a/archiva-scheduled/src/test/resources/archiva-test.xml b/archiva-scheduled/src/test/resources/archiva-test.xml
index dbed5bf00..32b43b1bf 100644
--- a/archiva-scheduled/src/test/resources/archiva-test.xml
+++ b/archiva-scheduled/src/test/resources/archiva-test.xml
@@ -19,18 +19,18 @@
-->
<configuration>
- <repositories>
- <repository>
+ <managedRepositories>
+ <managedRepository>
<id>testRepo</id>
<name>Archiva Test Repository</name>
- <url>file://${basedir}/src/test/repositories/default-repository</url>
+ <location>${basedir}/src/test/repositories/default-repository</location>
<layout>default</layout>
<releases>true</releases>
<snapshots>false</snapshots>
<indexed>true</indexed>
<refreshCronExpression>0 0 * * ?</refreshCronExpression>
- </repository>
- </repositories>
+ </managedRepository>
+ </managedRepositories>
<proxyConnectors />
diff --git a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml
index aa04d5931..cd6fbe9fb 100644
--- a/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml
+++ b/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml
@@ -33,9 +33,8 @@
<field-name>dao</field-name>
</requirement>
<requirement>
- <role>org.apache.maven.archiva.database.RepositoryDAO</role>
- <role-hint>jdo</role-hint>
- <field-name>repositoryDAO</field-name>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <field-name>archivaConfiguration</field-name>
</requirement>
<requirement>
<role>org.apache.maven.archiva.repository.scanner.RepositoryScanner</role>