From fa31d5bba58d7c0268ea59e63181cfc688da15f4 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 14 Sep 2012 09:27:56 +0000 Subject: [PATCH] [MRM-918] Switch for disabling user registration. implements backend part. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384695 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/mdo/configuration.mdo | 6 ++++++ .../admin/model/beans/UiConfiguration.java | 16 ++++++++++++++++ .../admin/ArchivaAdministrationTest.java | 5 ++++- .../ArchivaAdministrationServiceTest.java | 3 +++ pom.xml | 1 + 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 8692e7c50..bcc007dd0 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -1324,6 +1324,12 @@ 1.4.0+ String + + disableRegistration + 1.4.0+ + boolean + false + diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/UiConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/UiConfiguration.java index a2c00e49f..aa3d13fda 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/UiConfiguration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/UiConfiguration.java @@ -47,6 +47,11 @@ public class UiConfiguration */ private String applicationUrl; + /** + * @since 1.4-M3 + */ + private boolean disableRegistration = false; + public UiConfiguration() { // noop @@ -92,6 +97,16 @@ public class UiConfiguration this.applicationUrl = applicationUrl; } + public boolean isDisableRegistration() + { + return disableRegistration; + } + + public void setDisableRegistration( boolean disableRegistration ) + { + this.disableRegistration = disableRegistration; + } + @Override public String toString() { @@ -101,6 +116,7 @@ public class UiConfiguration sb.append( ", appletFindEnabled=" ).append( appletFindEnabled ); sb.append( ", disableEasterEggs=" ).append( disableEasterEggs ); sb.append( ", applicationUrl='" ).append( applicationUrl ).append( '\'' ); + sb.append( ", disableRegistration=" ).append( disableRegistration ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java index f971c792e..5abd7a6fa 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java @@ -226,11 +226,13 @@ public class ArchivaAdministrationTest assertFalse( oldUi.isDisableEasterEggs() ); assertTrue( oldUi.isAppletFindEnabled() ); assertTrue( oldUi.isShowFindArtifacts() ); + assertFalse( oldUi.isDisableRegistration() ); UiConfiguration ui = archivaAdministration.getUiConfiguration(); ui.setAppletFindEnabled( false ); ui.setShowFindArtifacts( false ); ui.setDisableEasterEggs( true ); + ui.setDisableRegistration( true ); archivaAdministration.updateUiConfiguration( ui ); @@ -239,7 +241,8 @@ public class ArchivaAdministrationTest assertTrue( ui.isDisableEasterEggs() ); assertFalse( ui.isAppletFindEnabled() ); assertFalse( ui.isShowFindArtifacts() ); - + assertTrue( ui.isDisableRegistration() ); + archivaAdministration.updateUiConfiguration( oldUi ); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java index ddf1fac03..9c9e18653 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java @@ -117,6 +117,7 @@ public class ArchivaAdministrationServiceTest assertNotNull( ui ); // assert default values assertFalse( ui.isDisableEasterEggs() ); + assertFalse( ui.isDisableRegistration() ); assertTrue( ui.isAppletFindEnabled() ); assertTrue( ui.isShowFindArtifacts() ); assertNull( ui.getApplicationUrl() ); @@ -124,6 +125,7 @@ public class ArchivaAdministrationServiceTest ui.setAppletFindEnabled( false ); ui.setShowFindArtifacts( false ); ui.setDisableEasterEggs( true ); + ui.setDisableRegistration( true ); String url = "http://foo.fr/bar"; ui.setApplicationUrl( url ); @@ -132,6 +134,7 @@ public class ArchivaAdministrationServiceTest ui = getArchivaAdministrationService().getUiConfiguration(); assertTrue( ui.isDisableEasterEggs() ); + assertTrue( ui.isDisableRegistration() ); assertFalse( ui.isAppletFindEnabled() ); assertFalse( ui.isShowFindArtifacts() ); assertEquals( url, ui.getApplicationUrl() ); diff --git a/pom.xml b/pom.xml index bfb2f3758..0e5e5c2fa 100644 --- a/pom.xml +++ b/pom.xml @@ -1828,6 +1828,7 @@ .idea/** .repository/** *.patch + **/target/**