Coverage Report - org.apache.maven.archiva.scheduled.tasks.TaskCreator
 
Classes in this File Line Coverage Branch Coverage Complexity
TaskCreator
0%
0/24
0%
0/4
1.167
 
 1  
 package org.apache.maven.archiva.scheduled.tasks;
 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 java.io.File;
 23  
 import java.io.IOException;
 24  
 
 25  
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 26  
 import org.sonatype.nexus.index.NexusIndexer;
 27  
 import org.sonatype.nexus.index.context.DefaultIndexingContext;
 28  
 import org.sonatype.nexus.index.context.IndexingContext;
 29  
 import org.sonatype.nexus.index.context.UnsupportedExistingLuceneIndexException;
 30  
 
 31  
 /**
 32  
  * TaskCreator Convenience class for creating Archiva tasks.
 33  
  * @todo Nexus specifics shouldn't be in the archiva-scheduled module
 34  
  */
 35  0
 public class TaskCreator
 36  
 {
 37  
     public static RepositoryTask createRepositoryTask( String repositoryId )
 38  
     {
 39  0
         RepositoryTask task = new RepositoryTask();
 40  0
         task.setRepositoryId( repositoryId );
 41  0
         return task;
 42  
     }
 43  
 
 44  
     public static RepositoryTask createRepositoryTask( String repositoryId, boolean scanAll )
 45  
     {
 46  0
         RepositoryTask task = createRepositoryTask( repositoryId );
 47  0
         task.setScanAll( scanAll );
 48  
 
 49  0
         return task;
 50  
     }
 51  
 
 52  
     public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile,
 53  
                                                        boolean updateRelatedArtifacts )
 54  
     {
 55  0
         RepositoryTask task = createRepositoryTask( repositoryId );
 56  0
         task.setResourceFile( resourceFile );
 57  0
         task.setUpdateRelatedArtifacts( updateRelatedArtifacts );
 58  
 
 59  0
         return task;
 60  
     }
 61  
 
 62  
     public static RepositoryTask createRepositoryTask( String repositoryId, File resourceFile,
 63  
                                                        boolean updateRelatedArtifacts, boolean scanAll )
 64  
     {
 65  0
         RepositoryTask task = createRepositoryTask( repositoryId, resourceFile, updateRelatedArtifacts );
 66  0
         task.setScanAll( scanAll );
 67  
 
 68  0
         return task;
 69  
     }
 70  
 
 71  
     public static ArtifactIndexingTask createIndexingTask( ManagedRepositoryConfiguration repository, File resource,
 72  
                                                     ArtifactIndexingTask.Action action, IndexingContext context )
 73  
     {
 74  0
         return new ArtifactIndexingTask( repository, resource, action, context );
 75  
     }
 76  
 
 77  
     public static IndexingContext createContext( ManagedRepositoryConfiguration repository )
 78  
         throws IOException, UnsupportedExistingLuceneIndexException
 79  
     {
 80  0
         String indexDir = repository.getIndexDir();
 81  0
         File managedRepository = new File( repository.getLocation() );
 82  
 
 83  0
         File indexDirectory = null;
 84  0
         if ( indexDir != null && !"".equals( indexDir ) )
 85  
         {
 86  0
             indexDirectory = new File( repository.getIndexDir() );
 87  
         }
 88  
         else
 89  
         {
 90  0
             indexDirectory = new File( managedRepository, ".indexer" );
 91  
         }
 92  
 
 93  0
         IndexingContext context =
 94  
             new DefaultIndexingContext( repository.getId(), repository.getId(), managedRepository, indexDirectory,
 95  
                                         null, null, NexusIndexer.FULL_INDEX, false );
 96  0
         context.setSearchable( repository.isScanned() );
 97  0
         return context;
 98  
     }
 99  
 
 100  
 }