From: Olivier Lamy Date: Sat, 10 Sep 2011 07:33:38 +0000 (+0000) Subject: [MRM-1514] api to configure OrganisationInfo X-Git-Tag: archiva-1.4-M1~334 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3c92bc1b406480f6d65c413bedd45a84eb3df874;p=archiva.git [MRM-1514] api to configure OrganisationInfo git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167472 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/ArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/ArchivaAdministration.java index 3dbe0c287..48a365faf 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/ArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/ArchivaAdministration.java @@ -81,4 +81,10 @@ public interface ArchivaAdministration void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation ) throws RepositoryAdminException; + OrganisationInformation getOrganisationInformation() + throws RepositoryAdminException; + + void setOrganisationInformation( OrganisationInformation organisationInformation ) + throws RepositoryAdminException; + } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java index 4c60ffda7..084869214 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java @@ -252,6 +252,36 @@ public class DefaultArchivaAdministration getArchivaConfiguration().getConfiguration().getRepositoryScanning().getInvalidContentConsumers() ); } + public OrganisationInformation getOrganisationInformation() + throws RepositoryAdminException + { + org.apache.maven.archiva.configuration.OrganisationInformation organisationInformation = + getArchivaConfiguration().getConfiguration().getOrganisationInfo(); + if ( organisationInformation == null ) + { + return null; + } + return new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class ); + } + + public void setOrganisationInformation( OrganisationInformation organisationInformation ) + throws RepositoryAdminException + { + Configuration configuration = getArchivaConfiguration().getConfiguration(); + if ( organisationInformation != null ) + { + org.apache.maven.archiva.configuration.OrganisationInformation organisationInformationModel = + new BeanReplicator().replicateBean( organisationInformation, + org.apache.maven.archiva.configuration.OrganisationInformation.class ); + configuration.setOrganisationInfo( organisationInformationModel ); + } + else + { + configuration.setOrganisationInfo( null ); + } + saveConfiguration( configuration ); + } + //------------------------- // //------------------------- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java index d9d1d03ba..c51c12664 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java @@ -165,4 +165,26 @@ public class ArchivaAdministrationTest mockAuditListener.clearEvents(); } + + + public void organisationInfoUpdate() + throws Exception + { + OrganisationInformation organisationInformation = archivaAdministration.getOrganisationInformation(); + assertNull( organisationInformation ); + + organisationInformation = new OrganisationInformation(); + organisationInformation.setLogoLocation( "http://foo.com/bar.png" ); + organisationInformation.setName( "foo org" ); + organisationInformation.setUrl( "http:/foo.com" ); + + archivaAdministration.setOrganisationInformation( organisationInformation ); + + organisationInformation = archivaAdministration.getOrganisationInformation(); + assertNotNull( organisationInformation ); + assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() ); + assertEquals( "foo org", organisationInformation.getName() ); + assertEquals( "http://foo.com", organisationInformation.getUrl() ); + + } }