1 package org.apache.archiva.rest.services;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.rest.api.services.RepositoriesService;
23 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
24 import org.apache.archiva.scheduler.repository.RepositoryTask;
25 import org.codehaus.plexus.redback.role.RoleManager;
26 import org.codehaus.plexus.taskqueue.TaskQueueException;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.stereotype.Service;
31 import javax.inject.Inject;
32 import javax.inject.Named;
33 import javax.ws.rs.PathParam;
36 * @author Olivier Lamy
39 @Service( "repositoriesService#rest" )
40 public class DefaultRepositoriesService
41 extends AbstractRestService
42 implements RepositoriesService
44 private Logger log = LoggerFactory.getLogger( getClass() );
47 protected RoleManager roleManager;
50 @Named( value = "archivaTaskScheduler#repository" )
51 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
54 // FIXME olamy move this to repository admin component !
55 public Boolean scanRepository( String repositoryId, boolean fullScan )
57 if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) )
59 log.info( "scanning of repository with id {} already scheduled" );
61 RepositoryTask task = new RepositoryTask();
62 task.setRepositoryId( repositoryId );
63 task.setScanAll( fullScan );
66 repositoryTaskScheduler.queueTask( task );
68 catch ( TaskQueueException e )
70 log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
76 public Boolean alreadyScanning( String repositoryId )
78 return repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId );
81 public Boolean removeScanningTaskFromQueue( @PathParam( "repositoryId" ) String repositoryId )
83 RepositoryTask task = new RepositoryTask();
84 task.setRepositoryId( repositoryId );
87 return repositoryTaskScheduler.unQueueTask( task );
89 catch ( TaskQueueException e )
91 log.error( "failed to unschedule scanning of repo with id {}", repositoryId, e );