From 3c92bc1b406480f6d65c413bedd45a84eb3df874 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 10 Sep 2011 07:33:38 +0000 Subject: [PATCH] [MRM-1514] api to configure OrganisationInfo git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167472 13f79535-47bb-0310-9956-ffa450edef68 --- .../admin/ArchivaAdministration.java | 6 ++++ .../admin/DefaultArchivaAdministration.java | 30 +++++++++++++++++++ .../admin/ArchivaAdministrationTest.java | 22 ++++++++++++++ 3 files changed, 58 insertions(+) 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() ); + + } } -- 2.39.5