From 4102a4a916f8649dd12182f727b6cb45f4e356b2 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Thu, 19 Nov 2009 17:16:20 +0000 Subject: [PATCH] [MRM-1025] split the scheduler into modules to isolate database and indexer dependent code git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@882207 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-lucene-consumers/pom.xml | 14 +- .../lucene/NexusIndexerConsumer.java | 26 +-- .../lucene/NexusIndexerConsumerTest.java | 42 +--- .../lucene/stubs/ArchivaDAOStub.java | 74 ------- .../archiva-base/archiva-proxy/pom.xml | 2 +- .../DefaultRepositoryProxyConnectors.java | 17 +- .../proxy/CacheFailuresTransferTest.xml | 3 +- .../archiva/proxy/ChecksumTransferTest.xml | 3 +- .../maven/archiva/proxy/ErrorHandlingTest.xml | 3 +- .../archiva/proxy/HttpProxyTransferTest.xml | 3 +- .../proxy/ManagedDefaultTransferTest.xml | 3 +- .../proxy/ManagedLegacyTransferTest.xml | 3 +- .../archiva/proxy/MetadataTransferTest.xml | 3 +- .../archiva/proxy/RelocateTransferTest.xml | 3 +- .../archiva/proxy/SnapshotTransferTest.xml | 3 +- .../scheduled/ArchivaTaskScheduler.java | 94 -------- .../archiva/scheduled/tasks/TaskCreator.java | 100 --------- .../resources/META-INF/plexus/components.xml | 144 ------------ .../scheduled/tasks/TaskCreatorTest.java | 92 -------- .../archiva-scheduler-api/pom.xml | 18 ++ .../scheduler/ArchivaTaskScheduler.java | 44 ++++ .../archiva-scheduler-database/pom.xml | 71 ++++++ .../ArchivaDatabaseUpdateTaskExecutor.java | 3 +- .../DatabaseArchivaTaskScheduler.java | 209 ++++++++++++++++++ .../scheduler/database}/DatabaseTask.java | 2 +- .../scheduler/database}/DatabaseTaskJob.java | 5 +- .../resources/META-INF/plexus/components.xml | 63 ++++++ ...ArchivaDatabaseUpdateTaskExecutorTest.java | 4 +- .../TestDatabaseUnprocessedConsumer.java | 2 +- .../javax/maven-metadata.xml | 0 .../javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 | 0 .../javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 | 0 .../jdbc/2.0/maven-metadata-repository.xml | 0 .../sql/jdbc/maven-metadata-repository.xml | 0 .../javax/sql/maven-metadata-repository.xml | 0 .../org/apache/maven/A/1.0/A-1.0.pom | 0 .../org/apache/maven/A/1.0/A-1.0.pom.md5 | 0 .../org/apache/maven/A/1.0/A-1.0.pom.sha1 | 0 .../org/apache/maven/A/1.0/A-1.0.war | 0 .../org/apache/maven/A/1.0/A-1.0.war.md5 | 0 .../org/apache/maven/A/1.0/A-1.0.war.sha1 | 0 .../org/apache/maven/B/1.0/B-1.0.pom | 0 .../org/apache/maven/B/1.0/B-1.0.pom.md5 | 0 .../org/apache/maven/B/1.0/B-1.0.pom.sha1 | 0 .../org/apache/maven/B/2.0/B-2.0.pom | 0 .../org/apache/maven/B/2.0/B-2.0.pom.md5 | 0 .../org/apache/maven/B/2.0/B-2.0.pom.sha1 | 0 .../org/apache/maven/C/1.0/C-1.0.pom | 0 .../org/apache/maven/C/1.0/C-1.0.pom.md5 | 0 .../org/apache/maven/C/1.0/C-1.0.pom.sha1 | 0 .../org/apache/maven/C/1.0/C-1.0.war | 0 .../org/apache/maven/C/1.0/C-1.0.war.md5 | 0 .../org/apache/maven/C/1.0/C-1.0.war.sha1 | 0 .../org/apache/maven/maven-metadata.xml | 0 .../testgroup/discovery/1.0/discovery-1.0.pom | 0 .../discovery/1.0/discovery-1.0.pom.md5 | 0 .../discovery/1.0/discovery-1.0.pom.sha1 | 0 .../discovery/1.0/maven-metadata.xml | 0 .../testgroup/discovery/maven-metadata.xml | 0 .../src/test/resources/archiva-test.xml | 0 .../ArchivaDatabaseUpdateTaskExecutorTest.xml | 4 +- .../archiva-scheduler-indexing/pom.xml | 62 ++++++ .../ArchivaIndexingTaskExecutor.java | 4 +- .../indexing}/ArtifactIndexingTask.java | 29 ++- .../IndexingArchivaTaskScheduler.java | 51 +++++ .../resources/META-INF/plexus/components.xml | 63 ++++++ .../ArchivaIndexingTaskExecutorTest.java | 27 +-- .../archiva-scheduler-repository}/pom.xml | 74 ++----- ...ArchivaRepositoryScanningTaskExecutor.java | 3 +- .../RepositoryArchivaTaskScheduler.java} | 189 +++------------- .../scheduler/repository}/RepositoryTask.java | 2 +- .../repository}/RepositoryTaskJob.java | 11 +- .../resources/META-INF/plexus/components.xml | 63 ++++++ ...ivaRepositoryScanningTaskExecutorTest.java | 8 +- .../javax/maven-metadata.xml} | 16 +- .../javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 | 1 + .../javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 | 1 + .../jdbc/2.0/maven-metadata-repository.xml | 25 +++ .../sql/jdbc/maven-metadata-repository.xml | 30 +++ .../javax/sql/maven-metadata-repository.xml | 25 +++ .../org/apache/maven/A/1.0/A-1.0.pom | 28 +++ .../org/apache/maven/A/1.0/A-1.0.pom.md5 | 1 + .../org/apache/maven/A/1.0/A-1.0.pom.sha1 | 1 + .../org/apache/maven/A/1.0/A-1.0.war | 1 + .../org/apache/maven/A/1.0/A-1.0.war.md5 | 1 + .../org/apache/maven/A/1.0/A-1.0.war.sha1 | 1 + .../org/apache/maven/B/1.0/B-1.0.pom | 28 +++ .../org/apache/maven/B/1.0/B-1.0.pom.md5 | 1 + .../org/apache/maven/B/1.0/B-1.0.pom.sha1 | 1 + .../org/apache/maven/B/2.0/B-2.0.pom | 28 +++ .../org/apache/maven/B/2.0/B-2.0.pom.md5 | 1 + .../org/apache/maven/B/2.0/B-2.0.pom.sha1 | 1 + .../org/apache/maven/C/1.0/C-1.0.pom | 28 +++ .../org/apache/maven/C/1.0/C-1.0.pom.md5 | 1 + .../org/apache/maven/C/1.0/C-1.0.pom.sha1 | 1 + .../org/apache/maven/C/1.0/C-1.0.war | 1 + .../org/apache/maven/C/1.0/C-1.0.war.md5 | 1 + .../org/apache/maven/C/1.0/C-1.0.war.sha1 | 1 + .../org/apache/maven/maven-metadata.xml | 23 ++ .../testgroup/discovery/1.0/discovery-1.0.pom | 28 +++ .../discovery/1.0/discovery-1.0.pom.md5 | 1 + .../discovery/1.0/discovery-1.0.pom.sha1 | 1 + .../discovery/1.0/maven-metadata.xml | 25 +++ .../testgroup/discovery/maven-metadata.xml | 24 ++ .../src/test/resources/archiva-test.xml | 119 ++++++++++ ...hivaRepositoryScanningTaskExecutorTest.xml | 2 +- .../archiva-index-methods-jar-test-1.0.jar | Bin .../1.0/pom.xml | 0 archiva-modules/archiva-scheduler/pom.xml | 37 ++++ .../archiva-web/archiva-webapp/pom.xml | 6 +- .../archiva/web/action/UploadAction.java | 20 +- .../web/action/admin/SchedulerAction.java | 31 ++- .../archiva/web/startup/ArchivaStartup.java | 43 ++-- .../archiva/web/action/UploadActionTest.java | 5 +- .../archiva-web/archiva-webdav/pom.xml | 4 - .../archiva/webdav/ArchivaDavResource.java | 21 +- .../webdav/ArchivaDavResourceFactory.java | 8 +- .../webdav/RepositoryServletSecurityTest.xml | 3 +- .../archiva/webdav/RepositoryServletTest.xml | 3 +- .../archiva-xmlrpc-services/pom.xml | 10 +- .../services/AdministrationServiceImpl.java | 139 ++++++------ .../AdministrationServiceImplTest.java | 61 ++--- archiva-modules/pom.xml | 2 +- pom.xml | 17 +- 126 files changed, 1489 insertions(+), 1011 deletions(-) delete mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/stubs/ArchivaDAOStub.java delete mode 100644 archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java delete mode 100644 archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java delete mode 100644 archiva-modules/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml delete mode 100644 archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/ArchivaTaskScheduler.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database}/ArchivaDatabaseUpdateTaskExecutor.java (95%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks => archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database}/DatabaseTask.java (96%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled => archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database}/DatabaseTaskJob.java (90%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml rename archiva-modules/{archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database}/ArchivaDatabaseUpdateTaskExecutorTest.java (98%) rename archiva-modules/{archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled => archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database}/TestDatabaseUnprocessedConsumer.java (98%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/maven-metadata.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-database}/src/test/resources/archiva-test.xml (100%) rename archiva-modules/{archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database}/ArchivaDatabaseUpdateTaskExecutorTest.xml (93%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing}/ArchivaIndexingTaskExecutor.java (97%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks => archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing}/ArtifactIndexingTask.java (73%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/plexus/components.xml rename archiva-modules/{archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing}/ArchivaIndexingTaskExecutorTest.java (90%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-repository}/pom.xml (51%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository}/ArchivaRepositoryScanningTaskExecutor.java (98%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java => archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java} (68%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks => archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository}/RepositoryTask.java (98%) rename archiva-modules/{archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled => archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository}/RepositoryTaskJob.java (79%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/resources/META-INF/plexus/components.xml rename archiva-modules/{archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository}/ArchivaRepositoryScanningTaskExecutorTest.java (98%) rename archiva-modules/{archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/org/apache/archiva/consumers/lucene/LuceneConsumersTest.xml => archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/maven-metadata.xml} (74%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/archiva-test.xml rename archiva-modules/{archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors => archiva-scheduler/archiva-scheduler-repository/src/test/resources/org/apache/archiva/scheduler/repository}/ArchivaRepositoryScanningTaskExecutorTest.xml (97%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-repository}/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar (100%) rename archiva-modules/{archiva-scheduled => archiva-scheduler/archiva-scheduler-repository}/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml (100%) create mode 100644 archiva-modules/archiva-scheduler/pom.xml diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml index 169ace1fe..3d0d77f22 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml @@ -30,14 +30,6 @@ Archiva Consumers :: Lucene Consumers - - org.apache.archiva - archiva-common - - - org.apache.archiva - archiva-database - org.apache.archiva archiva-configuration @@ -52,7 +44,11 @@ org.apache.archiva - archiva-scheduled + archiva-scheduler-api + + + org.apache.archiva + archiva-scheduler-indexing org.slf4j diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java index 2567d13ba..be141b307 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java @@ -26,6 +26,8 @@ import java.util.Collections; import java.util.Date; import java.util.List; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.FileTypes; @@ -34,9 +36,6 @@ import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; import org.apache.maven.archiva.consumers.ConsumerException; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.registry.Registry; @@ -64,13 +63,14 @@ public class NexusIndexerConsumer private File managedRepository; - private ArchivaTaskScheduler scheduler; + private ArchivaTaskScheduler scheduler; private IndexingContext context; private List includes = new ArrayList(); - public NexusIndexerConsumer( ArchivaTaskScheduler scheduler, ArchivaConfiguration configuration, FileTypes filetypes ) + public NexusIndexerConsumer( ArchivaTaskScheduler scheduler, + ArchivaConfiguration configuration, FileTypes filetypes ) { this.configuration = configuration; this.filetypes = filetypes; @@ -102,7 +102,7 @@ public class NexusIndexerConsumer try { - context = TaskCreator.createContext( repository ); + context = ArtifactIndexingTask.createContext( repository ); } catch ( IOException e ) { @@ -120,12 +120,12 @@ public class NexusIndexerConsumer File artifactFile = new File( managedRepository, path ); ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryContent.getRepository(), artifactFile, - ArtifactIndexingTask.Action.ADD, context ); + new ArtifactIndexingTask( repositoryContent.getRepository(), artifactFile, ArtifactIndexingTask.Action.ADD, + context ); try { log.debug( "Queueing indexing task + '" + task + "' to add or update the artifact in the index." ); - scheduler.queueIndexingTask( task ); + scheduler.queueTask( task ); } catch ( TaskQueueException e ) { @@ -136,12 +136,12 @@ public class NexusIndexerConsumer public void completeScan() { ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryContent.getRepository(), null, - ArtifactIndexingTask.Action.FINISH, context ); + new ArtifactIndexingTask( repositoryContent.getRepository(), null, ArtifactIndexingTask.Action.FINISH, + context ); try { log.debug( "Queueing indexing task + '" + task + "' to finish indexing." ); - scheduler.queueIndexingTask( task ); + scheduler.queueTask( task ); } catch ( TaskQueueException e ) { @@ -173,7 +173,7 @@ public class NexusIndexerConsumer includes.clear(); includes.addAll( filetypes.getFileTypePatterns( FileTypes.INDEXABLE_CONTENT ) ); - + includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) ); } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java index fc725f785..7d6953ddd 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java @@ -27,20 +27,16 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.commons.io.FileUtils; -import org.apache.maven.archiva.common.ArchivaException; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.FileTypes; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.codehaus.plexus.taskqueue.TaskQueueException; -import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; /** * NexusIndexerConsumerTest @@ -49,26 +45,11 @@ public class NexusIndexerConsumerTest extends PlexusInSpringTestCase { private final class ArchivaTaskSchedulerStub - implements ArchivaTaskScheduler + implements ArchivaTaskScheduler { Set indexed = new HashSet(); - public void startup() - throws ArchivaException - { - } - - public void scheduleDatabaseTasks() - throws TaskExecutionException - { - } - - public void queueRepositoryTask( RepositoryTask task ) - throws TaskQueueException - { - } - - public void queueIndexingTask( ArtifactIndexingTask task ) + public void queueTask( ArtifactIndexingTask task ) throws TaskQueueException { switch ( task.getAction() ) @@ -91,21 +72,6 @@ public class NexusIndexerConsumerTest break; } } - - public void queueDatabaseTask( DatabaseTask task ) - throws TaskQueueException - { - } - - public boolean isProcessingRepositoryTask( String repositoryId ) - { - return false; - } - - public boolean isProcessingDatabaseTask() - { - return false; - } } private KnownRepositoryContentConsumer nexusIndexerConsumer; diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/stubs/ArchivaDAOStub.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/stubs/ArchivaDAOStub.java deleted file mode 100644 index 47ebdce62..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/stubs/ArchivaDAOStub.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.apache.archiva.consumers.lucene.stubs; - -/* - * 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.io.Serializable; -import java.util.List; - -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; -import org.apache.maven.archiva.database.RepositoryProblemDAO; -import org.apache.maven.archiva.database.SimpleConstraint; - -/** - * Using a stub for faster tests! Not really used for the unit tests, just for dependency injection. - */ -public class ArchivaDAOStub - implements ArchivaDAO -{ - - public ArtifactDAO getArtifactDAO() - { - // TODO Auto-generated method stub - return null; - } - - public ProjectModelDAO getProjectModelDAO() - { - // TODO Auto-generated method stub - return null; - } - - public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO() - { - // TODO Auto-generated method stub - return null; - } - - public RepositoryProblemDAO getRepositoryProblemDAO() - { - // TODO Auto-generated method stub - return null; - } - - public List query( SimpleConstraint constraint ) - { - // TODO Auto-generated method stub - return null; - } - - public Object save( Serializable obj ) - { - // TODO Auto-generated method stub - return null; - } -} diff --git a/archiva-modules/archiva-base/archiva-proxy/pom.xml b/archiva-modules/archiva-base/archiva-proxy/pom.xml index dc855cda5..334b003ba 100644 --- a/archiva-modules/archiva-base/archiva-proxy/pom.xml +++ b/archiva-modules/archiva-base/archiva-proxy/pom.xml @@ -47,7 +47,7 @@ org.apache.archiva - archiva-scheduled + archiva-scheduler-repository commons-io diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java index 674488a06..1306eb76e 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java @@ -30,6 +30,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; @@ -55,9 +57,6 @@ import org.apache.maven.archiva.repository.RepositoryException; import org.apache.maven.archiva.repository.RepositoryNotFoundException; import org.apache.maven.archiva.repository.metadata.MetadataTools; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.Wagon; @@ -133,9 +132,9 @@ public class DefaultRepositoryProxyConnectors private WagonFactory wagonFactory; /** - * @plexus.requirement + * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository" */ - private ArchivaTaskScheduler scheduler; + private RepositoryArchivaTaskScheduler scheduler; public File fetchFromProxies( ManagedRepositoryContent repository, ArtifactReference artifact ) throws ProxyDownloadException @@ -585,11 +584,15 @@ public class DefaultRepositoryProxyConnectors private void queueRepositoryTask( String repositoryId, File localFile ) { - RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile, true, true ); + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repositoryId ); + task.setResourceFile( localFile ); + task.setUpdateRelatedArtifacts( true ); + task.setScanAll( true ); try { - scheduler.queueRepositoryTask( task ); + scheduler.queueTask( task ); } catch ( TaskQueueException e ) { diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml index 0c735768c..80bc628da 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/CacheFailuresTransferTest.xml @@ -78,7 +78,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ChecksumTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ChecksumTransferTest.xml index 1c6faa919..d5d032574 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ChecksumTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ChecksumTransferTest.xml @@ -76,7 +76,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ErrorHandlingTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ErrorHandlingTest.xml index f5795b797..884b9778f 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ErrorHandlingTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ErrorHandlingTest.xml @@ -81,7 +81,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/HttpProxyTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/HttpProxyTransferTest.xml index 34bd22bf8..620cc84d0 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/HttpProxyTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/HttpProxyTransferTest.xml @@ -72,7 +72,8 @@ default - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.xml index 1c6faa919..d5d032574 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedDefaultTransferTest.xml @@ -76,7 +76,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.xml index 1c6faa919..d5d032574 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/ManagedLegacyTransferTest.xml @@ -76,7 +76,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml index 2a03b3a43..2b14dd8fb 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/MetadataTransferTest.xml @@ -95,7 +95,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml index 1c6faa919..d5d032574 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/RelocateTransferTest.xml @@ -76,7 +76,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/SnapshotTransferTest.xml b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/SnapshotTransferTest.xml index 1c6faa919..d5d032574 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/SnapshotTransferTest.xml +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/resources/org/apache/maven/archiva/proxy/SnapshotTransferTest.xml @@ -76,7 +76,8 @@ urlFailureCache - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java deleted file mode 100644 index 444a7b1d2..000000000 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.maven.archiva.scheduled; - -/* - * 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.apache.maven.archiva.common.ArchivaException; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.codehaus.plexus.taskqueue.TaskQueueException; -import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; - -/** - * The component that takes care of scheduling in the application. - * - */ -public interface ArchivaTaskScheduler -{ - /** - * The Plexus component role. - */ - public final static String ROLE = ArchivaTaskScheduler.class.getName(); - - /** - * Checks if there is any database scanning task queued. - * - * @return - * @throws ArchivaException - */ - public boolean isProcessingDatabaseTask(); - - /** - * Checks if a repository scanning task for the specified repository is queuedd. - * - * @param repositoryId - * @return - * @throws ArchivaException - */ - public boolean isProcessingRepositoryTask( String repositoryId ); - - /** - * Adds the database task to the database scanning queue. - * - * @param task - * @throws TaskQueueException - */ - public void queueDatabaseTask( DatabaseTask task ) - throws TaskQueueException; - - /** - * Adds the repository task to the repo scanning queue. - * - * @param task - * @throws TaskQueueException - */ - public void queueRepositoryTask( RepositoryTask task ) - throws TaskQueueException; - - /** - * Adds the indexing task to the indexing queue. - * - * @param task - * @throws TaskQueueException - */ - public void queueIndexingTask( ArtifactIndexingTask task ) - throws TaskQueueException; - - /** - * Schedules the database tasks using the set cron expression. - * - * @throws TaskExecutionException - */ - public void scheduleDatabaseTasks() - throws TaskExecutionException; - - public void startup() - throws ArchivaException; -} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java deleted file mode 100644 index 5075b6e81..000000000 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/TaskCreator.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.archiva.scheduled.tasks; - -/* - * 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.io.File; -import java.io.IOException; - -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.sonatype.nexus.index.NexusIndexer; -import org.sonatype.nexus.index.context.DefaultIndexingContext; -import org.sonatype.nexus.index.context.IndexingContext; -import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; - -/** - * TaskCreator Convenience class for creating Archiva tasks. - * @todo Nexus specifics shouldn't be in the archiva-scheduled module - */ -public class TaskCreator -{ - public static RepositoryTask createRepositoryTask( String repositoryId ) - { - RepositoryTask task = new RepositoryTask(); - task.setRepositoryId( repositoryId ); - return task; - } - - public static RepositoryTask createRepositoryTask( String repositoryId, boolean scanAll ) - { - RepositoryTask task = createRepositoryTask( repositoryId ); - task.setScanAll( scanAll ); - - return task; - } - - public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile, - boolean updateRelatedArtifacts ) - { - RepositoryTask task = createRepositoryTask( repositoryId ); - task.setResourceFile( resourceFile ); - task.setUpdateRelatedArtifacts( updateRelatedArtifacts ); - - return task; - } - - public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile, - boolean updateRelatedArtifacts, boolean scanAll ) - { - RepositoryTask task = createRepositoryTask( repositoryId, resourceFile, updateRelatedArtifacts ); - task.setScanAll( scanAll ); - - return task; - } - - public static ArtifactIndexingTask createIndexingTask( ManagedRepositoryConfiguration repository, File resource, - ArtifactIndexingTask.Action action, IndexingContext context ) - { - return new ArtifactIndexingTask( repository, resource, action, context ); - } - - public static IndexingContext createContext( ManagedRepositoryConfiguration repository ) - throws IOException, UnsupportedExistingLuceneIndexException - { - String indexDir = repository.getIndexDir(); - File managedRepository = new File( repository.getLocation() ); - - File indexDirectory = null; - if ( indexDir != null && !"".equals( indexDir ) ) - { - indexDirectory = new File( repository.getIndexDir() ); - } - else - { - indexDirectory = new File( managedRepository, ".indexer" ); - } - - IndexingContext context = - new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory, - null, null, NexusIndexer.FULL_INDEX, false ); - context.setSearchable( repository.isScanned() ); - return context; - } - -} diff --git a/archiva-modules/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 27e491340..000000000 --- a/archiva-modules/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - org.codehaus.plexus.taskqueue.TaskQueue - database-update - org.codehaus.plexus.taskqueue.DefaultTaskQueue - plexus-configurable - - - - - - - - - - - - org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor - database-update - org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor - singleton - - - org.codehaus.plexus.taskqueue.execution.TaskExecutor - database-update - - - org.codehaus.plexus.taskqueue.TaskQueue - database-update - - - - database-update - - - - - - org.codehaus.plexus.taskqueue.TaskQueue - repository-scanning - org.codehaus.plexus.taskqueue.DefaultTaskQueue - plexus-configurable - - - - - - - - - - - - org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor - repository-scanning - org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor - singleton - - - org.codehaus.plexus.taskqueue.execution.TaskExecutor - repository-scanning - - - org.codehaus.plexus.taskqueue.TaskQueue - repository-scanning - - - - repository-scanning - - - - - - - org.codehaus.plexus.taskqueue.TaskQueue - indexing - org.codehaus.plexus.taskqueue.DefaultTaskQueue - plexus-configurable - - - - - - - - - - - - org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor - indexing - org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor - singleton - - - org.codehaus.plexus.taskqueue.execution.TaskExecutor - indexing - - - org.codehaus.plexus.taskqueue.TaskQueue - indexing - - - - indexing - - - - diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java deleted file mode 100644 index 68c1ad476..000000000 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/tasks/TaskCreatorTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.apache.maven.archiva.scheduled.tasks; - -/* - * 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.io.File; - -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -public class TaskCreatorTest - extends PlexusInSpringTestCase -{ - private static final String REPO_ID = "test-repo"; - - public void testCreateRepositoryTask() - throws Exception - { - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID ); - - assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() ); - } - - public void testCreateRepositoryTaskWithTaskNameSuffix() - throws Exception - { - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID ); - - assertBasicTaskDetails( task ); - } - - public void testCreateRepositoryTaskScanAllArtifacts() - throws Exception - { - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, true ); - - assertBasicTaskDetails( task ); - assertTrue( task.isScanAll() ); - } - - public void testCreateRepositoryTaskDoNotScanAllArtifacts() - throws Exception - { - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, false ); - - assertBasicTaskDetails( task ); - assertFalse( task.isScanAll() ); - } - - public void testCreateRepositoryTaskForArtifactUpdateAllRelated() - throws Exception - { - File resource = new File( getBasedir(), "target/test-classes/test.jar" ); - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, true ); - - assertBasicTaskDetails( task ); - assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() ); - assertTrue( task.isUpdateRelatedArtifacts() ); - } - - public void testCreateRepositoryTaskForArtifactDoNotUpdateAllRelated() - throws Exception - { - File resource = new File( getBasedir(), "target/test-classes/test.jar" ); - RepositoryTask task = TaskCreator.createRepositoryTask( REPO_ID, resource, false ); - - assertBasicTaskDetails( task ); - assertEquals( "Incorrect resource file set.", resource, task.getResourceFile() ); - assertFalse( task.isUpdateRelatedArtifacts() ); - } - - private void assertBasicTaskDetails( RepositoryTask task ) - { - assertEquals( "Incorrect repository id set.", REPO_ID, task.getRepositoryId() ); - } - -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml new file mode 100644 index 000000000..ffcbe736b --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-api/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + archiva-scheduler + org.apache.archiva + 1.3-SNAPSHOT + + archiva-scheduler-api + Archiva Base :: Scheduled Tasks :: API + + + org.codehaus.plexus + plexus-taskqueue + + + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/ArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/ArchivaTaskScheduler.java new file mode 100644 index 000000000..dbcffead1 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/ArchivaTaskScheduler.java @@ -0,0 +1,44 @@ +package org.apache.archiva.scheduler; + +/* + * 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.taskqueue.Task; +import org.codehaus.plexus.taskqueue.TaskQueueException; + +/** + * The component that takes care of scheduling in the application. + * + */ +public interface ArchivaTaskScheduler +{ + /** + * The Plexus component role. + */ + public final static String ROLE = ArchivaTaskScheduler.class.getName(); + + /** + * Adds the task to the scanning queue. + * + * @param task + * @throws TaskQueueException + */ + public void queueTask( T task ) + throws TaskQueueException; +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml new file mode 100644 index 000000000..73c70f4a8 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + archiva-scheduler + org.apache.archiva + 1.3-SNAPSHOT + + archiva-scheduler-database + Archiva Base :: Scheduled Tasks :: Database + + + org.apache.archiva + archiva-scheduler-api + + + org.apache.archiva + archiva-configuration + + + org.apache.archiva + archiva-database + + + org.codehaus.plexus + plexus-quartz + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + test + + + hsqldb + hsqldb + test + + + org.codehaus.plexus + plexus-spring + test + + + + + + org.codehaus.plexus + plexus-component-metadata + + + merge + + merge-metadata + + + + ${basedir}/src/main/resources/META-INF/plexus/components.xml + ${project.build.outputDirectory}/META-INF/plexus/components.xml + + + + + + + + diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java similarity index 95% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java index 7f8964575..a675d8e51 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.database; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -21,7 +21,6 @@ package org.apache.maven.archiva.scheduled.executors; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.updater.DatabaseUpdater; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.taskqueue.Task; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java new file mode 100644 index 000000000..c98f692af --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java @@ -0,0 +1,209 @@ +package org.apache.archiva.scheduler.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 java.text.ParseException; +import java.util.List; + +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.maven.archiva.common.ArchivaException; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ConfigurationEvent; +import org.apache.maven.archiva.configuration.ConfigurationListener; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; +import org.codehaus.plexus.scheduler.CronExpressionValidator; +import org.codehaus.plexus.scheduler.Scheduler; +import org.codehaus.plexus.taskqueue.Task; +import org.codehaus.plexus.taskqueue.TaskQueue; +import org.codehaus.plexus.taskqueue.TaskQueueException; +import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; +import org.quartz.CronTrigger; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.SchedulerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Default implementation of a scheduling component for archiva. + * + * @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database" + */ +public class DatabaseArchivaTaskScheduler + implements ArchivaTaskScheduler, Startable, ConfigurationListener +{ + private Logger log = LoggerFactory.getLogger( DatabaseArchivaTaskScheduler.class ); + + /** + * @plexus.requirement + */ + private Scheduler scheduler; + + /** + * @plexus.requirement role-hint="database-update" + */ + private TaskQueue databaseUpdateQueue; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + private static final String DATABASE_SCAN_GROUP = "dbg"; + + private static final String DATABASE_JOB = "dbj"; + + private static final String DATABASE_JOB_TRIGGER = "dbt"; + + static final String TASK_QUEUE = "TASK_QUEUE"; + + public static final String CRON_HOURLY = "0 0 * * * ?"; + + public void startup() + throws ArchivaException + { + archivaConfiguration.addListener( this ); + + try + { + start(); + } + catch ( StartingException e ) + { + throw new ArchivaException( e.getMessage(), e ); + } + } + + public void start() + throws StartingException + { + try + { + scheduleDatabaseJobs(); + } + catch ( SchedulerException e ) + { + throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e ); + } + } + + public void stop() + throws StoppingException + { + try + { + scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); + } + catch ( SchedulerException e ) + { + throw new StoppingException( "Unable to unschedule tasks", e ); + } + } + + public void scheduleDatabaseTasks() + throws TaskExecutionException + { + try + { + scheduleDatabaseJobs(); + } + catch ( SchedulerException e ) + { + throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e ); + + } + } + + @SuppressWarnings("unchecked") + public boolean isProcessingDatabaseTask() + { + List queue = null; + + try + { + queue = databaseUpdateQueue.getQueueSnapshot(); + } + catch ( TaskQueueException e ) + { + // not possible with plexus-taskqueue implementation, ignore + } + + return !queue.isEmpty(); + } + + public void queueTask( DatabaseTask task ) + throws TaskQueueException + { + databaseUpdateQueue.put( task ); + } + + public void configurationEvent( ConfigurationEvent event ) + { + if ( event.getType() == ConfigurationEvent.SAVED ) + { + try + { + scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); + + scheduleDatabaseJobs(); + } + catch ( SchedulerException e ) + { + log.error( "Error restarting the database scanning job after property change." ); + } + } + } + + private synchronized void scheduleDatabaseJobs() + throws SchedulerException + { + String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression(); + + // setup the unprocessed artifact job + JobDetail databaseJob = new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class ); + + JobDataMap dataMap = new JobDataMap(); + dataMap.put( TASK_QUEUE, databaseUpdateQueue ); + databaseJob.setJobDataMap( dataMap ); + + CronExpressionValidator cronValidator = new CronExpressionValidator(); + if ( !cronValidator.validate( cronString ) ) + { + log.warn( + "Cron expression [" + cronString + "] for database update is invalid. Defaulting to hourly." ); + cronString = CRON_HOURLY; + } + + try + { + CronTrigger trigger = new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_SCAN_GROUP, cronString ); + + scheduler.scheduleJob( databaseJob, trigger ); + } + catch ( ParseException e ) + { + log.error( + "ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() ); + } + + } +} \ No newline at end of file diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java similarity index 96% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java index c2db624de..6757fa43f 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.tasks; +package org.apache.archiva.scheduler.database; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java similarity index 90% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java index e00829be1..1721505a3 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled; +package org.apache.archiva.scheduler.database; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,7 +19,6 @@ package org.apache.maven.archiva.scheduled; * under the License. */ -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; import org.codehaus.plexus.scheduler.AbstractJob; import org.codehaus.plexus.taskqueue.Task; import org.codehaus.plexus.taskqueue.TaskQueue; @@ -47,7 +46,7 @@ public class DatabaseTaskJob JobDataMap dataMap = context.getJobDetail().getJobDataMap(); setJobDataMap( dataMap ); - TaskQueue taskQueue = (TaskQueue) dataMap.get( DefaultArchivaTaskScheduler.TASK_QUEUE ); + TaskQueue taskQueue = (TaskQueue) dataMap.get( DatabaseArchivaTaskScheduler.TASK_QUEUE ); Task task = new DatabaseTask(); diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..3d77c29ce --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,63 @@ + + + + + + + + org.codehaus.plexus.taskqueue.TaskQueue + database-update + org.codehaus.plexus.taskqueue.DefaultTaskQueue + plexus-configurable + + + + + + + + + + + + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor + database-update + org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor + singleton + + + org.codehaus.plexus.taskqueue.execution.TaskExecutor + database-update + + + org.codehaus.plexus.taskqueue.TaskQueue + database-update + + + + database-update + + + + diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java similarity index 98% rename from archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java index 84a8235a8..6d83c4c7f 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.database; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -25,7 +25,6 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; - import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; @@ -34,7 +33,6 @@ import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; import org.codehaus.plexus.jdo.JdoFactory; import org.codehaus.plexus.spring.PlexusInSpringTestCase; diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java similarity index 98% rename from archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java index 6f3807c07..185071b9a 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled; +package org.apache.archiva.scheduler.database; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/maven-metadata.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/maven-metadata.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/maven-metadata.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml diff --git a/archiva-modules/archiva-scheduled/src/test/resources/archiva-test.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/archiva-test.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/resources/archiva-test.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/archiva-test.xml diff --git a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml similarity index 93% rename from archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml index ebdc062ef..2d2746d21 100644 --- a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml @@ -23,7 +23,7 @@ org.codehaus.plexus.taskqueue.execution.TaskExecutor test-database-update - org.apache.maven.archiva.scheduled.executors.ArchivaDatabaseUpdateTaskExecutor + org.apache.archiva.scheduler.database.ArchivaDatabaseUpdateTaskExecutor @@ -69,7 +69,7 @@ org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer test-db-unprocessed - org.apache.maven.archiva.scheduled.TestDatabaseUnprocessedConsumer + org.apache.archiva.scheduler.database.TestDatabaseUnprocessedConsumer diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml new file mode 100644 index 000000000..412d05472 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + archiva-scheduler + org.apache.archiva + 1.3-SNAPSHOT + + archiva-scheduler-indexing + Archiva Base :: Scheduled Tasks :: Indexing + + + org.apache.archiva + archiva-scheduler-api + + + org.apache.archiva + archiva-configuration + + + org.sonatype.nexus + nexus-indexer + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + test + + + org.codehaus.plexus + plexus-spring + test + + + + + + org.codehaus.plexus + plexus-component-metadata + + + merge + + merge-metadata + + + + ${basedir}/src/main/resources/META-INF/plexus/components.xml + ${project.build.outputDirectory}/META-INF/plexus/components.xml + + + + + + + + diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java similarity index 97% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index 2eef44f6d..64e13b636 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.indexing; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -25,7 +25,6 @@ import java.io.IOException; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.taskqueue.Task; @@ -47,7 +46,6 @@ import org.sonatype.nexus.index.packer.IndexPackingRequest; * all performed by this executor. Add and update artifact in index tasks are added in the indexing task queue by the * NexusIndexerConsumer while remove artifact from index tasks are added by the LuceneCleanupRemoveIndexedConsumer. * - * @todo Nexus specifics shouldn't be in the archiva-scheduled module * @plexus.component role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="indexing" * instantiation-strategy="singleton" */ diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java similarity index 73% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java index a9c0ac465..79207e731 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArtifactIndexingTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.tasks; +package org.apache.archiva.scheduler.indexing; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -20,10 +20,14 @@ package org.apache.maven.archiva.scheduled.tasks; */ import java.io.File; +import java.io.IOException; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.codehaus.plexus.taskqueue.Task; +import org.sonatype.nexus.index.NexusIndexer; +import org.sonatype.nexus.index.context.DefaultIndexingContext; import org.sonatype.nexus.index.context.IndexingContext; +import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException; public class ArtifactIndexingTask implements Task @@ -116,4 +120,27 @@ public class ArtifactIndexingTask return false; return true; } + + public static IndexingContext createContext( ManagedRepositoryConfiguration repository ) + throws IOException, UnsupportedExistingLuceneIndexException + { + String indexDir = repository.getIndexDir(); + File managedRepository = new File( repository.getLocation() ); + + File indexDirectory = null; + if ( indexDir != null && !"".equals( indexDir ) ) + { + indexDirectory = new File( repository.getIndexDir() ); + } + else + { + indexDirectory = new File( managedRepository, ".indexer" ); + } + + IndexingContext context = + new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory, + null, null, NexusIndexer.FULL_INDEX, false ); + context.setSearchable( repository.isScanned() ); + return context; + } } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java new file mode 100644 index 000000000..d5d92f3b8 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/IndexingArchivaTaskScheduler.java @@ -0,0 +1,51 @@ +package org.apache.archiva.scheduler.indexing; + +/* + * 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.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.codehaus.plexus.taskqueue.TaskQueue; +import org.codehaus.plexus.taskqueue.TaskQueueException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Default implementation of a scheduling component for archiva. + * + * @todo FIXME - consider just folding in, not really scheduled + * + * @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="indexing" + */ +public class IndexingArchivaTaskScheduler + implements ArchivaTaskScheduler +{ + private Logger log = LoggerFactory.getLogger( IndexingArchivaTaskScheduler.class ); + + /** + * @plexus.requirement role-hint="indexing" + */ + private TaskQueue indexingQueue; + + public void queueTask( ArtifactIndexingTask task ) + throws TaskQueueException + { + indexingQueue.put( task ); + } + +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..68e97ab8d --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,63 @@ + + + + + + + + org.codehaus.plexus.taskqueue.TaskQueue + indexing + org.codehaus.plexus.taskqueue.DefaultTaskQueue + plexus-configurable + + + + + + + + + + + + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor + indexing + org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor + singleton + + + org.codehaus.plexus.taskqueue.execution.TaskExecutor + indexing + + + org.codehaus.plexus.taskqueue.TaskQueue + indexing + + + + indexing + + + + diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java similarity index 90% rename from archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java index a0e90b647..d8aeb1787 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaIndexingTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.indexing; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -31,14 +31,12 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.io.FileUtils; +import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.BooleanClause.Occur; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.sonatype.nexus.index.ArtifactInfo; import org.sonatype.nexus.index.FlatSearchRequest; @@ -95,7 +93,7 @@ public class ArchivaIndexingTaskExecutorTest indexingExecutor.setIndexerEngine( indexerEngine ); indexingExecutor.setIndexPacker( indexPacker ); - context = TaskCreator.createContext( repositoryConfig ); + context = ArtifactIndexingTask.createContext( repositoryConfig ); } protected void tearDown() @@ -124,7 +122,7 @@ public class ArchivaIndexingTaskExecutorTest "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); + new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); indexingExecutor.executeTask( task ); @@ -164,7 +162,7 @@ public class ArchivaIndexingTaskExecutorTest "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); + new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); indexingExecutor.executeTask( task ); indexingExecutor.executeTask( task ); @@ -193,7 +191,7 @@ public class ArchivaIndexingTaskExecutorTest "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); + new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); // remove artifact from index indexingExecutor.executeTask( task ); @@ -213,15 +211,13 @@ public class ArchivaIndexingTaskExecutorTest searcher.close(); - context = TaskCreator.createContext( repositoryConfig ); + context = ArtifactIndexingTask.createContext( repositoryConfig ); // remove added artifact from index - task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.DELETE, context ); + task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.DELETE, context ); indexingExecutor.executeTask( task ); - task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH, context ); + task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH, context ); indexingExecutor.executeTask( task ); q = new BooleanQuery(); @@ -250,12 +246,11 @@ public class ArchivaIndexingTaskExecutorTest "org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ); ArtifactIndexingTask task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); + new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.ADD, context ); indexingExecutor.executeTask( task ); - task = - TaskCreator.createIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH, context ); + task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH, context ); indexingExecutor.executeTask( task ); diff --git a/archiva-modules/archiva-scheduled/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml similarity index 51% rename from archiva-modules/archiva-scheduled/pom.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml index f3cb8421f..d71b10925 100644 --- a/archiva-modules/archiva-scheduled/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml @@ -1,97 +1,57 @@ - - - + + 4.0.0 + archiva-scheduler org.apache.archiva - archiva-modules 1.3-SNAPSHOT - 4.0.0 - archiva-scheduled - Archiva Base :: Scheduled Tasks + archiva-scheduler-repository + Archiva Base :: Scheduled Tasks :: Repository Scanning org.apache.archiva - archiva-configuration + archiva-scheduler-api org.apache.archiva - archiva-database + archiva-configuration org.apache.archiva - archiva-repository-layer + archiva-database org.apache.archiva archiva-repository-scanner - - org.codehaus.plexus - plexus-taskqueue - org.codehaus.plexus plexus-quartz - org.codehaus.plexus - plexus-spring - test - - - org.codehaus.plexus - plexus-component-api - - - commons-lang - commons-lang - - - org.codehaus.plexus.registry - plexus-registry-api - - - org.sonatype.nexus - nexus-indexer + org.slf4j + slf4j-api - org.apache.archiva archiva-database-consumers test - hsqldb - hsqldb + org.codehaus.plexus + plexus-spring test - org.codehaus.plexus.registry - plexus-registry-commons + org.slf4j + slf4j-simple test - org.slf4j - slf4j-simple + hsqldb + hsqldb test diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java similarity index 98% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java index 090eeaa3b..fd3ba2ed0 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.repository; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -42,7 +42,6 @@ import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.RepositoryContentStatistics; import org.apache.maven.archiva.repository.events.RepositoryListener; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.taskqueue.Task; diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java similarity index 68% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java index e624b9884..e8a97557d 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled; +package org.apache.archiva.scheduler.repository; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -26,6 +26,7 @@ import java.util.List; import java.util.Set; import org.apache.archiva.repository.scanner.RepositoryScanStatistics; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.maven.archiva.common.ArchivaException; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationEvent; @@ -33,19 +34,13 @@ import org.apache.maven.archiva.configuration.ConfigurationListener; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics; -import org.apache.maven.archiva.scheduled.tasks.ArtifactIndexingTask; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; import org.codehaus.plexus.scheduler.CronExpressionValidator; import org.codehaus.plexus.scheduler.Scheduler; -import org.codehaus.plexus.taskqueue.Task; import org.codehaus.plexus.taskqueue.TaskQueue; import org.codehaus.plexus.taskqueue.TaskQueueException; -import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; import org.quartz.CronTrigger; import org.quartz.JobDataMap; import org.quartz.JobDetail; @@ -56,49 +51,33 @@ import org.slf4j.LoggerFactory; /** * Default implementation of a scheduling component for archiva. * - * @plexus.component role="org.apache.maven.archiva.scheduled.ArchivaTaskScheduler" role-hint="default" + * @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository" */ -public class DefaultArchivaTaskScheduler - implements ArchivaTaskScheduler, Startable, ConfigurationListener +public class RepositoryArchivaTaskScheduler + implements ArchivaTaskScheduler, Startable, ConfigurationListener { - private Logger log = LoggerFactory.getLogger( DefaultArchivaTaskScheduler.class ); - + private Logger log = LoggerFactory.getLogger( RepositoryArchivaTaskScheduler.class ); + /** * @plexus.requirement */ private Scheduler scheduler; - /** - * @plexus.requirement role-hint="database-update" - */ - private TaskQueue databaseUpdateQueue; - /** * @plexus.requirement role-hint="repository-scanning" */ private TaskQueue repositoryScanningQueue; - - /** - * @plexus.requirement role-hint="indexing" - */ - private TaskQueue indexingQueue; /** * @plexus.requirement */ private ArchivaConfiguration archivaConfiguration; - + /** * @plexus.requirement role-hint="jdo" */ private ArchivaDAO dao; - private static final String DATABASE_SCAN_GROUP = "dbg"; - - private static final String DATABASE_JOB = "dbj"; - - private static final String DATABASE_JOB_TRIGGER = "dbt"; - private static final String REPOSITORY_SCAN_GROUP = "rg"; private static final String REPOSITORY_JOB = "rj"; @@ -112,7 +91,7 @@ public class DefaultArchivaTaskScheduler public static final String CRON_HOURLY = "0 0 * * * ?"; private Set jobs = new HashSet(); - + private List queuedRepos = new ArrayList(); public void startup() @@ -129,7 +108,7 @@ public class DefaultArchivaTaskScheduler throw new ArchivaException( e.getMessage(), e ); } } - + public void start() throws StartingException { @@ -143,15 +122,13 @@ public class DefaultArchivaTaskScheduler if ( repoConfig.isScanned() ) { scheduleRepositoryJobs( repoConfig ); - + if( !isPreviouslyScanned( repoConfig ) ) { queueInitialRepoScan( repoConfig ); } } } - - scheduleDatabaseJobs(); } catch ( SchedulerException e ) { @@ -164,8 +141,6 @@ public class DefaultArchivaTaskScheduler { try { - scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); - for ( String job : jobs ) { scheduler.unscheduleJob( job, REPOSITORY_SCAN_GROUP ); @@ -179,33 +154,13 @@ public class DefaultArchivaTaskScheduler } } - /** - * @see ArchivaTaskScheduler#scheduleDatabaseTasks() - */ - public void scheduleDatabaseTasks() - throws TaskExecutionException - { - try - { - scheduleDatabaseJobs(); - } - catch ( SchedulerException e ) - { - throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e ); - - } - } - - /** - * @see ArchivaTaskScheduler#isProcessingRepositoryTask(String) - */ @SuppressWarnings("unchecked") public boolean isProcessingRepositoryTask( String repositoryId ) { synchronized( repositoryScanningQueue ) { List queue = null; - + try { queue = repositoryScanningQueue.getQueueSnapshot(); @@ -214,7 +169,7 @@ public class DefaultArchivaTaskScheduler { // not possible with plexus-taskqueue implementation, ignore } - + for ( RepositoryTask queuedTask : queue ) { if ( queuedTask.getRepositoryId().equals( repositoryId ) ) @@ -225,17 +180,14 @@ public class DefaultArchivaTaskScheduler return false; } } - - /** - * @see ArchivaTaskScheduler#isProcessingIndexingTaskWithName(String) - */ + @SuppressWarnings("unchecked") private boolean isProcessingRepositoryTask( RepositoryTask task ) { synchronized( repositoryScanningQueue ) { List queue = null; - + try { queue = repositoryScanningQueue.getQueueSnapshot(); @@ -244,7 +196,7 @@ public class DefaultArchivaTaskScheduler { // not possible with plexus-taskqueue implementation, ignore } - + for ( RepositoryTask queuedTask : queue ) { if ( task.equals( queuedTask ) ) @@ -256,30 +208,7 @@ public class DefaultArchivaTaskScheduler } } - /** - * @see ArchivaTaskScheduler#isProcessingDatabaseTask() - */ - @SuppressWarnings("unchecked") - public boolean isProcessingDatabaseTask() - { - List queue = null; - - try - { - queue = databaseUpdateQueue.getQueueSnapshot(); - } - catch ( TaskQueueException e ) - { - // not possible with plexus-taskqueue implementation, ignore - } - - return !queue.isEmpty(); - } - - /** - * @see ArchivaTaskScheduler#queueRepositoryTask(RepositoryTask) - */ - public void queueRepositoryTask( RepositoryTask task ) + public void queueTask( RepositoryTask task ) throws TaskQueueException { synchronized ( repositoryScanningQueue ) @@ -296,39 +225,10 @@ public class DefaultArchivaTaskScheduler } } - /** - * @see ArchivaTaskScheduler#queueDatabaseTask(DatabaseTask) - */ - public void queueDatabaseTask( DatabaseTask task ) - throws TaskQueueException - { - databaseUpdateQueue.put( task ); - } - - /** - * @see ArchivaTaskScheduler#queueIndexingTask(ArtifactIndexingTask) - */ - public void queueIndexingTask( ArtifactIndexingTask task ) - throws TaskQueueException - { - indexingQueue.put( task ); - } - public void configurationEvent( ConfigurationEvent event ) { if ( event.getType() == ConfigurationEvent.SAVED ) { - try - { - scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); - - scheduleDatabaseJobs(); - } - catch ( SchedulerException e ) - { - log.error( "Error restarting the database scanning job after property change." ); - } - for ( String job : jobs ) { try @@ -360,7 +260,7 @@ public class DefaultArchivaTaskScheduler } } } - + @SuppressWarnings("unchecked") private boolean isPreviouslyScanned( ManagedRepositoryConfiguration repoConfig ) { @@ -374,12 +274,13 @@ public class DefaultArchivaTaskScheduler return false; } - + // MRM-848: Pre-configured repository initially appear to be empty private synchronized void queueInitialRepoScan( ManagedRepositoryConfiguration repoConfig ) { - String repoId = repoConfig.getId(); - RepositoryTask task = TaskCreator.createRepositoryTask( repoId ); + String repoId = repoConfig.getId(); + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repoId ); if ( !queuedRepos.contains( repoId ) ) { @@ -388,7 +289,7 @@ public class DefaultArchivaTaskScheduler try { queuedRepos.add( repoConfig.getId() ); - this.queueRepositoryTask( task ); + this.queueTask( task ); } catch ( TaskQueueException e ) { @@ -396,7 +297,7 @@ public class DefaultArchivaTaskScheduler } } } - + private synchronized void scheduleRepositoryJobs( ManagedRepositoryConfiguration repoConfig ) throws SchedulerException { @@ -405,7 +306,7 @@ public class DefaultArchivaTaskScheduler log.warn( "Skipping job, no cron expression for " + repoConfig.getId() ); return; } - + if ( !repoConfig.isScanned() ) { log.warn( "Skipping job, repository scannable has been disabled for " + repoConfig.getId() ); @@ -428,8 +329,8 @@ public class DefaultArchivaTaskScheduler new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class ); JobDataMap dataMap = new JobDataMap(); - dataMap.put( DefaultArchivaTaskScheduler.TASK_QUEUE, repositoryScanningQueue ); - dataMap.put( DefaultArchivaTaskScheduler.TASK_REPOSITORY, repoConfig.getId() ); + dataMap.put( TASK_QUEUE, repositoryScanningQueue ); + dataMap.put( TASK_REPOSITORY, repoConfig.getId() ); repositoryJob.setJobDataMap( dataMap ); try @@ -448,38 +349,4 @@ public class DefaultArchivaTaskScheduler } } - - private synchronized void scheduleDatabaseJobs() - throws SchedulerException - { - String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression(); - - // setup the unprocessed artifact job - JobDetail databaseJob = new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class ); - - JobDataMap dataMap = new JobDataMap(); - dataMap.put( TASK_QUEUE, databaseUpdateQueue ); - databaseJob.setJobDataMap( dataMap ); - - CronExpressionValidator cronValidator = new CronExpressionValidator(); - if ( !cronValidator.validate( cronString ) ) - { - log.warn( - "Cron expression [" + cronString + "] for database update is invalid. Defaulting to hourly." ); - cronString = CRON_HOURLY; - } - - try - { - CronTrigger trigger = new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_SCAN_GROUP, cronString ); - - scheduler.scheduleJob( databaseJob, trigger ); - } - catch ( ParseException e ) - { - log.error( - "ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() ); - } - - } -} +} \ No newline at end of file diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java similarity index 98% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java index 27dd5e787..94f55bee7 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.tasks; +package org.apache.archiva.scheduler.repository; import java.io.File; diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTaskJob.java similarity index 79% rename from archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTaskJob.java index e0c34ae2c..ab265a5ea 100644 --- a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTaskJob.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled; +package org.apache.archiva.scheduler.repository; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,8 +19,6 @@ package org.apache.maven.archiva.scheduled; * under the License. */ -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.codehaus.plexus.scheduler.AbstractJob; import org.codehaus.plexus.taskqueue.TaskQueue; import org.codehaus.plexus.taskqueue.TaskQueueException; @@ -46,10 +44,11 @@ public class RepositoryTaskJob JobDataMap dataMap = context.getJobDetail().getJobDataMap(); setJobDataMap( dataMap ); - TaskQueue taskQueue = (TaskQueue) dataMap.get( DefaultArchivaTaskScheduler.TASK_QUEUE ); + TaskQueue taskQueue = (TaskQueue) dataMap.get( RepositoryArchivaTaskScheduler.TASK_QUEUE ); - String repositoryId = (String) dataMap.get( DefaultArchivaTaskScheduler.TASK_REPOSITORY ); - RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId ); + String repositoryId = (String) dataMap.get( RepositoryArchivaTaskScheduler.TASK_REPOSITORY ); + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repositoryId ); try { diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..d472d5a56 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,63 @@ + + + + + + + + org.codehaus.plexus.taskqueue.TaskQueue + repository-scanning + org.codehaus.plexus.taskqueue.DefaultTaskQueue + plexus-configurable + + + + + + + + + + + + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor + repository-scanning + org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor + singleton + + + org.codehaus.plexus.taskqueue.execution.TaskExecutor + repository-scanning + + + org.codehaus.plexus.taskqueue.TaskQueue + repository-scanning + + + + repository-scanning + + + + diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java similarity index 98% rename from archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java index 103d53dd9..a79db2a81 100644 --- a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.scheduled.executors; +package org.apache.archiva.scheduler.repository; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -25,7 +25,6 @@ import java.util.Calendar; import java.util.List; import java.util.Map; import java.util.Properties; - import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; @@ -36,7 +35,6 @@ import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.RepositoryContentStatistics; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; import org.codehaus.plexus.jdo.JdoFactory; import org.codehaus.plexus.spring.PlexusInSpringTestCase; @@ -224,8 +222,8 @@ public class ArchivaRepositoryScanningTaskExecutorTest File newArtifactGroup = new File( repoDir, "org/apache/archiva"); - FileUtils.copyDirectoryStructure( new File( getBasedir(), "target/test-classes/test-repo/org/apache/archiva"), newArtifactGroup ); - + FileUtils.copyDirectoryStructure( new File( getBasedir(), "target/test-classes/test-repo/org/apache/archiva"), newArtifactGroup ); + // update last modified date new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/pom.xml" ).setLastModified( Calendar.getInstance().getTimeInMillis() + 1000 ); new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ).setLastModified( Calendar.getInstance().getTimeInMillis() + 1000 ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/org/apache/archiva/consumers/lucene/LuceneConsumersTest.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/maven-metadata.xml similarity index 74% rename from archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/org/apache/archiva/consumers/lucene/LuceneConsumersTest.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/maven-metadata.xml index 4b3f8e25b..b3baf545d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/org/apache/archiva/consumers/lucene/LuceneConsumersTest.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/maven-metadata.xml @@ -1,3 +1,4 @@ + - - - - org.apache.maven.archiva.database.ArchivaDAO - jdo - org.apache.archiva.consumers.lucene.stubs.ArchivaDAOStub - - - \ No newline at end of file + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 new file mode 100644 index 000000000..ef7483fad --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.md5 @@ -0,0 +1 @@ +d41d8cd98f00b204e9800998ecf8427e jdbc-2.0.jar \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 new file mode 100644 index 000000000..4bc014766 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 @@ -0,0 +1 @@ +da39a3ee5e6b4b0d3255bfef95601890afd80709 jdbc-2.0.jar \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml new file mode 100644 index 000000000..bb7570891 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml @@ -0,0 +1,30 @@ + + + + + javax.sql + jdbc + 2.0 + + + 2.0 + + + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom new file mode 100644 index 000000000..202a0a448 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + A + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 new file mode 100644 index 000000000..78a953bc5 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.md5 @@ -0,0 +1 @@ +bc479af1df809dbabb92e29548776b84 A-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 new file mode 100644 index 000000000..71d6233aa --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 @@ -0,0 +1 @@ +fbb4c97603c64f3915c88243e1ea49f1a238afa7 A-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 new file mode 100644 index 000000000..665059bc7 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 @@ -0,0 +1 @@ +fd4275a6811332d67075ffd879d13d4a A-1.0.war \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 new file mode 100644 index 000000000..c8494eb9d --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 @@ -0,0 +1 @@ +754133cd9c36adef86d35b96c0e96e11a9c6bfc9 A-1.0.war \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom new file mode 100644 index 000000000..fa5f8f6c8 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 new file mode 100644 index 000000000..2324bce0c --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.md5 @@ -0,0 +1 @@ +c543ad342d1de7a4352fc9b0f42067b8 B-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 new file mode 100644 index 000000000..d8d5abce7 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 @@ -0,0 +1 @@ +be06d04d5824859253abf423394dc85d24971ba8 B-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom new file mode 100644 index 000000000..c3034e820 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 2.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 new file mode 100644 index 000000000..4ddd22b82 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.md5 @@ -0,0 +1 @@ +1af6c812f02f24e1ba287647a6856cd5 B-2.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 new file mode 100644 index 000000000..95912764c --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 @@ -0,0 +1 @@ +5d49f821499ab061c97457b3e6512fd1624a3033 B-2.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom new file mode 100644 index 000000000..ae14cd7eb --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 new file mode 100644 index 000000000..d08745961 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.md5 @@ -0,0 +1 @@ +90f5c062bded5f794cd4ea9479b35173 C-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 new file mode 100644 index 000000000..fbe7bd338 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 @@ -0,0 +1 @@ +fcefa8220d30b7aa72a1b7422cc06336ca14bb6f C-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 new file mode 100644 index 000000000..4eb175498 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 @@ -0,0 +1 @@ +fd4275a6811332d67075ffd879d13d4a C-1.0.war \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 new file mode 100644 index 000000000..78e0b6eb7 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 @@ -0,0 +1 @@ +754133cd9c36adef86d35b96c0e96e11a9c6bfc9 C-1.0.war \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml new file mode 100644 index 000000000..8ce7fc7bb --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml @@ -0,0 +1,23 @@ + + + + + org.apache.maven + \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom new file mode 100644 index 000000000..12538e81a --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.testgroup + discovery + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 new file mode 100644 index 000000000..b163670f2 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.md5 @@ -0,0 +1 @@ +764dd493029133aff4c0f7cb4be2d9b7 discovery-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 new file mode 100644 index 000000000..dedf18ade --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 @@ -0,0 +1 @@ +a7aaf680caaf5bb971753e047c439f3fd4efa473 discovery-1.0.pom \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml new file mode 100644 index 000000000..8ee18048c --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml @@ -0,0 +1,25 @@ + + + + + org.apache.testgroup + discovery + 1.0 + \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml new file mode 100644 index 000000000..b024ef7ef --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.testgroup + discovery + \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/archiva-test.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/archiva-test.xml new file mode 100644 index 000000000..7721bb63e --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/archiva-test.xml @@ -0,0 +1,119 @@ + + + + + + + testRepo + Archiva Test Repository + ${basedir}/src/test/repositories/default-repository + default + true + false + true + 0 0 * * * ? + + + + + + + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + + indexable-content + + **/*.txt + **/*.TXT + **/*.block + **/*.config + **/*.pom + **/*.xml + **/*.xsd + **/*.dtd + **/*.tld + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + + + update-db-artifact + create-missing-checksums + update-db-repository-metadata + validate-checksum + validate-signature + index-content + auto-remove + auto-rename + + + update-db-bad-content + + + + + 0 0 * * * ? + + test-db-unprocessed + update-db-artifact + + + test-db-cleanup + + + + diff --git a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.xml similarity index 97% rename from archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.xml index 6a419f76a..183d77281 100644 --- a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.xml @@ -23,7 +23,7 @@ org.codehaus.plexus.taskqueue.execution.TaskExecutor test-repository-scanning - org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor + org.apache.archiva.scheduler.repository.ArchivaRepositoryScanningTaskExecutor diff --git a/archiva-modules/archiva-scheduled/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar diff --git a/archiva-modules/archiva-scheduled/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml similarity index 100% rename from archiva-modules/archiva-scheduled/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml rename to archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/test-repo/org/apache/archiva/archiva-index-methods-jar-test/1.0/pom.xml diff --git a/archiva-modules/archiva-scheduler/pom.xml b/archiva-modules/archiva-scheduler/pom.xml new file mode 100644 index 000000000..a08c13faf --- /dev/null +++ b/archiva-modules/archiva-scheduler/pom.xml @@ -0,0 +1,37 @@ + + + + + + org.apache.archiva + archiva-modules + 1.3-SNAPSHOT + + 4.0.0 + archiva-scheduler + pom + Archiva Base :: Scheduled Tasks + + archiva-scheduler-api + archiva-scheduler-indexing + archiva-scheduler-database + archiva-scheduler-repository + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 3ddb6f90b..a8f0f6e8b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -39,7 +39,11 @@ org.apache.archiva - archiva-scheduled + archiva-scheduler-repository + + + org.apache.archiva + archiva-scheduler-database org.apache.archiva diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java index 3bab1372b..f5155f136 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java @@ -32,8 +32,12 @@ import java.util.Date; import java.util.List; import java.util.TimeZone; +import com.opensymphony.xwork2.Preparable; +import com.opensymphony.xwork2.Validateable; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.common.utils.VersionComparator; @@ -58,18 +62,12 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; import org.apache.maven.archiva.repository.project.ProjectModelException; import org.apache.maven.archiva.repository.project.ProjectModelWriter; import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.apache.maven.archiva.security.AccessDeniedException; import org.apache.maven.archiva.security.ArchivaSecurityException; import org.apache.maven.archiva.security.PrincipalNotFoundException; import org.apache.maven.archiva.security.UserRepositories; import org.codehaus.plexus.taskqueue.TaskQueueException; -import com.opensymphony.xwork2.Preparable; -import com.opensymphony.xwork2.Validateable; - /** * Upload an artifact using Jakarta file upload in webwork. If set by the user a pom will also be generated. Metadata * will also be updated if one exists, otherwise it would be created. @@ -146,7 +144,7 @@ public class UploadAction private RepositoryContentFactory repositoryFactory; /** - * @plexus.requirement + * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository" */ private ArchivaTaskScheduler scheduler; @@ -617,11 +615,15 @@ public class UploadAction private void queueRepositoryTask( String repositoryId, File localFile ) { - RepositoryTask task = TaskCreator.createRepositoryTask( repositoryId, localFile, true, true ); + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repositoryId ); + task.setResourceFile( localFile ); + task.setUpdateRelatedArtifacts( true ); + task.setScanAll( true ); try { - scheduler.queueRepositoryTask( task ); + scheduler.queueTask( task ); } catch ( TaskQueueException e ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java index c6eb4cb7b..f4cab02be 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java @@ -19,11 +19,11 @@ package org.apache.maven.archiva.web.action.admin; * under the License. */ +import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; +import org.apache.archiva.scheduler.database.DatabaseTask; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.PlexusActionSupport; import org.codehaus.plexus.redback.rbac.Resource; @@ -42,9 +42,14 @@ public class SchedulerAction implements SecureAction { /** - * @plexus.requirement + * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository" */ - private ArchivaTaskScheduler taskScheduler; + private RepositoryArchivaTaskScheduler repositoryTaskScheduler; + + /** + * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database" + */ + private DatabaseArchivaTaskScheduler databaseTaskScheduler; private String repoid; @@ -58,9 +63,11 @@ public class SchedulerAction return SUCCESS; } - RepositoryTask task = TaskCreator.createRepositoryTask( repoid, scanAll ); - - if ( taskScheduler.isProcessingRepositoryTask( repoid ) ) + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repoid ); + task.setScanAll( scanAll ); + + if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) ) { addActionError( "Repository [" + repoid + "] task was already queued." ); } @@ -69,7 +76,7 @@ public class SchedulerAction try { addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." ); - taskScheduler.queueRepositoryTask( task ); + repositoryTaskScheduler.queueTask( task ); } catch ( TaskQueueException e ) { @@ -87,7 +94,7 @@ public class SchedulerAction log.info( "Queueing database task on request from user interface" ); DatabaseTask task = new DatabaseTask(); - if ( taskScheduler.isProcessingDatabaseTask() ) + if ( databaseTaskScheduler.isProcessingDatabaseTask() ) { addActionError( "Database task was already queued." ); } @@ -95,7 +102,7 @@ public class SchedulerAction { try { - taskScheduler.queueDatabaseTask( task ); + databaseTaskScheduler.queueTask( task ); addActionMessage( "Your request to update the database has been queued." ); } catch ( TaskQueueException e ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java index 9adf31458..fb3984362 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java @@ -22,8 +22,10 @@ package org.apache.maven.archiva.web.startup; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.maven.archiva.common.ArchivaException; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; import org.codehaus.plexus.spring.PlexusToSpringUtils; import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor; import org.springframework.context.ApplicationContext; @@ -32,28 +34,36 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; /** - * ArchivaStartup - the startup of all archiva features in a deterministic order. + * ArchivaStartup - the startup of all archiva features in a deterministic order. * * @version $Id$ */ public class ArchivaStartup implements ServletContextListener { - public void contextInitialized(ServletContextEvent contextEvent) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(contextEvent.getServletContext()); - - SecuritySynchronization securitySync = (SecuritySynchronization) wac.getBean(PlexusToSpringUtils.buildSpringId(SecuritySynchronization.class)); - ResolverFactoryInit resolverFactory = (ResolverFactoryInit) wac.getBean(PlexusToSpringUtils.buildSpringId(ResolverFactoryInit.class)); - ArchivaTaskScheduler taskScheduler = (ArchivaTaskScheduler) wac.getBean(PlexusToSpringUtils.buildSpringId(ArchivaTaskScheduler.class)); - wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "database-update")); - wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "repository-scanning")); - wac.getBean(PlexusToSpringUtils.buildSpringId(TaskQueueExecutor.class, "indexing")); + public void contextInitialized( ServletContextEvent contextEvent ) + { + WebApplicationContext wac = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + + SecuritySynchronization securitySync = + (SecuritySynchronization) wac.getBean( PlexusToSpringUtils.buildSpringId( SecuritySynchronization.class ) ); + ResolverFactoryInit resolverFactory = + (ResolverFactoryInit) wac.getBean( PlexusToSpringUtils.buildSpringId( ResolverFactoryInit.class ) ); + DatabaseArchivaTaskScheduler databaseTaskScheduler = (DatabaseArchivaTaskScheduler) wac.getBean( + PlexusToSpringUtils.buildSpringId( ArchivaTaskScheduler.class, "database" ) ); + RepositoryArchivaTaskScheduler repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) wac.getBean( + PlexusToSpringUtils.buildSpringId( ArchivaTaskScheduler.class, "repository" ) ); + wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "database-update" ) ); + wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "repository-scanning" ) ); + wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "indexing" ) ); try { securitySync.startup(); resolverFactory.startup(); - taskScheduler.startup(); + databaseTaskScheduler.startup(); + repositoryTaskScheduler.startup(); Banner.display(); } catch ( ArchivaException e ) @@ -62,12 +72,13 @@ public class ArchivaStartup } } - public void contextDestroyed(ServletContextEvent contextEvent) + public void contextDestroyed( ServletContextEvent contextEvent ) { - ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(contextEvent.getServletContext()); - if (applicationContext != null && applicationContext instanceof ClassPathXmlApplicationContext) + ApplicationContext applicationContext = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + if ( applicationContext != null && applicationContext instanceof ClassPathXmlApplicationContext ) { - ((ClassPathXmlApplicationContext)applicationContext).close(); + ( (ClassPathXmlApplicationContext) applicationContext ).close(); } } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java index f18aa17ff..0902a319a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java @@ -23,8 +23,10 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import com.opensymphony.xwork2.Action; import org.apache.archiva.checksum.ChecksumAlgorithm; import org.apache.archiva.checksum.ChecksummedFile; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; @@ -36,13 +38,10 @@ import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryNotFoundException; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; import org.apache.maven.archiva.repository.metadata.MetadataTools; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; -import com.opensymphony.xwork2.Action; - /** * UploadActionTest */ diff --git a/archiva-modules/archiva-web/archiva-webdav/pom.xml b/archiva-modules/archiva-web/archiva-webdav/pom.xml index 2a963b1e6..95341522e 100644 --- a/archiva-modules/archiva-web/archiva-webdav/pom.xml +++ b/archiva-modules/archiva-web/archiva-webdav/pom.xml @@ -42,10 +42,6 @@ org.apache.archiva archiva-repository-layer - - org.apache.archiva - archiva-scheduled - org.apache.archiva archiva-proxy diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java index 113aba0e5..eff87127e 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java @@ -25,9 +25,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; - import javax.servlet.http.HttpServletResponse; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.util.Text; @@ -56,9 +58,6 @@ import org.apache.jackrabbit.webdav.property.ResourceType; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.repository.audit.AuditEvent; import org.apache.maven.archiva.repository.audit.AuditListener; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.apache.maven.archiva.webdav.util.IndexWriter; import org.apache.maven.archiva.webdav.util.MimeTypes; import org.codehaus.plexus.taskqueue.TaskQueueException; @@ -108,7 +107,7 @@ public class ArchivaDavResource public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository, DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory, MimeTypes mimeTypes, List auditListeners, - ArchivaTaskScheduler scheduler ) + RepositoryArchivaTaskScheduler scheduler ) { this.localResource = new File( localResource ); this.logicalResource = logicalResource; @@ -128,7 +127,7 @@ public class ArchivaDavResource public ArchivaDavResource( String localResource, String logicalResource, ManagedRepositoryConfiguration repository, String remoteAddr, String principal, DavSession session, ArchivaDavResourceLocator locator, DavResourceFactory factory, MimeTypes mimeTypes, List auditListeners, - ArchivaTaskScheduler scheduler ) + RepositoryArchivaTaskScheduler scheduler ) { this( localResource, logicalResource, repository, session, locator, factory, mimeTypes, auditListeners, scheduler ); @@ -645,11 +644,15 @@ public class ArchivaDavResource private void queueRepositoryTask( File localFile ) { - RepositoryTask task = TaskCreator.createRepositoryTask( repository.getId(), localFile, false, true ); - + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repository.getId() ); + task.setResourceFile( localFile ); + task.setUpdateRelatedArtifacts( false ); + task.setScanAll( true ); + try { - scheduler.queueRepositoryTask( task ); + scheduler.queueTask( task ); } catch ( TaskQueueException e ) { diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index 89c271238..ba7915913 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.jackrabbit.webdav.DavException; @@ -60,7 +61,6 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataMerge; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; -import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; import org.apache.maven.archiva.security.ServletAuthenticator; import org.apache.maven.archiva.webdav.util.MimeTypes; import org.apache.maven.archiva.webdav.util.RepositoryPathUtil; @@ -164,9 +164,9 @@ public class ArchivaDavResourceFactory private Digester digestMd5; /** - * @plexus.requirement + * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository" */ - private ArchivaTaskScheduler scheduler; + private RepositoryArchivaTaskScheduler scheduler; public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request, final DavServletResponse response ) @@ -1068,7 +1068,7 @@ public class ArchivaDavResourceFactory this.httpAuth = httpAuth; } - public void setScheduler( ArchivaTaskScheduler scheduler ) + public void setScheduler( RepositoryArchivaTaskScheduler scheduler ) { this.scheduler = scheduler; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml index a370ddb5f..520a10d36 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.xml @@ -149,7 +149,8 @@ digestMd5 - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml index 71c3c0f41..78bdb75ab 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/resources/org/apache/maven/archiva/webdav/RepositoryServletTest.xml @@ -161,7 +161,8 @@ digestMd5 - org.apache.maven.archiva.scheduled.ArchivaTaskScheduler + org.apache.archiva.scheduler.ArchivaTaskScheduler + repository scheduler diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml index 71f5e2638..d960bdab9 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml @@ -52,7 +52,15 @@ org.apache.archiva - archiva-scheduled + archiva-repository-scanner + + + org.apache.archiva + archiva-scheduler-repository + + + org.apache.archiva + archiva-scheduler-database org.apache.archiva diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index 8493e309a..c2aceb607 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -24,6 +24,10 @@ import java.util.Collection; import java.util.List; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; +import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; +import org.apache.archiva.scheduler.database.DatabaseTask; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.archiva.web.xmlrpc.api.AdministrationService; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; @@ -49,41 +53,40 @@ import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryException; 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.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; -import org.apache.maven.archiva.scheduled.tasks.TaskCreator; import org.codehaus.plexus.registry.RegistryException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * AdministrationServiceImpl - * + * * @version $Id: AdministrationServiceImpl.java */ public class AdministrationServiceImpl implements AdministrationService -{ +{ protected Logger log = LoggerFactory.getLogger( getClass() ); private ArchivaConfiguration archivaConfiguration; - + private RepositoryContentConsumers repoConsumersUtil; - + private DatabaseConsumers dbConsumersUtil; - + private RepositoryContentFactory repoFactory; - + private ArtifactDAO artifactDAO; - - private ArchivaTaskScheduler taskScheduler; - + + private DatabaseArchivaTaskScheduler databaseTaskScheduler; + + private RepositoryArchivaTaskScheduler repositoryTaskScheduler; + private Collection listeners; public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, - ArtifactDAO artifactDAO, ArchivaTaskScheduler taskScheduler, + ArtifactDAO artifactDAO, DatabaseArchivaTaskScheduler databaseTaskScheduler, + RepositoryArchivaTaskScheduler repositoryTaskScheduler, Collection listeners ) { this.archivaConfiguration = archivaConfig; @@ -91,10 +94,11 @@ public class AdministrationServiceImpl this.dbConsumersUtil = dbConsumersUtil; this.repoFactory = repoFactory; this.artifactDAO = artifactDAO; - this.taskScheduler = taskScheduler; + this.databaseTaskScheduler = databaseTaskScheduler; + this.repositoryTaskScheduler = repositoryTaskScheduler; this.listeners = listeners; } - + /** * @see AdministrationService#configureDatabaseConsumer(String, boolean) */ @@ -102,9 +106,9 @@ public class AdministrationServiceImpl { List unprocessedConsumers = dbConsumersUtil.getAvailableUnprocessedConsumers(); - + boolean found = false; - + for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) { if( consumer.getId().equals( consumerId ) ) @@ -113,20 +117,20 @@ public class AdministrationServiceImpl break; } } - + if( !found ) { throw new Exception( "Invalid database consumer." ); } - + Configuration config = archivaConfiguration.getConfiguration(); DatabaseScanningConfiguration dbScanningConfig = config.getDatabaseScanning(); - + dbScanningConfig.addUnprocessedConsumer( consumerId ); - - config.setDatabaseScanning( dbScanningConfig ); + + config.setDatabaseScanning( dbScanningConfig ); saveConfiguration( config ); - + return new Boolean( true ); } @@ -137,10 +141,10 @@ public class AdministrationServiceImpl throws Exception { // TODO use repoId once consumers are configured per repository! (MRM-930) - + List knownConsumers = repoConsumersUtil.getAvailableKnownConsumers(); List invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers(); - + boolean found = false; boolean isKnownContentConsumer = false; for( KnownRepositoryContentConsumer consumer : knownConsumers ) @@ -152,7 +156,7 @@ public class AdministrationServiceImpl break; } } - + if( !found ) { for( InvalidRepositoryContentConsumer consumer : invalidConsumers ) @@ -164,15 +168,15 @@ public class AdministrationServiceImpl } } } - + if( !found ) { throw new Exception( "Invalid repository consumer." ); } - + Configuration config = archivaConfiguration.getConfiguration(); RepositoryScanningConfiguration repoScanningConfig = config.getRepositoryScanning(); - + if( isKnownContentConsumer ) { repoScanningConfig.addKnownContentConsumer( consumerId ); @@ -181,13 +185,13 @@ public class AdministrationServiceImpl { repoScanningConfig.addInvalidContentConsumer( consumerId ); } - - config.setRepositoryScanning( repoScanningConfig ); + + config.setRepositoryScanning( repoScanningConfig ); saveConfiguration( config ); - + return new Boolean( true ); } - + /** * @see AdministrationService#deleteArtifact(String, String, String, String) */ @@ -196,26 +200,26 @@ public class AdministrationServiceImpl { Configuration config = archivaConfiguration.getConfiguration(); ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId ); - + if( repoConfig == null ) { throw new Exception( "Repository does not exist." ); } - + try { - ManagedRepositoryContent repoContent = repoFactory.getManagedRepositoryContent( repoId ); + ManagedRepositoryContent repoContent = repoFactory.getManagedRepositoryContent( repoId ); VersionedReference ref = new VersionedReference(); ref.setGroupId( groupId ); ref.setArtifactId( artifactId ); ref.setVersion( version ); - + // delete from file system repoContent.deleteVersion( ref ); - + ArtifactVersionsConstraint constraint = new ArtifactVersionsConstraint( repoId, groupId, artifactId, false ); List artifacts = null; - + try { artifacts = artifactDAO.queryArtifacts( constraint ); @@ -223,8 +227,8 @@ public class AdministrationServiceImpl catch ( ArchivaDatabaseException e ) { throw new Exception( "Error occurred while cleaning up database." ); - } - + } + if ( artifacts != null ) { for ( ArchivaArtifact artifact : artifacts ) @@ -251,7 +255,7 @@ public class AdministrationServiceImpl { throw new Exception( "Repository exception occurred." ); } - + return new Boolean( true ); } @@ -260,16 +264,16 @@ public class AdministrationServiceImpl */ public Boolean executeDatabaseScanner() throws Exception { - if ( taskScheduler.isProcessingDatabaseTask() ) + if ( databaseTaskScheduler.isProcessingDatabaseTask() ) { return false; } log.info( "Queueing database task on request from administration service" ); DatabaseTask task = new DatabaseTask(); - - taskScheduler.queueDatabaseTask( task ); - + + databaseTaskScheduler.queueTask( task ); + return new Boolean( true ); } @@ -283,16 +287,17 @@ public class AdministrationServiceImpl { throw new Exception( "Repository does not exist." ); } - - if ( taskScheduler.isProcessingRepositoryTask( repoId ) ) + + if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoId ) ) { return false; } - RepositoryTask task = TaskCreator.createRepositoryTask( repoId ); + RepositoryTask task = new RepositoryTask(); + task.setRepositoryId( repoId ); + + repositoryTaskScheduler.queueTask( task ); - taskScheduler.queueRepositoryTask( task ); - return new Boolean( true ); } @@ -302,14 +307,14 @@ public class AdministrationServiceImpl public List getAllDatabaseConsumers() { List consumers = new ArrayList(); - + List unprocessedConsumers = dbConsumersUtil.getAvailableUnprocessedConsumers(); - + for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) { consumers.add( consumer.getId() ); - } - + } + return consumers; } @@ -319,15 +324,15 @@ public class AdministrationServiceImpl public List getAllRepositoryConsumers() { List consumers = new ArrayList(); - + List knownConsumers = repoConsumersUtil.getAvailableKnownConsumers(); List invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers(); - + for( KnownRepositoryContentConsumer consumer : knownConsumers ) { consumers.add( consumer.getId() ); } - + for( InvalidRepositoryContentConsumer consumer : invalidConsumers ) { consumers.add( consumer.getId() ); @@ -342,19 +347,19 @@ public class AdministrationServiceImpl public List getAllManagedRepositories() { List managedRepos = new ArrayList(); - + Configuration config = archivaConfiguration.getConfiguration(); List managedRepoConfigs = config.getManagedRepositories(); - + for( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs ) { // TODO fix resolution of repo url! ManagedRepository repo = new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", repoConfig.getLayout(), - repoConfig.isSnapshots(), repoConfig.isReleases() ); + repoConfig.isSnapshots(), repoConfig.isReleases() ); managedRepos.add( repo ); } - + return managedRepos; } @@ -364,10 +369,10 @@ public class AdministrationServiceImpl public List getAllRemoteRepositories() { List remoteRepos = new ArrayList(); - + Configuration config = archivaConfiguration.getConfiguration(); List remoteRepoConfigs = config.getRemoteRepositories(); - + for( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs ) { RemoteRepository repo = @@ -375,7 +380,7 @@ public class AdministrationServiceImpl repoConfig.getLayout() ); remoteRepos.add( repo ); } - + return remoteRepos; } @@ -392,7 +397,7 @@ public class AdministrationServiceImpl } catch ( IndeterminateConfigurationException e ) { - throw new Exception( "Error occurred while saving the configuration." ); + throw new Exception( "Error occurred while saving the configuration." ); } } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index 04946b4ec..022f35cc9 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -26,6 +26,10 @@ import java.util.Collections; import java.util.List; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; +import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; +import org.apache.archiva.scheduler.database.DatabaseTask; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; import org.apache.commons.io.FileUtils; @@ -51,9 +55,6 @@ import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryConten 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.scheduled.ArchivaTaskScheduler; -import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; -import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; @@ -76,10 +77,14 @@ public class AdministrationServiceImplTest private AdministrationServiceImpl service; - private MockControl taskSchedulerControl; + private MockControl repositoryTaskSchedulerControl; + + private MockControl databaseTaskSchedulerControl; - private ArchivaTaskScheduler taskScheduler; + private RepositoryArchivaTaskScheduler repositoryTaskScheduler; + private DatabaseArchivaTaskScheduler databaseTaskScheduler; + // repository consumers private MockControl repoConsumerUtilsControl; @@ -134,9 +139,12 @@ public class AdministrationServiceImplTest configControl = MockClassControl.createControl( Configuration.class ); config = ( Configuration ) configControl.getMock(); - taskSchedulerControl = MockControl.createControl( ArchivaTaskScheduler.class ); - taskScheduler = ( ArchivaTaskScheduler ) taskSchedulerControl.getMock(); + databaseTaskSchedulerControl = MockClassControl.createControl( DatabaseArchivaTaskScheduler.class ); + databaseTaskScheduler = (DatabaseArchivaTaskScheduler) databaseTaskSchedulerControl.getMock(); + repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class ); + repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock(); + // repo consumers repoConsumerUtilsControl = MockClassControl.createControl( RepositoryContentConsumers.class ); repoConsumersUtil = ( RepositoryContentConsumers ) repoConsumerUtilsControl.getMock(); @@ -169,7 +177,8 @@ public class AdministrationServiceImplTest service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, repositoryFactory, - artifactDao, taskScheduler, Collections.singletonList( listener ) ); + artifactDao, databaseTaskScheduler, repositoryTaskScheduler, + Collections.singletonList( listener ) ); } /* Tests for database consumers */ @@ -622,15 +631,15 @@ public class AdministrationServiceImplTest RepositoryTask task = new RepositoryTask(); - taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), false ); + repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), false ); - taskScheduler.queueRepositoryTask( task ); - taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); - taskSchedulerControl.setVoidCallable(); + repositoryTaskScheduler.queueTask( task ); + repositoryTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); + repositoryTaskSchedulerControl.setVoidCallable(); archivaConfigControl.replay(); configControl.replay(); - taskSchedulerControl.replay(); + repositoryTaskSchedulerControl.replay(); try { @@ -644,7 +653,7 @@ public class AdministrationServiceImplTest archivaConfigControl.verify(); configControl.verify(); - taskSchedulerControl.verify(); + repositoryTaskSchedulerControl.verify(); } public void testExecuteRepoScannerRepoExistsButBeingScanned() @@ -654,11 +663,11 @@ public class AdministrationServiceImplTest configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); - taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), true); + repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), true); archivaConfigControl.replay(); configControl.replay(); - taskSchedulerControl.replay(); + repositoryTaskSchedulerControl.replay(); try { @@ -672,7 +681,7 @@ public class AdministrationServiceImplTest archivaConfigControl.verify(); configControl.verify(); - taskSchedulerControl.verify(); + repositoryTaskSchedulerControl.verify(); } public void testExecuteRepoScannerRepoDoesNotExist() @@ -705,17 +714,17 @@ public class AdministrationServiceImplTest { DatabaseTask task = new DatabaseTask(); - taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingDatabaseTask(), false ); + databaseTaskSchedulerControl.expectAndReturn( databaseTaskScheduler.isProcessingDatabaseTask(), false ); - taskScheduler.queueDatabaseTask( task ); - taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); - taskSchedulerControl.setVoidCallable(); + databaseTaskScheduler.queueTask( task ); + databaseTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); + databaseTaskSchedulerControl.setVoidCallable(); - taskSchedulerControl.replay(); + databaseTaskSchedulerControl.replay(); boolean success = service.executeDatabaseScanner(); - taskSchedulerControl.verify(); + databaseTaskSchedulerControl.verify(); assertTrue( success ); } @@ -723,13 +732,13 @@ public class AdministrationServiceImplTest public void testExecuteDbScannerDbIsBeingScanned() throws Exception { - taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingDatabaseTask(), true ); + databaseTaskSchedulerControl.expectAndReturn( databaseTaskScheduler.isProcessingDatabaseTask(), true ); - taskSchedulerControl.replay(); + databaseTaskSchedulerControl.replay(); boolean success = service.executeDatabaseScanner(); - taskSchedulerControl.verify(); + databaseTaskSchedulerControl.verify(); assertFalse( success ); } diff --git a/archiva-modules/pom.xml b/archiva-modules/pom.xml index 5ce96c5ea..226b3a880 100644 --- a/archiva-modules/pom.xml +++ b/archiva-modules/pom.xml @@ -31,7 +31,7 @@ archiva-base archiva-database archiva-reporting - archiva-scheduled + archiva-scheduler archiva-web metadata plugins diff --git a/pom.xml b/pom.xml index 45d75db9d..5d647b7f7 100644 --- a/pom.xml +++ b/pom.xml @@ -405,7 +405,22 @@ org.apache.archiva - archiva-scheduled + archiva-scheduler-api + 1.3-SNAPSHOT + + + org.apache.archiva + archiva-scheduler-repository + 1.3-SNAPSHOT + + + org.apache.archiva + archiva-scheduler-database + 1.3-SNAPSHOT + + + org.apache.archiva + archiva-scheduler-indexing 1.3-SNAPSHOT -- 2.39.5