1 package org.apache.maven.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.scheduler.repository.RepositoryArchivaTaskScheduler;
23 import org.apache.archiva.scheduler.repository.RepositoryTask;
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.archiva.security.ArchivaRoleConstants;
26 import org.apache.maven.archiva.web.action.AbstractActionSupport;
27 import org.codehaus.plexus.redback.rbac.Resource;
28 import org.codehaus.plexus.taskqueue.TaskQueueException;
29 import org.codehaus.redback.integration.interceptor.SecureAction;
30 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
31 import org.codehaus.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 * plexus.component role="com.opensymphony.xwork2.Action" role-hint="schedulerAction" instantiation-strategy="per-lookup"
43 @Controller( "schedulerAction" )
45 public class SchedulerAction
46 extends AbstractActionSupport
47 implements SecureAction
50 * plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="repository"
53 @Named( value = "archivaTaskScheduler#repository" )
54 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
56 private String repoid;
58 private boolean scanAll;
60 public String scanRepository()
62 if ( StringUtils.isBlank( repoid ) )
64 addActionError( "Cannot run indexer on blank repository id." );
68 RepositoryTask task = new RepositoryTask();
69 task.setRepositoryId( repoid );
70 task.setScanAll( scanAll );
72 if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoid ) )
74 addActionError( "Repository [" + repoid + "] task was already queued." );
80 addActionMessage( "Your request to have repository [" + repoid + "] be indexed has been queued." );
81 repositoryTaskScheduler.queueTask( task );
83 catch ( TaskQueueException e )
86 "Unable to queue your request to have repository [" + repoid + "] be indexed: " + e.getMessage() );
90 // Return to the repositories screen.
95 public void addActionMessage( String aMessage )
97 super.addActionMessage( aMessage );
98 log.info( "[ActionMessage] " + aMessage );
102 public void addActionError( String anErrorMessage )
104 super.addActionError( anErrorMessage );
105 log.warn( "[ActionError] " + anErrorMessage );
108 public SecureActionBundle getSecureActionBundle()
109 throws SecureActionException
111 SecureActionBundle bundle = new SecureActionBundle();
113 bundle.setRequiresAuthentication( true );
114 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_RUN_INDEXER, Resource.GLOBAL );
119 public String getRepoid()
124 public void setRepoid( String repoid )
126 this.repoid = repoid;
129 public boolean getScanAll()
134 public void setScanAll( boolean scanAll )
136 this.scanAll = scanAll;