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.admin.repository.managed.ManagedRepositoryAdmin;
23 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
24 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
25 import org.apache.archiva.rest.api.services.RepositoriesService;
26 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
27 import org.apache.archiva.scheduler.repository.RepositoryTask;
28 import org.codehaus.plexus.redback.role.RoleManager;
29 import org.codehaus.plexus.registry.Registry;
30 import org.codehaus.plexus.taskqueue.TaskQueueException;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.stereotype.Service;
35 import javax.inject.Inject;
36 import javax.inject.Named;
37 import javax.ws.rs.PathParam;
40 * @author Olivier Lamy
43 @Service( "repositoriesService#rest" )
44 public class DefaultRepositoriesService
45 extends AbstractRestService
46 implements RepositoriesService
48 private Logger log = LoggerFactory.getLogger( getClass() );
51 protected RoleManager roleManager;
54 @Named( value = "archivaTaskScheduler#repository" )
55 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
58 // FIXME olamy move this to repository admin component !
59 public Boolean scanRepository( String repositoryId, boolean fullScan )
61 if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) )
63 log.info( "scanning of repository with id {} already scheduled" );
65 RepositoryTask task = new RepositoryTask();
66 task.setRepositoryId( repositoryId );
67 task.setScanAll( fullScan );
70 repositoryTaskScheduler.queueTask( task );
72 catch ( TaskQueueException e )
74 log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
80 public Boolean alreadyScanning( String repositoryId )
82 return repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId );
85 public Boolean removeScanningTaskFromQueue( @PathParam( "repositoryId" ) String repositoryId )
87 RepositoryTask task = new RepositoryTask();
88 task.setRepositoryId( repositoryId );
91 return repositoryTaskScheduler.unQueueTask( task );
93 catch ( TaskQueueException e )
95 log.error( "failed to unschedule scanning of repo with id {}", repositoryId, e );