diff options
author | Brett Porter <brett@apache.org> | 2008-03-29 03:09:22 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2008-03-29 03:09:22 +0000 |
commit | a05f42cc0ec53b094ddd64661579374792a55231 (patch) | |
tree | 32274f5d8286676016f357caf10dce8be975f28e /archiva-modules/archiva-scheduled | |
parent | ed0fa81292f6aaca377638a3fbf5b80cef029452 (diff) | |
download | archiva-a05f42cc0ec53b094ddd64661579374792a55231.tar.gz archiva-a05f42cc0ec53b094ddd64661579374792a55231.zip |
restructure according to discussion on the dev list
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@642497 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-scheduled')
51 files changed, 2583 insertions, 0 deletions
diff --git a/archiva-modules/archiva-scheduled/pom.xml b/archiva-modules/archiva-scheduled/pom.xml new file mode 100644 index 000000000..ce3ab02ff --- /dev/null +++ b/archiva-modules/archiva-scheduled/pom.xml @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-modules</artifactId> + <version>1.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>archiva-scheduled</artifactId> + <version>1.1-SNAPSHOT</version> + <name>Archiva Base :: Scheduled Tasks</name> + <dependencies> + <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-configuration</artifactId> + </dependency> + <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-database</artifactId> + </dependency> + <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-repository-layer</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-taskqueue</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-quartz</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-api</artifactId> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-container-default</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.plexus.registry</groupId> + <artifactId>plexus-registry-api</artifactId> + </dependency> + <!-- Test Dependencies --> + <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-database-consumers</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>hsqldb</groupId> + <artifactId>hsqldb</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.codehaus.plexus.registry</groupId> + <artifactId>plexus-registry-commons</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-slf4j-logging</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-maven-plugin</artifactId> + <executions> + <execution> + <id>merge</id> + <goals> + <goal>merge-descriptors</goal> + </goals> + <configuration> + <descriptors> + <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor> + <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> 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 new file mode 100644 index 000000000..70478a591 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/ArchivaTaskScheduler.java @@ -0,0 +1,60 @@ +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.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. + * + * @author <a href="mailto:brett@apache.org">Brett Porter</a> + */ +public interface ArchivaTaskScheduler +{ + /** + * The Plexus component role. + */ + public final static String ROLE = ArchivaTaskScheduler.class.getName(); + + public boolean isProcessingAnyRepositoryTask() + throws ArchivaException; + + public boolean isProcessingDatabaseTask() + throws ArchivaException; + + public boolean isProcessingRepositoryTask( String repositoryId ) + throws ArchivaException; + + public void queueDatabaseTask( DatabaseTask task ) + throws TaskQueueException; + + public void queueRepositoryTask( RepositoryTask task ) + throws TaskQueueException; + + 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/DatabaseTaskJob.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java new file mode 100644 index 000000000..ede35a8f6 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DatabaseTaskJob.java @@ -0,0 +1,85 @@ +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.scheduled.tasks.ArchivaTask; +import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; +import org.codehaus.plexus.scheduler.AbstractJob; +import org.codehaus.plexus.taskqueue.TaskQueue; +import org.codehaus.plexus.taskqueue.TaskQueueException; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * This class is the database job that is executed by the scheduler. + */ +public class DatabaseTaskJob + extends AbstractJob +{ + static final String TASK_KEY = "EXECUTION"; + + static final String TASK_QUEUE = "TASK_QUEUE"; + + static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY"; + + /** + * Execute the discoverer and the indexer. + * + * @param context + * @throws org.quartz.JobExecutionException + * + */ + public void execute( JobExecutionContext context ) + throws JobExecutionException + { + JobDataMap dataMap = context.getJobDetail().getJobDataMap(); + setJobDataMap( dataMap ); + + TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE ); + String queuePolicy = (String) dataMap.get( TASK_QUEUE_POLICY ); + + ArchivaTask task = new DatabaseTask(); + task.setName( context.getJobDetail().getName() ); + + try + { + if ( taskQueue.getQueueSnapshot().size() == 0 ) + { + taskQueue.put( task ); + } + else + { + if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) ) + { + taskQueue.put( task ); + } + else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) ) + { + // do not queue anymore, policy is to skip + } + } + } + catch ( TaskQueueException e ) + { + throw new JobExecutionException( e ); + } + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java new file mode 100644 index 000000000..fd3fd0901 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/DefaultArchivaTaskScheduler.java @@ -0,0 +1,364 @@ +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.commons.collections.CollectionUtils; +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.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.scheduled.tasks.ArchivaTask; +import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTaskSelectionPredicate; +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; + +import java.text.ParseException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Default implementation of a scheduling component for archiva. + * + * @author <a href="mailto:brett@apache.org">Brett Porter</a> + * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a> + * @plexus.component role="org.apache.maven.archiva.scheduled.ArchivaTaskScheduler" role-hint="default" + */ +public class DefaultArchivaTaskScheduler + implements ArchivaTaskScheduler, Startable, ConfigurationListener +{ + private Logger log = LoggerFactory.getLogger( DefaultArchivaTaskScheduler.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 + */ + private ArchivaConfiguration archivaConfiguration; + + public static final String DATABASE_SCAN_GROUP = "database-group"; + + public static final String DATABASE_JOB = "database-job"; + + public static final String DATABASE_JOB_TRIGGER = "database-job-trigger"; + + public static final String REPOSITORY_SCAN_GROUP = "repository-group"; + + public static final String REPOSITORY_JOB = "repository-job"; + + public static final String REPOSITORY_JOB_TRIGGER = "repository-job-trigger"; + + public static final String CRON_HOURLY = "0 0 * * * ?"; + + private Set<String> jobs = new HashSet<String>(); + + 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 + { + List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration() + .getManagedRepositories(); + + for ( ManagedRepositoryConfiguration repoConfig : repositories ) + { + if ( repoConfig.isScanned() ) + { + scheduleRepositoryJobs( repoConfig ); + } + } + + scheduleDatabaseJobs(); + } + catch ( SchedulerException e ) + { + throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e ); + } + } + + private synchronized void scheduleRepositoryJobs( ManagedRepositoryConfiguration repoConfig ) + throws SchedulerException + { + if ( repoConfig.getRefreshCronExpression() == null ) + { + log.warn( "Skipping job, no cron expression for " + repoConfig.getId() ); + return; + } + + // get the cron string for these database scanning jobs + String cronString = repoConfig.getRefreshCronExpression(); + + CronExpressionValidator cronValidator = new CronExpressionValidator(); + if ( !cronValidator.validate( cronString ) ) + { + log.warn( "Cron expression [" + cronString + "] for repository [" + repoConfig.getId() + + "] is invalid. Defaulting to hourly." ); + cronString = CRON_HOURLY; + } + + // setup the unprocessed artifact job + JobDetail repositoryJob = + new JobDetail( REPOSITORY_JOB + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, RepositoryTaskJob.class ); + + JobDataMap dataMap = new JobDataMap(); + dataMap.put( RepositoryTaskJob.TASK_QUEUE, repositoryScanningQueue ); + dataMap.put( RepositoryTaskJob.TASK_QUEUE_POLICY, ArchivaTask.QUEUE_POLICY_WAIT ); + dataMap.put( RepositoryTaskJob.TASK_REPOSITORY, repoConfig.getId() ); + repositoryJob.setJobDataMap( dataMap ); + + try + { + CronTrigger trigger = + new CronTrigger( REPOSITORY_JOB_TRIGGER + ":" + repoConfig.getId(), REPOSITORY_SCAN_GROUP, cronString ); + + jobs.add( REPOSITORY_JOB + ":" + repoConfig.getId() ); + scheduler.scheduleJob( repositoryJob, trigger ); + } + catch ( ParseException e ) + { + log.error( + "ParseException in repository scanning cron expression, disabling repository scanning for '" + + repoConfig.getId() + "': " + e.getMessage() ); + } + + } + + 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( DatabaseTaskJob.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() ); + } + + } + + public void stop() + throws StoppingException + { + try + { + scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); + + for ( String job : jobs ) + { + scheduler.unscheduleJob( job, REPOSITORY_SCAN_GROUP ); + } + jobs.clear(); + } + 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 ); + + } + } + + public boolean isProcessingAnyRepositoryTask() + throws ArchivaException + { + List<? extends Task> queue = null; + + try + { + queue = repositoryScanningQueue.getQueueSnapshot(); + } + catch ( TaskQueueException e ) + { + throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e ); + } + + return !queue.isEmpty(); + } + + public boolean isProcessingRepositoryTask( String repositoryId ) + throws ArchivaException + { + List<? extends Task> queue = null; + + try + { + queue = repositoryScanningQueue.getQueueSnapshot(); + } + catch ( TaskQueueException e ) + { + throw new ArchivaException( "Unable to get repository scanning queue:" + e.getMessage(), e ); + } + + return CollectionUtils.exists( queue, new RepositoryTaskSelectionPredicate( repositoryId ) ); + } + + public boolean isProcessingDatabaseTask() + throws ArchivaException + { + List<? extends Task> queue = null; + + try + { + queue = databaseUpdateQueue.getQueueSnapshot(); + } + catch ( TaskQueueException e ) + { + throw new ArchivaException( "Unable to get database update queue:" + e.getMessage(), e ); + } + + return !queue.isEmpty(); + } + + public void queueRepositoryTask( RepositoryTask task ) + throws TaskQueueException + { + repositoryScanningQueue.put( task ); + } + + public void queueDatabaseTask( 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." ); + } + + for ( String job : jobs ) + { + try + { + scheduler.unscheduleJob( job, REPOSITORY_SCAN_GROUP ); + } + catch ( SchedulerException e ) + { + log.error( "Error restarting the repository scanning job after property change." ); + } + } + jobs.clear(); + + List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration() + .getManagedRepositories(); + + for ( ManagedRepositoryConfiguration repoConfig : repositories ) + { + if ( repoConfig.getRefreshCronExpression() != null ) + { + try + { + scheduleRepositoryJobs( repoConfig ); + } + catch ( SchedulerException e ) + { + log.error( "error restarting job: " + REPOSITORY_JOB + ":" + repoConfig.getId() ); + } + } + } + } + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java new file mode 100644 index 000000000..e71d084fa --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/RepositoryTaskJob.java @@ -0,0 +1,88 @@ +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.scheduled.tasks.ArchivaTask; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.codehaus.plexus.scheduler.AbstractJob; +import org.codehaus.plexus.taskqueue.TaskQueue; +import org.codehaus.plexus.taskqueue.TaskQueueException; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +/** + * This class is the repository job that is executed by the scheduler. + */ +public class RepositoryTaskJob + extends AbstractJob +{ + static final String TASK_KEY = "EXECUTION"; + + static final String TASK_QUEUE = "TASK_QUEUE"; + + static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY"; + + static final String TASK_REPOSITORY = "TASK_REPOSITORY"; + + /** + * Execute the discoverer and the indexer. + * + * @param context + * @throws org.quartz.JobExecutionException + * + */ + public void execute( JobExecutionContext context ) + throws JobExecutionException + { + JobDataMap dataMap = context.getJobDetail().getJobDataMap(); + setJobDataMap( dataMap ); + + TaskQueue taskQueue = (TaskQueue) dataMap.get( TASK_QUEUE ); + String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString(); + + RepositoryTask task = new RepositoryTask(); + task.setName( context.getJobDetail().getName() ); + task.setRepositoryId( (String) dataMap.get( TASK_REPOSITORY ) ); + + try + { + if ( taskQueue.getQueueSnapshot().size() == 0 ) + { + taskQueue.put( task ); + } + else + { + if ( ArchivaTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) ) + { + taskQueue.put( task ); + } + else if ( ArchivaTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) ) + { + // do not queue anymore, policy is to skip + } + } + } + catch ( TaskQueueException e ) + { + throw new JobExecutionException( e ); + } + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java new file mode 100644 index 000000000..2c764ce12 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutor.java @@ -0,0 +1,91 @@ +package org.apache.maven.archiva.scheduled.executors; + +/* + * 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.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; +import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * ArchivaDatabaseTaskExecutor + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + * + * @plexus.component + * role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" + * role-hint="database-update" + */ +public class ArchivaDatabaseUpdateTaskExecutor + implements TaskExecutor, Initializable +{ + private Logger log = LoggerFactory.getLogger( ArchivaDatabaseUpdateTaskExecutor.class ); + + /** + * @plexus.requirement role-hint="jdo" + */ + private DatabaseUpdater databaseUpdater; + + public void initialize() + throws InitializationException + { + log.info( "Initialized " + this.getClass().getName() ); + } + + public void executeTask( Task task ) + throws TaskExecutionException + { + DatabaseTask dbtask = (DatabaseTask) task; + + log.info( "Executing task from queue with job name: " + dbtask.getName() ); + long time = System.currentTimeMillis(); + + try + { + log.info( "Task: Updating unprocessed artifacts" ); + databaseUpdater.updateAllUnprocessed(); + } + catch ( ArchivaDatabaseException e ) + { + throw new TaskExecutionException( "Error running unprocessed updater", e ); + } + + try + { + log.info( "Task: Updating processed artifacts" ); + databaseUpdater.updateAllProcessed(); + } + catch ( ArchivaDatabaseException e ) + { + throw new TaskExecutionException( "Error running processed updater", e ); + } + + time = System.currentTimeMillis() - time; + + log.info( "Finished database task in " + time + "ms." ); + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java new file mode 100644 index 000000000..527ee34fc --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java @@ -0,0 +1,130 @@ +package org.apache.maven.archiva.scheduled.executors; + +/* + * 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.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics; +import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.repository.RepositoryException; +import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics; +import org.apache.maven.archiva.repository.scanner.RepositoryScanner; +import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.codehaus.plexus.taskqueue.Task; +import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * ArchivaRepositoryScanningTaskExecutor + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + * + * @plexus.component + * role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" + * role-hint="repository-scanning" + */ +public class ArchivaRepositoryScanningTaskExecutor + implements TaskExecutor, Initializable +{ + private Logger log = LoggerFactory.getLogger( ArchivaRepositoryScanningTaskExecutor.class ); + + /** + * @plexus.requirement role-hint="jdo" + */ + private ArchivaDAO dao; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + /** + * The repository scanner component. + * + * @plexus.requirement + */ + private RepositoryScanner repoScanner; + + public void initialize() + throws InitializationException + { + log.info( "Initialized " + this.getClass().getName() ); + } + + public void executeTask( Task task ) + throws TaskExecutionException + { + RepositoryTask repoTask = (RepositoryTask) task; + + if ( StringUtils.isBlank( repoTask.getRepositoryId() ) ) + { + throw new TaskExecutionException("Unable to execute RepositoryTask with blank repository Id."); + } + + log.info( "Executing task from queue with job name: " + repoTask.getName() ); + + try + { + ManagedRepositoryConfiguration arepo = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoTask.getRepositoryId() ); + if ( arepo == null ) + { + throw new TaskExecutionException( "Unable to execute RepositoryTask with invalid repository id: " + repoTask.getRepositoryId() ); + } + + long sinceWhen = RepositoryScanner.FRESH_SCAN; + + List<RepositoryContentStatistics> results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) ); + + if ( CollectionUtils.isNotEmpty( results ) ) + { + RepositoryContentStatistics lastStats = results.get( 0 ); + sinceWhen = lastStats.getWhenGathered().getTime() + lastStats.getDuration(); + } + + RepositoryScanStatistics stats = repoScanner.scan( arepo, sinceWhen ); + + log.info( "Finished repository task: " + stats.toDump( arepo ) ); + + // I hate jpox and modello + RepositoryContentStatistics dbstats = new RepositoryContentStatistics(); + dbstats.setDuration( stats.getDuration() ); + dbstats.setNewFileCount( stats.getNewFileCount() ); + dbstats.setRepositoryId( stats.getRepositoryId() ); + dbstats.setTotalFileCount( stats.getTotalFileCount() ); + dbstats.setWhenGathered( stats.getWhenGathered() ); + + dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats ); + } + catch ( RepositoryException e ) + { + throw new TaskExecutionException( "Repository error when executing repository job.", e ); + } + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java new file mode 100644 index 000000000..642f16b7f --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/ArchivaTask.java @@ -0,0 +1,68 @@ +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 org.codehaus.plexus.taskqueue.Task; + +/** + * A repository task. + * + * @author <a href="mailto:brett@apache.org">Brett Porter</a> + */ +public interface ArchivaTask + extends Task +{ + public static final String QUEUE_POLICY_WAIT = "wait"; + + public static final String QUEUE_POLICY_SKIP = "skip"; + + /** + * Gets the queue policy for this task. + * + * @return Queue policy for this task + */ + public String getQueuePolicy(); + + /** + * Sets the queue policy for this task. + * + * @param policy + */ + public void setQueuePolicy( String policy ); + + /** + * Sets the job name to represent a group of similar / identical job tasks. Can be used to check the + * task queue for similar / identical job tasks. + */ + public void setName( String name ); + + /** + * obtains the name of the task + * @return + */ + public String getName(); + + public long getMaxExecutionTime(); + + public void setMaxExecutionTime( long maxExecutionTime ); + + + +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java new file mode 100644 index 000000000..427d9e8e9 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/DatabaseTask.java @@ -0,0 +1,68 @@ +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. + */ + +/** + * DataRefreshTask - task for discovering changes in the repository + * and updating all associated data. + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $ + */ +public class DatabaseTask + implements ArchivaTask +{ + + String name; + + String queuePolicy; + + long maxExecutionTime; + + public long getMaxExecutionTime() + { + return maxExecutionTime; + } + + public void setMaxExecutionTime( long maxExecutionTime ) + { + this.maxExecutionTime = maxExecutionTime; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public String getQueuePolicy() + { + return queuePolicy; + } + + public void setQueuePolicy( String queuePolicy ) + { + this.queuePolicy = queuePolicy; + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java new file mode 100644 index 000000000..cd4da2d6f --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTask.java @@ -0,0 +1,79 @@ +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. + */ + +/** + * DataRefreshTask - task for discovering changes in the repository + * and updating all associated data. + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $ + */ +public class RepositoryTask + implements ArchivaTask +{ + String repositoryId; + + String name; + + String queuePolicy; + + long maxExecutionTime; + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public long getMaxExecutionTime() + { + return maxExecutionTime; + } + + public void setMaxExecutionTime( long maxExecutionTime ) + { + this.maxExecutionTime = maxExecutionTime; + } + + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + public String getQueuePolicy() + { + return queuePolicy; + } + + public void setQueuePolicy( String queuePolicy ) + { + this.queuePolicy = queuePolicy; + } +} diff --git a/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java new file mode 100644 index 000000000..c328ebe9c --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/tasks/RepositoryTaskSelectionPredicate.java @@ -0,0 +1,54 @@ +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 org.apache.commons.collections.Predicate; +import org.apache.commons.lang.StringUtils; + +/** + * RepositoryTaskSelectionPredicate + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + */ +public class RepositoryTaskSelectionPredicate + implements Predicate +{ + private String repoid; + + public RepositoryTaskSelectionPredicate( String repositoryId ) + { + this.repoid = repositoryId; + } + + public boolean evaluate( Object object ) + { + boolean satisfies = false; + + if ( object instanceof RepositoryTask ) + { + RepositoryTask task = (RepositoryTask) object; + return StringUtils.equals( repoid, task.getRepositoryId() ); + } + + return satisfies; + } + +} 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 new file mode 100644 index 000000000..4d6d6370f --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" ?> +<!-- + ~ 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. + --> + +<component-set> + <components> + <!-- + | + | Database Update Task Queue / Executor + | + --> + <component> + <role>org.codehaus.plexus.taskqueue.TaskQueue</role> + <role-hint>database-update</role-hint> + <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation> + <lifecycle-handler>plexus-configurable</lifecycle-handler> + <configuration> + <task-entry-evaluators> + </task-entry-evaluators> + <task-exit-evaluators> + </task-exit-evaluators> + <task-viability-evaluators> + </task-viability-evaluators> + </configuration> + </component> + + <component> + <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role> + <role-hint>database-update</role-hint> + <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation> + <instantiation-strategy>singleton</instantiation-strategy> + <requirements> + <requirement> + <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> + <role-hint>database-update</role-hint> + </requirement> + <requirement> + <role>org.codehaus.plexus.taskqueue.TaskQueue</role> + <role-hint>database-update</role-hint> + </requirement> + </requirements> + <configuration> + <name>database-update</name> + </configuration> + </component> + + <!-- + | + | Repository Scanning Task Queue / Executor + | + --> + <component> + <role>org.codehaus.plexus.taskqueue.TaskQueue</role> + <role-hint>repository-scanning</role-hint> + <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation> + <lifecycle-handler>plexus-configurable</lifecycle-handler> + <configuration> + <task-entry-evaluators> + </task-entry-evaluators> + <task-exit-evaluators> + </task-exit-evaluators> + <task-viability-evaluators> + </task-viability-evaluators> + </configuration> + </component> + + <component> + <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role> + <role-hint>repository-scanning</role-hint> + <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation> + <instantiation-strategy>singleton</instantiation-strategy> + <requirements> + <requirement> + <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> + <role-hint>repository-scanning</role-hint> + </requirement> + <requirement> + <role>org.codehaus.plexus.taskqueue.TaskQueue</role> + <role-hint>repository-scanning</role-hint> + </requirement> + </requirements> + <configuration> + <name>repository-scanning</name> + </configuration> + </component> + </components> + +</component-set> diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java new file mode 100644 index 000000000..ff6979877 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseCleanupConsumer.java @@ -0,0 +1,100 @@ +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.consumers.AbstractMonitoredConsumer; +import org.apache.maven.archiva.consumers.ConsumerException; +import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer; +import org.apache.maven.archiva.model.ArchivaArtifact; + +import java.util.List; + +/** + * TestDatabaseCleanupConsumer + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + */ +public class TestDatabaseCleanupConsumer + extends AbstractMonitoredConsumer + implements DatabaseCleanupConsumer +{ + private int countBegin = 0; + private int countComplete = 0; + private int countProcessed = 0; + + public void resetCount() + { + countBegin = 0; + countProcessed = 0; + countComplete = 0; + } + + public void beginScan() + { + countBegin++; + } + + public void completeScan() + { + countComplete++; + } + + public List getIncludedTypes() + { + return null; + } + + public void processArchivaArtifact( ArchivaArtifact artifact ) + throws ConsumerException + { + countProcessed++; + } + + public String getDescription() + { + return "Test Consumer for Database Cleanup"; + } + + public String getId() + { + return "test-db-cleanup"; + } + + public boolean isPermanent() + { + return false; + } + + public int getCountBegin() + { + return countBegin; + } + + public int getCountComplete() + { + return countComplete; + } + + public int getCountProcessed() + { + return countProcessed; + } +} diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java new file mode 100644 index 000000000..ec93b3e87 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/TestDatabaseUnprocessedConsumer.java @@ -0,0 +1,111 @@ +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 java.util.ArrayList; +import java.util.List; + +import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; +import org.apache.maven.archiva.consumers.ConsumerException; +import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer; +import org.apache.maven.archiva.model.ArchivaArtifact; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * TestDatabaseUnprocessedConsumer + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + */ +public class TestDatabaseUnprocessedConsumer + extends AbstractMonitoredConsumer + implements DatabaseUnprocessedArtifactConsumer +{ + private Logger log = LoggerFactory.getLogger( TestDatabaseUnprocessedConsumer.class ); + + private int countBegin = 0; + + private int countComplete = 0; + + private int countProcessed = 0; + + public void resetCount() + { + countBegin = 0; + countProcessed = 0; + countComplete = 0; + } + + public void beginScan() + { + countBegin++; + } + + public void completeScan() + { + countComplete++; + } + + public List getIncludedTypes() + { + List types = new ArrayList(); + types.add( "pom" ); + types.add( "jar" ); + return types; + } + + public void processArchivaArtifact( ArchivaArtifact artifact ) + throws ConsumerException + { + log.info( "Processing Artifact: " + artifact ); + countProcessed++; + } + + public String getDescription() + { + return "Test Consumer for Database Unprocessed"; + } + + public String getId() + { + return "test-db-unprocessed"; + } + + public boolean isPermanent() + { + return false; + } + + public int getCountBegin() + { + return countBegin; + } + + public int getCountComplete() + { + return countComplete; + } + + public int getCountProcessed() + { + return countProcessed; + } +} diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java new file mode 100644 index 000000000..d6ee52438 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.java @@ -0,0 +1,199 @@ +package org.apache.maven.archiva.scheduled.executors; + +/* + * 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.configuration.ManagedRepositoryConfiguration; +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; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.jpox.SchemaTool; + +import java.io.File; +import java.net.URL; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +/** + * ArchivaDatabaseUpdateTaskExecutorTest + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id:$ + */ +public class ArchivaDatabaseUpdateTaskExecutorTest + extends PlexusInSpringTestCase +{ + private TaskExecutor taskExecutor; + + protected ArchivaDAO dao; + + protected void setUp() + throws Exception + { + super.setUp(); + + DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" ); + assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() ); + + jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); + + /* derby version + File derbyDbDir = new File( "target/plexus-home/testdb" ); + if ( derbyDbDir.exists() ) + { + FileUtils.deleteDirectory( derbyDbDir ); + } + + jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) ); + jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) ); + */ + + jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) ); + jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) ); + + jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); + + jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); + + jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); + + jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); + + jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); + + jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" ); + + jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" ); + + // jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" ); + + jdoFactory.setProperty( "org.jpox.validateTables", "true" ); + + jdoFactory.setProperty( "org.jpox.validateColumns", "true" ); + + jdoFactory.setProperty( "org.jpox.validateConstraints", "true" ); + + Properties properties = jdoFactory.getProperties(); + + for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + { + Map.Entry entry = (Map.Entry) it.next(); + + System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); + } + + URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; + + if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) ) + { + fail( "Unable to process test " + getName() + " - missing package.jdo." ); + } + + File propsFile = null; // intentional + boolean verbose = true; + + SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose ); + SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); + + PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory(); + + assertNotNull( pmf ); + + PersistenceManager pm = pmf.getPersistenceManager(); + + pm.close(); + + this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); + + taskExecutor = (TaskExecutor) lookup( TaskExecutor.class, "test-database-update" ); + } + + public void testExecutor() + throws Exception + { + File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); + + assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); + + ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir ); + assertNotNull( repo ); + + ArtifactDAO adao = dao.getArtifactDAO(); + + ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar" ); + sqlArtifact.getModel().setLastModified( new Date() ); + sqlArtifact.getModel().setSize( 1234 ); + sqlArtifact.getModel().setOrigin( "testcase" ); + sqlArtifact.getModel().setWhenProcessed( null ); + + adao.saveArtifact( sqlArtifact ); + + ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar" ); + + assertNotNull( artifact ); + + // Test for artifact existance. + List artifactList = adao.queryArtifacts( null ); + assertNotNull( "Artifact list should not be null.", artifactList ); + assertEquals( "Artifact list size", 1, artifactList.size() ); + + // Test for unprocessed artifacts. + List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList ); + assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() ); + + // Execute the database task. + DatabaseTask dataTask = new DatabaseTask(); + + dataTask.setName( "testDataTask" ); + + taskExecutor.executeTask( dataTask ); + + // Test for artifact existance. + artifactList = adao.queryArtifacts( null ); + assertNotNull( "Artifact list should not be null.", artifactList ); + assertEquals( "Artifact list size", 1, artifactList.size() ); + + // Test for processed artifacts. + List processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) ); + assertNotNull( "Processed Results should not be null.", processedResultList ); + assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() ); + } + + protected ManagedRepositoryConfiguration createRepository( String id, String name, File location ) + { + ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration(); + repo.setId( id ); + repo.setName( name ); + repo.setLocation( location.getAbsolutePath() ); + return repo; + } +} diff --git a/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java new file mode 100644 index 000000000..af5f708b6 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.java @@ -0,0 +1,176 @@ +package org.apache.maven.archiva.scheduled.executors; + +/* + * 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.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.ArtifactDAO; +import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; +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; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.jpox.SchemaTool; + +import java.io.File; +import java.net.URL; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + +/** + * ArchivaRepositoryScanningTaskExecutorTest + * + * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> + * @version $Id$ + */ +public class ArchivaRepositoryScanningTaskExecutorTest + extends PlexusInSpringTestCase +{ + private TaskExecutor taskExecutor; + + protected ArchivaDAO dao; + + protected void setUp() + throws Exception + { + super.setUp(); + + DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" ); + assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() ); + + jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); + + /* derby version + File derbyDbDir = new File( "target/plexus-home/testdb" ); + if ( derbyDbDir.exists() ) + { + FileUtils.deleteDirectory( derbyDbDir ); + } + + jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) ); + jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) ); + */ + + jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) ); + jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) ); + + jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); + + jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); + + jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); + + jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); + + jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); + + jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" ); + + jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" ); + + // jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" ); + + jdoFactory.setProperty( "org.jpox.validateTables", "true" ); + + jdoFactory.setProperty( "org.jpox.validateColumns", "true" ); + + jdoFactory.setProperty( "org.jpox.validateConstraints", "true" ); + + Properties properties = jdoFactory.getProperties(); + + for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); ) + { + Map.Entry entry = (Map.Entry) it.next(); + + System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); + } + + URL jdoFileUrls[] = new URL[] { getClass() + .getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; + + if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) ) + { + fail( "Unable to process test " + getName() + " - missing package.jdo." ); + } + + File propsFile = null; // intentional + boolean verbose = true; + + SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose ); + SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); + + PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory(); + + assertNotNull( pmf ); + + PersistenceManager pm = pmf.getPersistenceManager(); + + pm.close(); + + this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); + + taskExecutor = (TaskExecutor) lookup( TaskExecutor.class, "test-repository-scanning" ); + } + + public void testExecutor() throws Exception + { + File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); + + assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); + + ArchivaConfiguration archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class ); + assertNotNull( archivaConfig ); + + // Create it + ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir ); + assertNotNull( repo ); + archivaConfig.getConfiguration().getManagedRepositories().clear(); + archivaConfig.getConfiguration().addManagedRepository( repo ); + + RepositoryTask repoTask = new RepositoryTask(); + + repoTask.setName( "testRepoTask" ); + repoTask.setRepositoryId( "testRepo" ); + + taskExecutor.executeTask( repoTask ); + + ArtifactDAO adao = dao.getArtifactDAO(); + List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + + assertNotNull( unprocessedResultList ); + assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() ); + } + + protected ManagedRepositoryConfiguration createRepository( String id, String name, File location ) + { + ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration(); + repo.setId( id ); + repo.setName( name ); + repo.setLocation( location.getAbsolutePath() ); + return repo; + } +} diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/maven-metadata.xml b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/maven-metadata.xml new file mode 100644 index 000000000..b3baf545d --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/maven-metadata.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<!-- This metdata is intentionally wrong. --> +<metadata> + <groupId>javax.sql</groupId> + <artifactId>jdbc</artifactId> + <version>2.0</version> +</metadata> 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-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>javax.sql</groupId> + <artifactId>jdbc</artifactId> + <version>2.0</version> +</metadata> diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>javax.sql</groupId> + <artifactId>jdbc</artifactId> + <version>2.0</version> + <versioning> + <versions> + <version>2.0</version> + </versions> + </versioning> +</metadata> diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>javax.sql</groupId> + <artifactId>jdbc</artifactId> + <version>2.0</version> +</metadata> 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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom @@ -0,0 +1,28 @@ +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven</groupId> + <artifactId>A</artifactId> + <version>1.0</version> + <name>Maven Test Repository Artifact Discovery</name> + <packaging>war</packaging> +</project> 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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.md5 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom @@ -0,0 +1,28 @@ +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven</groupId> + <artifactId>B</artifactId> + <version>1.0</version> + <name>Maven Test Repository Artifact Discovery</name> + <packaging>pom</packaging> +</project> 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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom @@ -0,0 +1,28 @@ +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven</groupId> + <artifactId>B</artifactId> + <version>2.0</version> + <name>Maven Test Repository Artifact Discovery</name> + <packaging>pom</packaging> +</project> 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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom @@ -0,0 +1,28 @@ +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven</groupId> + <artifactId>C</artifactId> + <version>1.0</version> + <name>Maven Test Repository Artifact Discovery</name> + <packaging>war</packaging> +</project> 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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.md5 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml new file mode 100644 index 000000000..8ce7fc7bb --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>org.apache.maven</groupId> +</metadata>
\ No newline at end of file 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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.testgroup</groupId> + <artifactId>discovery</artifactId> + <version>1.0</version> + <name>Maven Test Repository Artifact Discovery</name> + <packaging>pom</packaging> +</project> 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-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom.sha1 b/archiva-modules/archiva-scheduled/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-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>org.apache.testgroup</groupId> + <artifactId>discovery</artifactId> + <version>1.0</version> +</metadata>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-modules/archiva-scheduled/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-scheduled/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<metadata> + <groupId>org.apache.testgroup</groupId> + <artifactId>discovery</artifactId> +</metadata>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduled/src/test/resources/archiva-test.xml b/archiva-modules/archiva-scheduled/src/test/resources/archiva-test.xml new file mode 100644 index 000000000..3f2310c7b --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/resources/archiva-test.xml @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<configuration> + <managedRepositories> + <managedRepository> + <id>testRepo</id> + <name>Archiva Test Repository</name> + <location>${basedir}/src/test/repositories/default-repository</location> + <layout>default</layout> + <releases>true</releases> + <snapshots>false</snapshots> + <indexed>true</indexed> + <refreshCronExpression>0 0 * * ?</refreshCronExpression> + </managedRepository> + </managedRepositories> + + <proxyConnectors /> + + <networkProxies /> + + <repositoryScanning> + <fileTypes> + <fileType> + <id>artifacts</id> + <patterns> + <pattern>**/*.pom</pattern> + <pattern>**/*.jar</pattern> + <pattern>**/*.ear</pattern> + <pattern>**/*.war</pattern> + <pattern>**/*.car</pattern> + <pattern>**/*.sar</pattern> + <pattern>**/*.mar</pattern> + <pattern>**/*.rar</pattern> + <pattern>**/*.dtd</pattern> + <pattern>**/*.tld</pattern> + <pattern>**/*.tar.gz</pattern> + <pattern>**/*.tar.bz2</pattern> + <pattern>**/*.zip</pattern> + </patterns> + </fileType> + <fileType> + <id>indexable-content</id> + <patterns> + <pattern>**/*.txt</pattern> + <pattern>**/*.TXT</pattern> + <pattern>**/*.block</pattern> + <pattern>**/*.config</pattern> + <pattern>**/*.pom</pattern> + <pattern>**/*.xml</pattern> + <pattern>**/*.xsd</pattern> + <pattern>**/*.dtd</pattern> + <pattern>**/*.tld</pattern> + </patterns> + </fileType> + <fileType> + <id>auto-remove</id> + <patterns> + <pattern>**/*.bak</pattern> + <pattern>**/*~</pattern> + <pattern>**/*-</pattern> + </patterns> + </fileType> + <fileType> + <id>ignored</id> + <patterns> + <pattern>**/.htaccess</pattern> + <pattern>**/KEYS</pattern> + <pattern>**/*.rb</pattern> + <pattern>**/*.sh</pattern> + <pattern>**/.svn/**</pattern> + <pattern>**/.DAV/**</pattern> + </patterns> + </fileType> + </fileTypes> + <knownContentConsumers> + <knownContentConsumer>update-db-artifact</knownContentConsumer> + <knownContentConsumer>create-missing-checksums</knownContentConsumer> + <knownContentConsumer>update-db-repository-metadata</knownContentConsumer> + <knownContentConsumer>validate-checksum</knownContentConsumer> + <knownContentConsumer>validate-signature</knownContentConsumer> + <knownContentConsumer>index-content</knownContentConsumer> + <knownContentConsumer>auto-remove</knownContentConsumer> + <knownContentConsumer>auto-rename</knownContentConsumer> + </knownContentConsumers> + <invalidContentConsumers> + <invalidContentConsumer>update-db-bad-content</invalidContentConsumer> + </invalidContentConsumers> + </repositoryScanning> + + <databaseScanning> + <cronExpression>0 0 * * ?</cronExpression> + <unprocessedConsumers> + <unprocessedConsumer>test-db-unprocessed</unprocessedConsumer> + <unprocessedConsumer>update-db-artifact</unprocessedConsumer> + </unprocessedConsumers> + <cleanupConsumers> + <cleanupConsumer>test-db-cleanup</cleanupConsumer> + </cleanupConsumers> + </databaseScanning> + +</configuration> diff --git a/archiva-modules/archiva-scheduled/src/test/resources/log4j.xml b/archiva-modules/archiva-scheduled/src/test/resources/log4j.xml new file mode 100644 index 000000000..3c782b138 --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/resources/log4j.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> + +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <appender name="console" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="%5p|%t|%5r|%-30c{1} - %m%n"/> + </layout> + </appender> + + <!-- Help identify bugs during testing --> + <logger name="org.apache.maven.archiva"> + <level value="debug"/> + </logger> + + <logger name="org.codehaus.plexus.security"> + <level value="info"/> + </logger> + + <logger name="org.codehaus.plexus.PlexusContainer"> + <level value="info"/> + </logger> + + <logger name="JPOX"> + <level value="warn"/> + </logger> + + <logger name="JPOX.MetaData"> + <level value="error"/> + </logger> + + <logger name="JPOX.RDBMS.SQL"> + <level value="error"/> + </logger> + + <logger name="SQL"> + <level value="error"/> + </logger> + + <root> + <priority value ="debug" /> + <appender-ref ref="console" /> + </root> + +</log4j:configuration> diff --git a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml b/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml new file mode 100644 index 000000000..24e60e8fb --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaDatabaseUpdateTaskExecutorTest.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<component-set> + <components> + <component> + <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> + <role-hint>test-database-update</role-hint> + <implementation>org.apache.maven.archiva.scheduled.executors.ArchivaDatabaseUpdateTaskExecutor</implementation> + <description></description> + <requirements> + <requirement> + <role>org.apache.maven.archiva.database.updater.DatabaseUpdater</role> + <role-hint>jdo</role-hint> + <field-name>databaseUpdater</field-name> + </requirement> + </requirements> + </component> + + <component> + <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> + <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> + <requirements> + <requirement> + <role>org.codehaus.plexus.registry.Registry</role> + <role-hint>configured</role-hint> + </requirement> + <requirement> + <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> + <field-name>prePolicies</field-name> + </requirement> + <requirement> + <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> + <field-name>postPolicies</field-name> + </requirement> + </requirements> + </component> + + <component> + <role>org.codehaus.plexus.registry.Registry</role> + <role-hint>configured</role-hint> + <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> + <configuration> + <properties> + <system/> + <xml fileName="${basedir}/src/test/resources/archiva-test.xml" + config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> + </properties> + </configuration> + </component> + + <component> + <role>org.apache.maven.archiva.consumers.DatabaseCleanupConsumer</role> + <role-hint>test-db-cleanup</role-hint> + <implementation>org.apache.maven.archiva.scheduled.TestDatabaseCleanupConsumer</implementation> + </component> + + <component> + <role>org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer</role> + <role-hint>test-db-unprocessed</role-hint> + <implementation>org.apache.maven.archiva.scheduled.TestDatabaseUnprocessedConsumer</implementation> + </component> + + + <component> + <role>org.codehaus.plexus.jdo.JdoFactory</role> + <role-hint>archiva</role-hint> + <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> + <configuration> + <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> + <otherProperties> + <property> + <name>javax.jdo.PersistenceManagerFactoryClass</name> + <value>org.jpox.PersistenceManagerFactoryImpl</value> + </property> + </otherProperties> + </configuration> + </component> + + </components> +</component-set> diff --git a/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml b/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml new file mode 100644 index 000000000..f903ba33f --- /dev/null +++ b/archiva-modules/archiva-scheduled/src/test/resources/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutorTest.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ 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. + --> + +<component-set> + <components> + <component> + <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> + <role-hint>test-repository-scanning</role-hint> + <implementation>org.apache.maven.archiva.scheduled.executors.ArchivaRepositoryScanningTaskExecutor + </implementation> + <description></description> + <requirements> + <requirement> + <role>org.apache.maven.archiva.database.ArchivaDAO</role> + <role-hint>jdo</role-hint> + <field-name>dao</field-name> + </requirement> + <requirement> + <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> + <field-name>archivaConfiguration</field-name> + </requirement> + <requirement> + <role>org.apache.maven.archiva.repository.scanner.RepositoryScanner</role> + <field-name>repoScanner</field-name> + </requirement> + </requirements> + </component> + + <component> + <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> + <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> + <requirements> + <requirement> + <role>org.codehaus.plexus.registry.Registry</role> + <role-hint>configured</role-hint> + </requirement> + <requirement> + <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> + <field-name>prePolicies</field-name> + </requirement> + <requirement> + <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> + <field-name>postPolicies</field-name> + </requirement> + </requirements> + </component> + + <component> + <role>org.codehaus.plexus.registry.Registry</role> + <role-hint>configured</role-hint> + <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> + <configuration> + <properties> + <system/> + <xml fileName="${basedir}/src/test/resources/archiva-test.xml" + config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> + </properties> + </configuration> + </component> + + <component> + <role>org.codehaus.plexus.jdo.JdoFactory</role> + <role-hint>archiva</role-hint> + <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> + <configuration> + <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> + <otherProperties> + <property> + <name>javax.jdo.PersistenceManagerFactoryClass</name> + <value>org.jpox.PersistenceManagerFactoryImpl</value> + </property> + </otherProperties> + </configuration> + </component> + + </components> +</component-set> |