From: Olivier Lamy Date: Sat, 10 Sep 2011 08:25:08 +0000 (+0000) Subject: [MRM-1514] api to configure OrganisationInfo : use it in webapp X-Git-Tag: archiva-1.4-M1~332 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b9ae9f3e799f2d5ca3736af278edfef5956018d8;p=archiva.git [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 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java index 4d6b8c28a..c3feab958 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java @@ -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 = archivaAdministration.getOrganisationInformation(); + if ( orgInfo != null ) { - OrganisationInformation orgInfo = config.getOrganisationInfo(); - if ( orgInfo != null ) - { - setOrganisationLogo( orgInfo.getLogoLocation() ); - setOrganisationName( orgInfo.getName() ); - setOrganisationUrl( orgInfo.getUrl() ); - } + setOrganisationLogo( orgInfo.getLogoLocation() ); + setOrganisationName( orgInfo.getName() ); + setOrganisationUrl( orgInfo.getUrl() ); } + + } + + public ArchivaAdministration getArchivaAdministration() + { + return archivaAdministration; + } + + public void setArchivaAdministration( ArchivaAdministration archivaAdministration ) + { + this.archivaAdministration = archivaAdministration; } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java index e0af7ca2e..647cae7ae 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java @@ -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 ); - } - orgInfo.setLogoLocation( getOrganisationLogo() ); - orgInfo.setName( getOrganisationName() ); - orgInfo.setUrl( getOrganisationUrl() ); + OrganisationInformation orgInfo = archivaAdministration.getOrganisationInformation(); - configuration.save( config ); - } + orgInfo.setLogoLocation( getOrganisationLogo() ); + orgInfo.setName( getOrganisationName() ); + orgInfo.setUrl( getOrganisationUrl() ); + + archivaAdministration.setOrganisationInformation( orgInfo ); return SUCCESS; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java index 86a01fdb8..86c62826a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java @@ -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 ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java index 88e85b0a6..0f1ceb7aa 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java @@ -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() ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java index 61d6175ab..acd15ac90 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java @@ -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(); } }