simplify the repository configuration pages

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@579036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2007-09-25 02:13:13 +00:00
parent 503001adf3
commit 0222469bc6
12 changed files with 222 additions and 331 deletions

View File

@ -19,12 +19,14 @@ package org.apache.maven.archiva.web.action.admin.repositories;
* under the License.
*/
import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
import org.apache.maven.archiva.configuration.InvalidConfigurationException;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
@ -36,10 +38,15 @@ import java.io.IOException;
/**
* Base class for repository configuration actions.
*/
public class AbstractConfigureRepositoryAction
public abstract class AbstractConfigureRepositoryAction<T extends AbstractRepositoryConfiguration>
extends PlexusActionSupport
implements SecureAction
{
/**
* The model for this action.
*/
protected T repository;
/**
* @plexus.requirement
*/
@ -47,25 +54,16 @@ public class AbstractConfigureRepositoryAction
protected String repoid;
// TODO: consider removing? was just meant to be for delete...
protected String mode;
// TODO: rename to confirmDelete
public String confirm()
{
return INPUT;
}
public String getMode()
{
return this.mode;
}
public String getRepoid()
{
return repoid;
}
public T getRepository()
{
return repository;
}
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
@ -77,11 +75,6 @@ public class AbstractConfigureRepositoryAction
return bundle;
}
public void setMode( String mode )
{
this.mode = mode;
}
public void setRepoid( String repoid )
{
this.repoid = repoid;
@ -92,13 +85,6 @@ public class AbstractConfigureRepositoryAction
this.archivaConfiguration = archivaConfiguration;
}
public String edit()
{
this.mode = "edit";
return INPUT;
}
protected String saveConfiguration( Configuration configuration )
throws IOException, InvalidConfigurationException, RegistryException
{
@ -110,9 +96,85 @@ public class AbstractConfigureRepositoryAction
catch ( IndeterminateConfigurationException e )
{
addActionError( e.getMessage() );
return INPUT;
return ERROR;
}
return SUCCESS;
}
public String add()
{
Configuration configuration = archivaConfiguration.getConfiguration();
String repoId = repository.getId();
if ( configuration.getManagedRepositoriesAsMap().containsKey( repoId ) ||
configuration.getRemoteRepositoriesAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id",
"Unable to add new repository with id [" + repoId + "], that id already exists." );
return INPUT;
}
boolean containsError = validateFields( configuration );
if ( containsError )
{
return INPUT;
}
return saveRepositoryConfiguration( configuration );
}
public String edit()
{
Configuration configuration = archivaConfiguration.getConfiguration();
boolean containsError = validateFields( configuration );
if ( containsError )
{
return INPUT;
}
removeRepository( repository.getId(), configuration );
return saveRepositoryConfiguration( configuration );
}
protected String saveRepositoryConfiguration( Configuration configuration )
{
String result;
try
{
addRepository( repository, configuration );
result = saveConfiguration( configuration );
}
catch ( IOException e )
{
addActionError( "I/O Exception: " + e.getMessage() );
result = ERROR;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Invalid Configuration Exception: " + e.getMessage() );
result = ERROR;
}
catch ( RegistryException e )
{
addActionError( "Configuration Registry Exception: " + e.getMessage() );
result = ERROR;
}
catch ( RoleManagerException e )
{
addActionError( "Security role creation Exception: " + e.getMessage() );
result = ERROR;
}
return result;
}
protected abstract boolean validateFields( Configuration config );
protected abstract void addRepository( T repository, Configuration configuration )
throws IOException, RoleManagerException;
protected abstract void removeRepository( String repoId, Configuration configuration );
}

View File

