diff options
Diffstat (limited to 'archiva-web')
-rw-r--r-- | archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java (renamed from archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java) | 53 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java | 1 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/resources/webwork.properties | 2 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/resources/xwork.xml | 6 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp | 4 | ||||
-rw-r--r-- | archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp | 2 |
6 files changed, 62 insertions, 6 deletions
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java index fcb345892..fb0db8436 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/IndexRepositoryAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java @@ -24,6 +24,7 @@ import org.apache.maven.archiva.common.ArchivaException; import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler; import org.apache.maven.archiva.scheduled.DefaultArchivaTaskScheduler; import org.apache.maven.archiva.scheduled.tasks.ArchivaTask; +import org.apache.maven.archiva.scheduled.tasks.DatabaseTask; import org.apache.maven.archiva.scheduled.tasks.RepositoryTask; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.rbac.Resource; @@ -36,12 +37,16 @@ import org.codehaus.plexus.xwork.action.PlexusActionSupport; /** * Configures the application. * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="indexRepositoryAction" + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="schedulerAction" */ -public class IndexRepositoryAction +public class SchedulerAction extends PlexusActionSupport implements SecureAction { + private static final String REPO_SUCCESS = "repoSucces"; + + private static final String DB_SUCCESS = "dbSuccess"; + /** * @plexus.requirement */ @@ -49,7 +54,7 @@ public class IndexRepositoryAction private String repoid; - public String run() + public String scanRepository() { if ( StringUtils.isBlank( repoid ) ) { @@ -106,6 +111,48 @@ public class IndexRepositoryAction return SUCCESS; } + public String updateDatabase() + { + DatabaseTask task = new DatabaseTask(); + task.setName( DefaultArchivaTaskScheduler.DATABASE_JOB + ":user-requested" ); + task.setQueuePolicy( ArchivaTask.QUEUE_POLICY_WAIT ); + + boolean scheduleTask = false; + + try + { + if ( taskScheduler.isProcessingDatabaseTask() ) + { + addActionError( "Database task was already queued." ); + } + else + { + scheduleTask = true; + } + } + catch ( ArchivaException e ) + { + scheduleTask = false; + addActionError( e.getMessage() ); + } + + if ( scheduleTask ) + { + try + { + taskScheduler.queueDatabaseTask( task ); + addActionMessage( "Your request to update the database has been queued." ); + } + catch ( TaskQueueException e ) + { + addActionError( "Unable to queue your request to update the database: " + e.getMessage() ); + } + } + + // Return to the database screen. + return SUCCESS; + } + public void addActionMessage( String aMessage ) { super.addActionMessage( aMessage ); diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java index d6e4fecce..a6b62c117 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java @@ -144,5 +144,6 @@ public class ConfigurationSynchronization { Banner.display( getLogger(), ArchivaVersion.determineVersion( this.getClass().getClassLoader() ) ); synchConfiguration(); + archivaConfiguration.addChangeListener( this ); } } diff --git a/archiva-web/archiva-webapp/src/main/resources/webwork.properties b/archiva-web/archiva-webapp/src/main/resources/webwork.properties index b53334909..d9155d8ca 100644 --- a/archiva-web/archiva-webapp/src/main/resources/webwork.properties +++ b/archiva-web/archiva-webapp/src/main/resources/webwork.properties @@ -22,6 +22,6 @@ webwork.mapper.class = org.apache.maven.archiva.web.mapper.RepositoryActionMappe webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory webwork.url.includeParams = none -webwork.devMode = true +# webwork.devMode = true # TODO: package up a theme and share with Continuum. Should contain everything from xhtml, and set templateDir to WEB-INF/themes diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 73cc1bfb5..79aeb4a7e 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -238,7 +238,7 @@ <result name="confirm" type="redirect-action">deleteRepository</result> </action> - <action name="indexRepository" class="indexRepositoryAction" method="run"> + <action name="indexRepository" class="schedulerAction" method="scanRepository"> <result type="redirect-action">repositories</result> </action> @@ -344,6 +344,10 @@ <result name="input">/WEB-INF/jsp/admin/database.jsp</result> </action> + <action name="updateDatabase" class="schedulerAction" method="updateDatabase"> + <result type="redirect-action">database</result> + </action> + <!-- .\ CONFIGURATION \.___________________________________________ --> <action name="configure" class="configureAction" method="input"> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp index 04a7e2ba0..7c34f97f8 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp @@ -56,6 +56,10 @@ </tr> </table> </ww:form> + + <ww:form action="updateDatabase" theme="simple"> + <ww:submit value="Update Database Now"/> + </ww:form> <h2>Database - Unprocessed Artifacts Scanning</h2> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp index 7d3af58c6..7b3a9ca39 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp @@ -157,7 +157,7 @@ <tr> <td> <redback:ifAuthorized permission="archiva-run-indexer"> - <ww:form action="indexRepository"> + <ww:form action="indexRepository" theme="simple"> <ww:hidden name="repoid" value="%{'${repository.id}'}"/> <ww:submit value="Scan Repository Now"/> </ww:form> |