1 package org.apache.archiva.web.action.admin;
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.redback.rbac.Resource;
23 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
24 import org.apache.archiva.scheduler.repository.RepositoryTask;
25 import org.apache.archiva.security.common.ArchivaRoleConstants;
26 import org.apache.commons.lang.StringUtils;
27 import org.apache.archiva.web.action.AbstractActionSupport;
28 import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
29 import org.apache.archiva.redback.integration.interceptor.SecureAction;
30 import org.apache.archiva.redback.integration.interceptor.SecureActionBundle;
31 import org.apache.archiva.redback.integration.interceptor.SecureActionException;
32 import org.springframework.context.annotation.Scope;
33 import org.springframework.stereotype.Controller;
35 import javax.inject.Inject;
36 import javax.inject.Named;
39 * Configures the application.
41 @Controller( "schedulerAction" )
43 public class SchedulerAction
44 extends AbstractActionSupport
45 implements SecureAction
49 @Named( value = "archivaTaskScheduler#repository" )
50 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
52 private String repoid;
54 private boolean scanAll;
56 public String scanRepository()
58 if ( StringUtils.isBlank( repoid ) )
60 addActionError( "Cannot run indexer on blank repository id." );
64 RepositoryTask task = new RepositoryTask();
65 task.setRepositoryId( repoid );
66 task.setScanAll( scanAll );
68 if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
70 addActionError( "Repository [" + repoid + "] task was already queued." );
76 addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." );
77 repositoryTaskScheduler.queueTask( task );
79 catch ( TaskQueueException e )
82 "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
86 // Return to the repositories screen.
91 public void addActionMessage( String aMessage )
93 super.addActionMessage( aMessage );
94 log.info( "[ActionMessage] " + aMessage );
98 public void addActionError( String anErrorMessage )
100 super.addActionError( anErrorMessage );
101 log.warn( "[ActionError] " + anErrorMessage );
104 public SecureActionBundle getSecureActionBundle()
105 throws SecureActionException
107 SecureActionBundle bundle = new SecureActionBundle();
109 bundle.setRequiresAuthentication( true );
110 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
115 public String getRepoid()
120 public void setRepoid( String repoid )
122 this.repoid = repoid;
125 public boolean getScanAll()
130 public void setScanAll( boolean scanAll )
132 this.scanAll = scanAll;