summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-09-14 09:28:23 +0000
committerOlivier Lamy <olamy@apache.org>2012-09-14 09:28:23 +0000
commit745421c23020c68c34f524e43882623cceea8b0f (patch)
treeb49b8268a9d7a3937fcbafbfbb2b3ab1f17943c9
parentfa31d5bba58d7c0268ea59e63181cfc688da15f4 (diff)
downloadarchiva-745421c23020c68c34f524e43882623cceea8b0f.tar.gz
archiva-745421c23020c68c34f524e43882623cceea8b0f.zip
[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
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java7
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java9
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js8
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js62
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html10
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="<a href='"+url+"' class='brand'>";
- if (data.logoLocation) {
- link+="<img src='"+data.logoLocation+"' style='max-height: 30px'/>";
- } 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="<a href='"+url+"' class='brand'>";
+ if (data.logoLocation) {
+ link+="<img src='"+data.logoLocation+"' style='max-height: 30px'/>";
+ } else if (data.name) {
+ link+=data.name;
+ } else {
+ link+="Archiva";
+ }
+ link+="</a>";
+ organisationLogo.html(link);
}
- link+="</a>";
- organisationLogo.html(link);
- }
- if (!data.url && data.name){
- organisationLogo.html("<a href='/' class='brand'>"+data.name+"</a>");
- }
- if (!data.url && !data.name){
+ if (!data.url && data.name){
+ organisationLogo.html("<a href='/' class='brand'>"+data.name+"</a>");
+ }
+ if (!data.url && !data.name){
+ organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
+ }
+ },
+ error: function() {
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
}
- },
- error: function() {
- organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
- }
- });
+ });
+ }});
};
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 @@
<div class="control-group">
<label class="control-label" for="maxTotal">${$.i18n.prop('ui-configuration.applicationUrl')}</label>
<div class="controls">
- <input type="text" class="xlarge required digits" id="applicationUrl" name="applicationUrl" size="8"
+ <input type="text" class="input-xlarge required digits" id="applicationUrl" name="applicationUrl" size="8"
data-bind="value: uiConfiguration().applicationUrl"/>
</div>
</div>
+
+ <div class="control-group">
+ <label class="control-label" for="disableRegistration">${$.i18n.prop('ui-configuration.applicationUrl.disableRegistration')}</label>
+ <div class="controls">
+ <input type="checkbox" id="disableRegistration" name="disableRegistration" data-bind="checked: uiConfiguration().disableRegistration"/>
+ </div>
+ </div>
+
</fieldset>
<button id="ui-configuration-btn-save" data-bind="click: save" class="btn">${$.i18n.prop('save')}</button>
</form>