[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
This commit is contained in:
Joakim Erdfelt 2007-06-19 18:43:30 +00:00
parent 7aaa1c52af
commit 795337f573
3 changed files with 74 additions and 11 deletions

View File

@ -19,12 +19,15 @@ package org.apache.maven.archiva.web.action.admin.database;
* under the License. * 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.commons.collections.CollectionUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; 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.database.updater.DatabaseConsumers;
import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.apache.maven.archiva.web.action.admin.scanning.AdminRepositoryConsumerComparator; 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.SecureAction;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport; import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.util.Collections; import com.opensymphony.xwork.Preparable;
import java.util.List;
/** /**
* DatabaseAction * DatabaseAction
@ -62,15 +65,25 @@ public class DatabaseAction
private String cron; private String cron;
/** /**
* List of {@link AdminDatabaseConsumer} objects for unprocessed artifacts. * List of available {@link AdminDatabaseConsumer} objects for unprocessed artifacts.
*/ */
private List unprocessedConsumers; private List unprocessedConsumers;
/**
* List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts.
*/
private List enabledUnprocessedConsumers;
/** /**
* List of {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts. * List of {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts.
*/ */
private List cleanupConsumers; private List cleanupConsumers;
/**
* List of enabled {@link AdminDatabaseConsumer} objects for "to cleanup" artifacts.
*/
private List enabledCleanupConsumers;
public void prepare() public void prepare()
throws Exception throws Exception
{ {
@ -98,21 +111,48 @@ public class DatabaseAction
public String updateUnprocessedConsumers() public String updateUnprocessedConsumers()
{ {
getLogger().info( "updateUnprocesedConsumers()" ); getLogger().info( "updateUnprocesedConsumers()" );
return INPUT;
archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( enabledUnprocessedConsumers );
return saveConfiguration();
} }
public String updateCleanupConsumers() public String updateCleanupConsumers()
{ {
getLogger().info( "updateCleanupConsumers()" ); getLogger().info( "updateCleanupConsumers()" );
return INPUT;
archivaConfiguration.getConfiguration().getDatabaseScanning().setCleanupConsumers( enabledCleanupConsumers );
return saveConfiguration();
} }
public String updateSchedule() public String updateSchedule()
{ {
getLogger().info( "updateSchedule()" ); getLogger().info( "updateSchedule()" );
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 INPUT;
} }
return SUCCESS;
}
public SecureActionBundle getSecureActionBundle() public SecureActionBundle getSecureActionBundle()
throws SecureActionException throws SecureActionException
{ {
@ -143,4 +183,24 @@ public class DatabaseAction
{ {
return unprocessedConsumers; 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;
}
} }

View File

@ -343,6 +343,9 @@
<action name="database" class="databaseAction" method="input"> <action name="database" class="databaseAction" method="input">
<result name="input">/WEB-INF/jsp/admin/database.jsp</result> <result name="input">/WEB-INF/jsp/admin/database.jsp</result>
<result name="success" type="redirect-action">
<param name="actionName">database</param>
</result>
</action> </action>
<action name="updateDatabase" class="schedulerAction" method="updateDatabase"> <action name="updateDatabase" class="schedulerAction" method="updateDatabase">

View File

@ -92,7 +92,7 @@
<tr> <tr>
<td class="${bgcolor}"> <td class="${bgcolor}">
<ww:checkbox name="enabledUnprocessedConsumer[]" theme="simple" value="${consumer.enabled}" /> <input type="checkbox" name="enabledUnprocessedConsumers" theme="simple" value="${consumer.id}" <c:if test="${consumer.enabled}">checked</c:if> />
</td> </td>
<td class="${bgcolor}"> <td class="${bgcolor}">
<c:if test="${consumer.enabled}"> <c:if test="${consumer.enabled}">
@ -147,7 +147,7 @@
<tr> <tr>
<td class="${bgcolor}"> <td class="${bgcolor}">
<ww:checkbox name="enabledCleanupConsumer[]" theme="simple" value="${consumer.enabled}" /> <input type="checkbox" name="enabledCleanupConsumers" theme="simple" value="${consumer.id}" <c:if test="${consumer.enabled}">checked</c:if> />
</td> </td>
<td class="${bgcolor}"> <td class="${bgcolor}">
<c:if test="${consumer.enabled}"> <c:if test="${consumer.enabled}">