From 795337f573479a353bf732287ce784672ffa7fd9 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 19 Jun 2007 18:43:30 +0000 Subject: [PATCH] [MRM-358] Update Consumers button in Database - Artifact Scanning doesn't work. Patch from Napolean Ramirez applied. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@548821 13f79535-47bb-0310-9956-ffa450edef68 --- .../action/admin/database/DatabaseAction.java | 78 ++++++++++++++++--- .../src/main/resources/xwork.xml | 3 + .../webapp/WEB-INF/jsp/admin/database.jsp | 4 +- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java index 7c1b2a99d..ebb42023c 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java @@ -19,12 +19,15 @@ package org.apache.maven.archiva.web.action.admin.database; * under the License. */ -import com.opensymphony.xwork.Preparable; +import java.io.IOException; +import java.util.Collections; +import java.util.List; import org.apache.commons.collections.CollectionUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; +import org.apache.maven.archiva.configuration.InvalidConfigurationException; import org.apache.maven.archiva.database.updater.DatabaseConsumers; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.admin.scanning.AdminRepositoryConsumerComparator; @@ -32,10 +35,10 @@ import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.redback.xwork.interceptor.SecureAction; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; +import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; -import java.util.Collections; -import java.util.List; +import com.opensymphony.xwork.Preparable; /** * DatabaseAction @@ -62,14 +65,24 @@ public class DatabaseAction private String cron; /** - * List of {@link AdminDatabaseConsumer} objects for unprocessed artifacts. + * List of available {@link AdminDatabaseConsumer} objects for unprocessed artifacts. */ private List unprocessedConsumers; - + + /** + * List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts. + */ + private List enabledUnprocessedConsumers; + /** * List of {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. */ private List cleanupConsumers; + + /** + * List of enabled {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. + */ + private List enabledCleanupConsumers; public void prepare() throws Exception @@ -98,19 +111,46 @@ public class DatabaseAction public String updateUnprocessedConsumers() { getLogger().info( "updateUnprocesedConsumers()" ); - return INPUT; + + archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( enabledUnprocessedConsumers ); + + return saveConfiguration(); } - + public String updateCleanupConsumers() { getLogger().info( "updateCleanupConsumers()" ); - return INPUT; + + archivaConfiguration.getConfiguration().getDatabaseScanning().setCleanupConsumers( enabledCleanupConsumers ); + + return saveConfiguration(); } public String updateSchedule() { getLogger().info( "updateSchedule()" ); - return INPUT; + + archivaConfiguration.getConfiguration().getDatabaseScanning().setCronExpression( cron ); + + return saveConfiguration(); + } + + private String saveConfiguration() + { + getLogger().info( ".saveConfiguration()" ); + + try + { + archivaConfiguration.save( archivaConfiguration.getConfiguration() ); + addActionMessage( "Successfully saved configuration" ); + } + catch ( Exception e) + { + addActionError( "Error in saving configuration" ); + return INPUT; + } + + return SUCCESS; } public SecureActionBundle getSecureActionBundle() @@ -143,4 +183,24 @@ public class DatabaseAction { return unprocessedConsumers; } + + public List getEnabledUnprocessedConsumers() + { + return enabledUnprocessedConsumers; + } + + public void setEnabledUnprocessedConsumers( List enabledUnprocessedConsumers ) + { + this.enabledUnprocessedConsumers = enabledUnprocessedConsumers; + } + + public List getEnabledCleanupConsumers() + { + return enabledCleanupConsumers; + } + + public void setEnabledCleanupConsumers( List enabledCleanupConsumers ) + { + this.enabledCleanupConsumers = enabledCleanupConsumers; + } } diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index fba394159..ad6781a1f 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -343,6 +343,9 @@ /WEB-INF/jsp/admin/database.jsp + + database + 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 d039031e2..9ffee7d4e 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 @@ -92,7 +92,7 @@ - + checked /> @@ -147,7 +147,7 @@ - + checked />