@ -24,7 +24,6 @@ import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.InvalidConfigurationException;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.registry.RegistryException;
import java.io.IOException;
@ -35,25 +34,12 @@ import java.io.IOException;
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRemoteRepositoryAction"
*/
public class ConfigureRemoteRepositoryAction
extends AbstractConfigureRepositoryAction
extends AbstractConfigureRepositoryAction<RemoteRepositoryConfiguration>
implements Preparable
{
/**
* The model for this action.
*/
private RemoteRepositoryConfiguration repository;
public String add()
{
this.mode = "add";
return INPUT;
}
public String delete()
{
RemoteRepositoryConfiguration existingRepository = repository;
if ( existingRepository == null )
if ( repository == null )
{
addActionError( "A repository with that id does not exist" );
return ERROR;
@ -69,27 +55,22 @@ public class ConfigureRemoteRepositoryAction
catch ( IOException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = INPUT;
result = ERROR;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = INPUT;
result = ERROR;
}
catch ( RegistryException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = INPUT;
result = ERROR;
}
return result;
}
public RemoteRepositoryConfiguration getRepository()
{
return repository;
}
public void prepare()
{
String id = repoid;
@ -103,58 +84,7 @@ public class ConfigureRemoteRepositoryAction
}
}
public String save()
{
String repoId = repository.getId();
Configuration configuration = archivaConfiguration.getConfiguration();
boolean containsError = validateFields( configuration );
if ( containsError && StringUtils.equalsIgnoreCase( "add", mode ) )
{
return INPUT;
}
else if ( containsError && StringUtils.equalsIgnoreCase( "edit", this.mode ) )
{
return ERROR;
}
if ( StringUtils.equalsIgnoreCase( "edit", this.mode ) )
{
removeRepository( repoId, configuration );
}
String result;
try
{
addRepository( repository, configuration );
result = saveConfiguration( configuration );
}
catch ( IOException e )
{
addActionError( "I/O Exception: " + e.getMessage() );
result = INPUT;
}
catch ( RoleManagerException e )
{
addActionError( "Role Manager Exception: " + e.getMessage() );
result = INPUT;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Invalid Configuration Exception: " + e.getMessage() );
result = INPUT;
}
catch ( RegistryException e )
{
addActionError( "Configuration Registry Exception: " + e.getMessage() );
result = INPUT;
}
return result;
}
private boolean validateFields( Configuration config )
protected boolean validateFields( Configuration config )
{
// TODO: push this into the webwork validation instead
boolean containsError = false;
@ -165,15 +95,6 @@ public class ConfigureRemoteRepositoryAction
addFieldError( "repository.id", "You must enter a repository identifier." );
containsError = true;
}
//if edit mode, do not validate existence of repoId
else if ( ( config.getManagedRepositoriesAsMap().containsKey( repoId ) ||
config.getRemoteRepositoriesAsMap().containsKey( repoId ) ) &&
!StringUtils.equalsIgnoreCase( mode, "edit" ) )
{
addFieldError( "repository.id",
"Unable to add new repository with id [" + repoId + "], that id already exists." );
containsError = true;
}
if ( StringUtils.isBlank( repository.getUrl() ) )
{
@ -189,13 +110,12 @@ public class ConfigureRemoteRepositoryAction
return containsError;
}
private void addRepository( RemoteRepositoryConfiguration repository, Configuration configuration )
throws IOException, RoleManagerException
protected void addRepository( RemoteRepositoryConfiguration repository, Configuration configuration )
{
configuration.addRemoteRepository( repository );
}
private void removeRepository( String repoId, Configuration configuration )
protected void removeRepository( String repoId, Configuration configuration )
{
RemoteRepositoryConfiguration toremove = configuration.findRemoteRepositoryById( repoId );
if ( toremove != null )
@ -203,4 +123,9 @@ public class ConfigureRemoteRepositoryAction
configuration.removeRemoteRepository( toremove );
}
}
public String input()
{
return INPUT;
}
}

View File

