From 745421c23020c68c34f524e43882623cceea8b0f Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 14 Sep 2012 09:28:23 +0000 Subject: [MRM-918] Switch for disabling user registration. implements ui part. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384696 13f79535-47bb-0310-9956-ffa450edef68 --- .../api/services/ArchivaAdministrationService.java | 7 +++ .../DefaultArchivaAdministrationService.java | 9 +++- .../src/main/webapp/js/archiva/general-admin.js | 8 ++- .../src/main/webapp/js/archiva/main.js | 62 +++++++++++++--------- .../webapp/js/templates/archiva/general-admin.html | 10 +++- 5 files changed, 65 insertions(+), 31 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java index 180dec9bf..f2a6133f9 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java @@ -207,6 +207,13 @@ public interface ArchivaAdministrationService UiConfiguration getUiConfiguration() throws ArchivaRestServiceException; + @Path( "registrationDisabled" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( noRestriction = true, noPermission = true ) + Boolean registrationDisabled() + throws ArchivaRestServiceException; + @Path( "setUiConfiguration" ) @POST @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java index 63aa63d09..bf0bad9e9 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java @@ -48,7 +48,7 @@ import java.util.List; * @author Olivier Lamy * @since 1.4-M1 */ -@Service( "archivaAdministrationService#default" ) +@Service ( "archivaAdministrationService#default" ) public class DefaultArchivaAdministrationService extends AbstractRestService implements ArchivaAdministrationService @@ -57,7 +57,7 @@ public class DefaultArchivaAdministrationService private ArchivaAdministration archivaAdministration; @Inject - @Named( value = "managedRepositoryContent#legacy" ) + @Named ( value = "managedRepositoryContent#legacy" ) private ManagedRepositoryContent repositoryContent; @Inject @@ -342,6 +342,11 @@ public class DefaultArchivaAdministrationService } } + public Boolean registrationDisabled() + throws ArchivaRestServiceException + { + return getUiConfiguration().isDisableRegistration(); + } public UiConfiguration getUiConfiguration() throws ArchivaRestServiceException diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 3a07cdf93..2034be330 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -573,14 +573,15 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" dataType: 'json', success: function(data){ mainContent.html($("#ui-configuration-screen").tmpl()); - var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,data.applicationUrl); + var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs, + data.applicationUrl,data.disableRegistration); var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration); ko.applyBindings(uiConfigurationViewModel,mainContent.get(0)); } }); } - UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl){ + UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl,disableRegistration){ this.showFindArtifacts = ko.observable(showFindArtifacts); this.appletFindEnabled = ko.observable(appletFindEnabled); @@ -588,6 +589,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.disableEasterEggs = ko.observable(disableEasterEggs); this.applicationUrl = ko.observable(applicationUrl); + + // default to false + this.disableRegistration = ko.observable(disableRegistration?disableRegistration:false); } UiConfigurationViewModel=function(uiConfiguration){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index da249ee3b..47c831271 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -126,35 +126,45 @@ function(jquery,ui,sammy,tmpl) { // Change UI with appearance settings // //------------------------------------// updateAppearanceToolBar=function() { - $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", { - type: "GET", - dataType: 'json', - success: function(data) { - var organisationLogo=$("#organisation-logo"); - if(data.url){ - var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url; - var link=""; - if (data.logoLocation) { - link+=""; - } else if (data.name) { - link+=data.name; - } else { - link+="Archiva"; + $.ajax("restServices/archivaServices/archivaAdministrationService/registrationDisabled", { + type: "GET", + dataType: 'json', + success: function(data) { + //var disableRegistration=data.disableRegistration; + if( data){ + $.log("disableRegistration"); + $("#topbar-menu").find("#register-link" ).hide(); + } + $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", { + type: "GET", + dataType: 'json', + success: function(data) { + var organisationLogo=$("#main-content").find("#organisation-logo"); + if(data.url){ + var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url; + var link=""; + if (data.logoLocation) { + link+=""; + } else if (data.name) { + link+=data.name; + } else { + link+="Archiva"; + } + link+=""; + organisationLogo.html(link); } - link+=""; - organisationLogo.html(link); - } - if (!data.url && data.name){ - organisationLogo.html(""+data.name+""); - } - if (!data.url && !data.name){ + if (!data.url && data.name){ + organisationLogo.html(""+data.name+""); + } + if (!data.url && !data.name){ + organisationLogo.html("Archiva"); + } + }, + error: function() { organisationLogo.html("Archiva"); } - }, - error: function() { - organisationLogo.html("Archiva"); - } - }); + }); + }}); }; diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html index eca846bd3..c5c12ee58 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html @@ -328,10 +328,18 @@
-
+ +
+ +
+ +
+
+ -- cgit v1.2.3