]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1514] api to configure OrganisationInfo : use it in webapp
authorOlivier Lamy <olamy@apache.org>
Sat, 10 Sep 2011 08:25:08 +0000 (08:25 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 10 Sep 2011 08:25:08 +0000 (08:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167475 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractAppearanceAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java

index 4d6b8c28aa07353bc8880381bdc923072b93cc55..c3feab958a9b1328b3ed4a6dddf4bec1a97d895b 100644 (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 = 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;
     }
 }
index e0af7ca2e7fa6bd2b9378d5749825b9e9fde4233..647cae7aea5c8896126d7bf4bd635714cfece2be 100644 (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 );
-            }
 
-            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;
     }
 
index 86a01fdb87beb915034333dd5e7dea03c7a91063..86c62826a3f15f1f9c614ff29ab483e4a6c37427 100644 (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 );
+
     }
 }
index 88e85b0a620bf91e80669b8a65a9be5ed396a6d8..0f1ceb7aa85595be3eac2289329aebdda7dfeb5e 100644 (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() );
index 61d6175ab063bf3420076e7d1852ab2938de70be..acd15ac905b3c72e4594ed268c3bccbb292d42b6 100644 (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();
     }
 }