@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.repositories;
*/
import com.opensymphony.xwork.Preparable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
@ -33,8 +32,6 @@ import org.codehaus.plexus.scheduler.CronExpressionValidator;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Configures the managed repositories.
@ -42,95 +39,88 @@ import java.util.List;
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction"
*/
public class ConfigureRepositoryAction
extends AbstractConfigureRepositoryAction
extends AbstractConfigureRepositoryAction<ManagedRepositoryConfiguration>
implements Preparable
{
/**
* The model for this action.
*/
private ManagedRepositoryConfiguration repository;
/**
* @plexus.requirement role-hint="default"
*/
protected RoleManager roleManager;
private static final List<String> VALID_MODES;
private String deleteMode = "delete-entry";
static
public String getDeleteMode()
{
VALID_MODES = new ArrayList<String>();
VALID_MODES.add( "add" );
VALID_MODES.add( "edit" );
return deleteMode;
}
public String add()
public void setDeleteMode( String deleteMode )
{
this.mode = "add";
this.deleteMode = deleteMode;
}
public String addInput()
{
// set defaults
this.repository.setReleases( true );
this.repository.setScanned( true );
return this.mode;
return INPUT;
}
public String editInput()
{
return INPUT;
}
public String delete()
{
String result = SUCCESS;
if ( StringUtils.equals( mode, "delete-entry" ) || StringUtils.equals( mode, "delete-contents" ) )
if ( repository == null )
{
ManagedRepositoryConfiguration existingRepository = repository;
if ( existingRepository == null )
{
addActionError( "A repository with that id does not exist" );
return ERROR;
}
addActionError( "A repository with that id does not exist" );
return ERROR;
}
try
{
Configuration configuration = archivaConfiguration.getConfiguration();
removeRepository( repoid, configuration );
result = saveConfiguration( configuration );
String result;
try
{
Configuration configuration = archivaConfiguration.getConfiguration();
removeRepository( repoid, configuration );
result = saveConfiguration( configuration );
if ( result.equals( SUCCESS ) )
if ( result.equals( SUCCESS ) )
{
removeRepositoryRoles( repository );
if ( StringUtils.equals( deleteMode, "delete-contents" ) )
{
removeRepositoryRoles( existingRepository );
if ( StringUtils.equals( mode, "delete-contents" ) )
{
removeContents( existingRepository );
}
removeContents( repository );
}
}
catch ( IOException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( RoleManagerException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( RegistryException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
}
catch ( IOException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( RoleManagerException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
catch ( RegistryException e )
{
addActionError( "Unable to delete repository: " + e.getMessage() );
result = ERROR;
}
return result;
}
public ManagedRepositoryConfiguration getRepository()
{
return repository;
}
public void prepare()
{
String id = repoid;
@ -146,68 +136,7 @@ public class ConfigureRepositoryAction
}
}
public String save()
{
// Ensure a proper mode is set.
if ( StringUtils.isBlank( this.mode ) )
{
addActionError( "Unable to process save request. edit mode undefined. " );
return ERROR;
}
if ( !VALID_MODES.contains( this.mode.toLowerCase() ) )
{
addActionError( "Unable to process save request. edit mode is invalid." );
return ERROR;
}
// Ensure that the fields are valid.
Configuration configuration = archivaConfiguration.getConfiguration();
boolean containsError = validateFields( configuration );
if ( containsError )
{
return this.mode.toLowerCase();
}
// If we are in edit mode, then remove the old repository configuration.
if ( StringUtils.equalsIgnoreCase( "edit", this.mode ) )
{
removeRepository( repository.getId(), configuration );
}
// Save the repository configuration.
String result;
try
{
addRepository( repository, configuration );
result = saveConfiguration( configuration );
}
catch ( IOException e )
{
addActionError( "I/O Exception: " + e.getMessage() );
result = ERROR;
}
catch ( RoleManagerException e )
{
addActionError( "Role Manager Exception: " + e.getMessage() );
result = ERROR;
}
catch ( InvalidConfigurationException e )
{
addActionError( "Invalid Configuration Exception: " + e.getMessage() );
result = ERROR;
}
catch ( RegistryException e )
{
addActionError( "Configuration Registry Exception: " + e.getMessage() );
result = ERROR;
}
return result;
}
private boolean validateFields( Configuration config )
protected boolean validateFields( Configuration config )
{
boolean containsError = false;
CronExpressionValidator validator = new CronExpressionValidator();
@ -218,23 +147,6 @@ public class ConfigureRepositoryAction
addFieldError( "repository.id", "You must enter a repository identifier." );
containsError = true;
}
// Validate the existance of the repository id, but not in edit mode.
else if ( !StringUtils.equalsIgnoreCase( mode, "edit" ) )
{
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ "], that id already exists as a managed repository." );
containsError = true;
}
if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
{
addFieldError( "repository.id", "Unable to add new repository with id [" + repoId
+ "], that id already exists as a remote repository." );
containsError = true;
}
}
if ( StringUtils.isBlank( repository.getLocation() ) )
{
@ -255,7 +167,7 @@ public class ConfigureRepositoryAction
return containsError;
}
private void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
throws IOException, RoleManagerException
{
// Normalize the path
@ -285,7 +197,7 @@ public class ConfigureRepositoryAction
FileUtils.deleteDirectory( new File( existingRepository.getLocation() ) );
}
private void removeRepository( String repoId, Configuration configuration )
protected void removeRepository( String repoId, Configuration configuration )
{
ManagedRepositoryConfiguration toremove = configuration.findManagedRepositoryById( repoId );
if ( toremove != null )

View File

@ -230,54 +230,52 @@
<action name="addRepository" class="configureRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/addRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="editRepository" class="configureRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editRepository.jsp</result>
<result name="error" type="redirect-action">repositories</result>
<result name="error">/WEB-INF/jsp/admin/editRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="saveRepository" class="configureRepositoryAction" method="save">
<result name="success" type="redirect-action">repositories</result>
<result name="add">/WEB-INF/jsp/admin/addRepository.jsp</result>
<result name="edit">/WEB-INF/jsp/admin/editRepository.jsp</result>
<result name="input">/WEB-INF/jsp/admin/editRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<action name="confirmDeleteRepository" class="configureRepositoryAction">
<result>/WEB-INF/jsp/admin/deleteRepository.jsp</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="deleteRepository" class="configureRepositoryAction" method="confirm">
<action name="deleteRepository" class="configureRepositoryAction" method="delete">
<result name="input">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/deleteRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="addRemoteRepository" class="configureRemoteRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addRemoteRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/addRemoteRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="editRemoteRepository" class="configureRemoteRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editRemoteRepository.jsp</result>
<result name="error" type="redirect-action">repositories</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="saveRemoteRepository" class="configureRemoteRepositoryAction" method="save">
<result name="success" type="redirect-action">repositories</result>
<result name="input">/WEB-INF/jsp/admin/editRemoteRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/editRemoteRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="deleteRemoteRepository" class="configureRemoteRepositoryAction" method="confirm">
<action name="confirmDeleteRemoteRepository" class="configureRemoteRepositoryAction">
<result>/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="deleteRemoteRepository" class="configureRemoteRepositoryAction" method="delete">
<result name="input">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
<result name="error">/WEB-INF/jsp/admin/deleteRemoteRepository.jsp</result>
<result name="success" type="redirect-action">repositories</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>

View File

@ -34,15 +34,14 @@
<h2>Add Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="saveRemoteRepository" namespace="/admin" validate="true">
<ww:hidden name="mode" value="add"/>
<ww:form method="post" action="addRemoteRepository" namespace="/admin" validate="true">
<ww:textfield name="repository.id" label="Identifier" size="10" required="true"/>
<%@ include file="/WEB-INF/jsp/admin/include/remoteRepositoryForm.jspf" %>
<ww:submit value="Add Repository"/>
</ww:form>
<script type="text/javascript">
document.getElementById("saveRemoteRepository_id").focus();
document.getElementById("addRemoteRepository_id").focus();
</script>
</div>

View File

@ -34,15 +34,14 @@
<h2>Add Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="saveRepository" namespace="/admin" validate="true">
<ww:hidden name="mode" value="add"/>
<ww:form method="post" action="addRepository" namespace="/admin" validate="true">
<ww:textfield name="repository.id" label="Identifier" size="10" required="true"/>
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
<ww:submit value="Add Repository"/>
</ww:form>
<script type="text/javascript">
document.getElementById("saveRepository_id").focus();
document.getElementById("addRepository_id").focus();
</script>
</div>

View File

@ -39,12 +39,13 @@
<strong><span class="statusFailed">WARNING:</span> This operation can not be undone.</strong>
</blockquote>
<ww:form method="post" action="deleteRepository!delete" namespace="/admin" validate="true">
<ww:form method="post" action="deleteRepository" namespace="/admin" validate="true">
<ww:hidden name="repoid"/>
<ww:radio list="#@java.util.LinkedHashMap@{'delete-contents' : 'Remove the repository and delete its contents from disk',
'delete-entry' : 'Remove the repository from the management list, but leave the contents unmodified',
'unmodified' : 'Leave the repository unmodified'}" name="mode" theme="archiva"/>
<ww:submit value="Go"/>
'delete-entry' : 'Remove the repository from the management list, but leave the contents unmodified'}"
name="deleteMode" theme="archiva"/>
<ww:submit value="Confirm" method="delete"/>
<ww:submit value="Cancel" method="execute"/>
</ww:form>
</div>

View File

@ -36,15 +36,14 @@
<h2>Edit Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="saveRemoteRepository" namespace="/admin" validate="false">
<ww:hidden name="mode" value="edit"/>
<ww:form method="post" action="editRemoteRepository" namespace="/admin" validate="false">
<ww:hidden name="repository.id"/>
<%@ include file="/WEB-INF/jsp/admin/include/remoteRepositoryForm.jspf" %>
<ww:submit value="Update Repository"/>
</ww:form>
<script type="text/javascript">
document.getElementById("saveRemoteRepository_repository_name").focus();
document.getElementById("editRemoteRepository_repository_name").focus();
</script>
</div>

View File

@ -36,15 +36,14 @@
<h2>Edit Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="saveRepository" namespace="/admin" validate="false">
<ww:hidden name="mode" value="edit"/>
<ww:form method="post" action="editRepository" namespace="/admin" validate="false">
<ww:hidden name="repository.id"/>
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
<ww:submit value="Update Repository"/>
</ww:form>
<script type="text/javascript">
document.getElementById("saveRepository_repository_name").focus();
document.getElementById("editRepository_repository_name").focus();
</script>
</div>

View File

@ -40,7 +40,7 @@
<div class="admin">
<div class="controls">
<redback:ifAuthorized permission="archiva-manage-configuration">
<ww:url id="addRepositoryUrl" action="addRepository"/>
<ww:url id="addRepositoryUrl" action="addRepository" method="addInput"/>
<ww:a href="%{addRepositoryUrl}">
<img src="<c:url value="/images/icons/create.png" />" alt="" width="16" height="16"/>
Add
@ -72,10 +72,10 @@
<div class="controls">
<%-- TODO: make some icons --%>
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
<ww:url id="editRepositoryUrl" action="editRepository">
<ww:url id="editRepositoryUrl" action="editRepository" method="editInput">
<ww:param name="repoid" value="%{'${repository.id}'}"/>
</ww:url>
<ww:url id="deleteRepositoryUrl" action="deleteRepository" method="confirm">
<ww:url id="deleteRepositoryUrl" action="confirmDeleteRepository">
<ww:param name="repoid" value="%{'${repository.id}'}"/>
</ww:url>
<ww:a href="%{editRepositoryUrl}">
@ -230,7 +230,7 @@
<div class="controls">
<redback:ifAuthorized permission="archiva-manage-configuration">
<ww:url id="addRepositoryUrl" action="addRemoteRepository"/>
<ww:url id="addRepositoryUrl" action="addRemoteRepository" method="input"/>
<ww:a href="%{addRepositoryUrl}">
<img src="<c:url value="/images/icons/create.png" />" alt="" width="16" height="16"/>
Add
@ -260,16 +260,16 @@
<div class="controls">
<redback:ifAnyAuthorized permissions="archiva-manage-configuration">
<ww:url id="editRepositoryUrl" action="editRemoteRepository">
<ww:param name="repoid" value="%{'${repository.id}'}"/>
</ww:url>
<ww:url id="deleteRepositoryUrl" action="deleteRemoteRepository" method="confirm">
<ww:url id="editRepositoryUrl" action="editRemoteRepository" method="input">
<ww:param name="repoid" value="%{'${repository.id}'}"/>
</ww:url>
<ww:a href="%{editRepositoryUrl}">
<img src="<c:url value="/images/icons/edit.png" />" alt="" width="16" height="16"/>
Edit
</ww:a>
<ww:url id="deleteRepositoryUrl" action="confirmDeleteRemoteRepository">
<ww:param name="repoid" value="%{'${repository.id}'}"/>
</ww:url>
<ww:a href="%{deleteRepositoryUrl}">
<img src="<c:url value="/images/icons/delete.gif" />" alt="" width="16" height="16"/>
Delete

View File

@ -83,12 +83,11 @@ public class ConfigureRemoteRepositoryActionTest
action.prepare();
assertNull( action.getRepoid() );
assertNull( action.getMode() );
RemoteRepositoryConfiguration configuration = action.getRepository();
assertNotNull( configuration );
assertNull( configuration.getId() );
String status = action.add();
String status = action.input();
assertEquals( Action.INPUT, status );
}
@ -104,11 +103,10 @@ public class ConfigureRemoteRepositoryActionTest
archivaConfigurationControl.replay();
action.prepare();
action.setMode( "add" );
RemoteRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
String status = action.save();
String status = action.add();
assertEquals( Action.SUCCESS, status );
assertEquals( Collections.singletonList( repository ), configuration.getRemoteRepositories() );
@ -129,12 +127,11 @@ public class ConfigureRemoteRepositoryActionTest
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
RemoteRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
String status = action.edit();
String status = action.input();
assertEquals( Action.INPUT, status );
repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
@ -152,12 +149,11 @@ public class ConfigureRemoteRepositoryActionTest
archivaConfigurationControl.replay();
action.prepare();
action.setMode( "edit" );
RemoteRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
repository.setName( "new repo name" );
String status = action.save();
String status = action.edit();
assertEquals( Action.SUCCESS, status );
RemoteRepositoryConfiguration newRepository = createRepository();
@ -169,6 +165,7 @@ public class ConfigureRemoteRepositoryActionTest
}
public void testDeleteRemoteRepositoryConfirmation()
throws Exception
{
RemoteRepositoryConfiguration originalRepository = createRepository();
Configuration configuration = createConfigurationForEditing( originalRepository );
@ -181,13 +178,12 @@ public class ConfigureRemoteRepositoryActionTest
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
RemoteRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
String status = action.confirm();
assertEquals( Action.INPUT, status );
String status = action.execute();
assertEquals( Action.SUCCESS, status );
repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
assertEquals( Collections.singletonList( originalRepository ), configuration.getRemoteRepositories() );

View File

@ -97,7 +97,6 @@ public class ConfigureRepositoryActionTest
action.prepare();
assertNull( action.getRepoid() );
assertNull( action.getMode() );
ManagedRepositoryConfiguration configuration = action.getRepository();
assertNotNull( configuration );
assertNull( configuration.getId() );
@ -107,7 +106,7 @@ public class ConfigureRepositoryActionTest
assertFalse( configuration.isReleases() );
assertFalse( configuration.isSnapshots() );
String status = action.add();
String status = action.addInput();
assertEquals( Action.INPUT, status );
// check defaults
@ -137,12 +136,11 @@ public class ConfigureRepositoryActionTest
archivaConfigurationControl.replay();
action.prepare();
action.setMode( "add" );
ManagedRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
assertFalse( location.exists() );
String status = action.save();
String status = action.add();
assertEquals( Action.SUCCESS, status );
assertTrue( location.exists() );
@ -165,12 +163,11 @@ public class ConfigureRepositoryActionTest
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
String status = action.edit();
String status = action.editInput();
assertEquals( Action.INPUT, status );
repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
@ -194,12 +191,11 @@ public class ConfigureRepositoryActionTest
archivaConfigurationControl.replay();
action.prepare();
action.setMode( "edit" );
ManagedRepositoryConfiguration repository = action.getRepository();
populateRepository( repository );
repository.setName( "new repo name" );
String status = action.save();
String status = action.edit();
assertEquals( Action.SUCCESS, status );
ManagedRepositoryConfiguration newRepository = createRepository();
@ -212,6 +208,7 @@ public class ConfigureRepositoryActionTest
}
public void testDeleteRepositoryConfirmation()
throws Exception
{
ManagedRepositoryConfiguration originalRepository = createRepository();
Configuration configuration = createConfigurationForEditing( originalRepository );
@ -224,13 +221,13 @@ public class ConfigureRepositoryActionTest
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertNull( action.getMode() );
ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
String status = action.confirm();
assertEquals( Action.INPUT, status );
String status = action.execute();
assertEquals( Action.SUCCESS, status );
assertEquals( "delete-entry", action.getDeleteMode() );
repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories() );
@ -239,7 +236,9 @@ public class ConfigureRepositoryActionTest
public void testDeleteRepositoryKeepContent()
throws RegistryException, IndeterminateConfigurationException
{
Configuration configuration = executeDeletionTest( "delete-entry", createRepository() );
Configuration configuration = prepDeletionTest( createRepository(), "delete-entry" );
String status = action.delete();
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
@ -249,7 +248,9 @@ public class ConfigureRepositoryActionTest
public void testDeleteRepositoryDeleteContent()
throws RegistryException, IndeterminateConfigurationException
{
Configuration configuration = executeDeletionTest( "delete-contents", createRepository() );
Configuration configuration = prepDeletionTest( createRepository(), "delete-contents" );
String status = action.delete();
assertEquals( Action.SUCCESS, status );
assertTrue( configuration.getManagedRepositories().isEmpty() );
@ -257,10 +258,12 @@ public class ConfigureRepositoryActionTest
}
public void testDeleteRepositoryCancelled()
throws RegistryException, IndeterminateConfigurationException
throws Exception
{
ManagedRepositoryConfiguration originalRepository = createRepository();
Configuration configuration = executeDeletionTest( "unmodified", originalRepository );
Configuration configuration = prepDeletionTest( originalRepository, null );
String status = action.execute();
assertEquals( Action.SUCCESS, status );
ManagedRepositoryConfiguration repository = action.getRepository();
assertRepositoryEquals( repository, createRepository() );
@ -269,7 +272,7 @@ public class ConfigureRepositoryActionTest
assertTrue( location.exists() );
}
private Configuration executeDeletionTest( String mode, ManagedRepositoryConfiguration originalRepository )
private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository, String mode )
throws RegistryException, IndeterminateConfigurationException
{
location.mkdirs();
@ -285,18 +288,16 @@ public class ConfigureRepositoryActionTest
archivaConfigurationControl.replay();
action.setRepoid( REPO_ID );
action.setMode( mode );
action.setDeleteMode( mode );
action.prepare();
assertEquals( REPO_ID, action.getRepoid() );
assertEquals( mode, action.getMode() );
assertEquals( mode, action.getDeleteMode() );
ManagedRepositoryConfiguration repository = action.getRepository();
assertNotNull( repository );
assertRepositoryEquals( repository, createRepository() );
assertTrue( location.exists() );
String status = action.delete();
assertEquals( Action.SUCCESS, status );
return configuration;
}
@ -343,7 +344,7 @@ public class ConfigureRepositoryActionTest
repository.setRetentionCount( 20 );
repository.setReleases( true );
repository.setSnapshots( true );
repository.setScanned( true );
repository.setScanned( false );
repository.setDeleteReleasedSnapshots( true );
}