[MRM-1514] api to configure OrganisationInfo : use it in webapp

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-10 08:25:08 +00:00
parent 1f05224168
commit b9ae9f3e79
5 changed files with 41 additions and 42 deletions

View File

@ -20,9 +20,8 @@ package org.apache.maven.archiva.web.action.admin.appearance;
*/
import com.opensymphony.xwork2.Preparable;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.OrganisationInformation;
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
import org.apache.archiva.admin.repository.admin.OrganisationInformation;
import org.apache.maven.archiva.web.action.AbstractActionSupport;
import javax.inject.Inject;
@ -38,7 +37,7 @@ public abstract class AbstractAppearanceAction
{
@Inject
protected ArchivaConfiguration configuration;
protected ArchivaAdministration archivaAdministration;
private String organisationLogo;
@ -46,11 +45,6 @@ public abstract class AbstractAppearanceAction
private String organisationName;
public void setConfiguration( ArchivaConfiguration configuration )
{
this.configuration = configuration;
}
public String getOrganisationLogo()
{
return organisationLogo;
@ -84,16 +78,24 @@ public abstract class AbstractAppearanceAction
public void prepare()
throws Exception
{
Configuration config = configuration.getConfiguration();
if ( config != null )
{
OrganisationInformation orgInfo = config.getOrganisationInfo();
OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
if ( orgInfo != null )
{
setOrganisationLogo( orgInfo.getLogoLocation() );
setOrganisationName( orgInfo.getName() );
setOrganisationUrl( orgInfo.getUrl() );
}
}
}
public ArchivaAdministration getArchivaAdministration()
{
return archivaAdministration;
}
public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
{
this.archivaAdministration = archivaAdministration;
}
}

View File

@ -20,13 +20,11 @@ package org.apache.maven.archiva.web.action.admin.appearance;
*/
import com.opensymphony.xwork2.Validateable;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import org.apache.archiva.admin.repository.admin.OrganisationInformation;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
import org.apache.maven.archiva.configuration.OrganisationInformation;
import org.codehaus.plexus.redback.rbac.Resource;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.redback.integration.interceptor.SecureAction;
import org.codehaus.redback.integration.interceptor.SecureActionBundle;
import org.codehaus.redback.integration.interceptor.SecureActionException;
@ -44,23 +42,16 @@ public class EditOrganisationInfoAction
{
@Override
public String execute()
throws RegistryException, IndeterminateConfigurationException
throws RepositoryAdminException
{
Configuration config = configuration.getConfiguration();
if ( config != null )
{
OrganisationInformation orgInfo = config.getOrganisationInfo();
if ( orgInfo == null )
{
config.setOrganisationInfo( orgInfo );
}
OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation();
orgInfo.setLogoLocation( getOrganisationLogo() );
orgInfo.setName( getOrganisationName() );
orgInfo.setUrl( getOrganisationUrl() );
configuration.save( config );
}
archivaAdministration.setOrganisationInformation( orgInfo );
return SUCCESS;
}

View File

@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.action.admin.appearance;
* under the License.
*/
import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
@ -50,17 +51,22 @@ public abstract class AbstractOrganizationInfoActionTest
configuration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
configuration.getConfiguration();
archivaConfigurationControl.setReturnValue( config, 1, 2 );
archivaConfigurationControl.setReturnValue( config, 1, 5 );
configuration.save( config );
archivaConfigurationControl.setVoidCallable( 1, 2 );
archivaConfigurationControl.setVoidCallable( 1, 4 );
archivaConfigurationControl.replay();
DefaultArchivaAdministration defaultArchivaAdministration = new DefaultArchivaAdministration();
defaultArchivaAdministration.setArchivaConfiguration( configuration );
getAction().setArchivaAdministration( defaultArchivaAdministration );
}
protected void reloadAction()
{
action = getAction();
action.setConfiguration( configuration );
( (DefaultArchivaAdministration) action.getArchivaAdministration() ).setArchivaConfiguration( configuration );
}
}

View File

@ -20,9 +20,9 @@ package org.apache.maven.archiva.web.action.admin.appearance;
*/
import com.opensymphony.xwork2.validator.ActionValidatorManager;
import org.apache.archiva.web.validator.utils.ValidatorUtil;
import org.apache.maven.archiva.configuration.OrganisationInformation;
import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
import org.apache.archiva.web.validator.utils.ValidatorUtil;
import java.util.ArrayList;
import java.util.HashMap;
@ -89,6 +89,8 @@ public class EditOrganizationInfoActionTest
action.execute();
orginfo = config.getOrganisationInfo();
assertEquals( "LOGO1", orginfo.getLogoLocation() );
assertEquals( "NAME1", orginfo.getName() );
assertEquals( "URL1", orginfo.getUrl() );

View File

@ -49,8 +49,6 @@ public class OrganizationInfoActionTest
@Override
protected AbstractAppearanceAction getAction()
{
//return (OrganisationInfoAction) lookup( Action.class.getName(), "organisationInfo" );
return (OrganisationInfoAction) getActionProxy( "/components/companyInfo.action" ).getAction();
}
}