Coverage Report - org.apache.maven.archiva.scheduled.executors.ArchivaDatabaseUpdateTaskExecutor
 
Classes in this File Line Coverage Branch Coverage Complexity
ArchivaDatabaseUpdateTaskExecutor
0%
0/20
N/A
3
 
 1  
 package org.apache.maven.archiva.scheduled.executors;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 23  
 import org.apache.maven.archiva.database.updater.DatabaseUpdater;
 24  
 import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
 25  
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 26  
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 27  
 import org.codehaus.plexus.taskqueue.Task;
 28  
 import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
 29  
 import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
 30  
 import org.slf4j.Logger;
 31  
 import org.slf4j.LoggerFactory;
 32  
 
 33  
 /**
 34  
  * ArchivaDatabaseTaskExecutor 
 35  
  *
 36  
  * @version $Id: ArchivaDatabaseUpdateTaskExecutor.java 825082 2009-10-14 10:27:48Z brett $
 37  
  * 
 38  
  * @plexus.component
 39  
  *   role="org.codehaus.plexus.taskqueue.execution.TaskExecutor"
 40  
  *   role-hint="database-update"
 41  
  */
 42  0
 public class ArchivaDatabaseUpdateTaskExecutor
 43  
     implements TaskExecutor, Initializable
 44  
 {
 45  0
     private Logger log = LoggerFactory.getLogger( ArchivaDatabaseUpdateTaskExecutor.class );
 46  
     
 47  
     /**
 48  
      * @plexus.requirement role-hint="jdo"
 49  
      */
 50  
     private DatabaseUpdater databaseUpdater;
 51  
 
 52  
     public void initialize()
 53  
         throws InitializationException
 54  
     {
 55  0
         log.info( "Initialized " + this.getClass().getName() );
 56  0
     }
 57  
 
 58  
     public void executeTask( Task task )
 59  
         throws TaskExecutionException
 60  
     {
 61  0
         DatabaseTask dbtask = (DatabaseTask) task;
 62  
 
 63  0
         log.info( "Executing task from queue with job name: " + dbtask );
 64  0
         long time = System.currentTimeMillis();
 65  
 
 66  
         try
 67  
         {
 68  0
             log.info( "Task: Updating unprocessed artifacts" );
 69  0
             databaseUpdater.updateAllUnprocessed();
 70  
         }
 71  0
         catch ( ArchivaDatabaseException e )
 72  
         {
 73  0
             throw new TaskExecutionException( "Error running unprocessed updater", e );
 74  0
         }
 75  
 
 76  
         try
 77  
         {
 78  0
             log.info( "Task: Updating processed artifacts" );
 79  0
             databaseUpdater.updateAllProcessed();
 80  
         }
 81  0
         catch ( ArchivaDatabaseException e )
 82  
         {
 83  0
             throw new TaskExecutionException( "Error running processed updater", e );
 84  0
         }
 85  
 
 86  0
         time = System.currentTimeMillis() - time;
 87  
 
 88  0
         log.info( "Finished database task in " + time + "ms." );
 89  0
     }
 90  
 }