From 5f43a65cd8ea0d320f1c942e613506539d40c7b9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 25 May 2012 12:33:18 +0000 Subject: [PATCH] use configured applicationUrl to send registration email git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1342595 13f79535-47bb-0310-9956-ffa450edef68 --- .../ArchivaAdministrationService.java | 16 +++- .../DefaultArchivaAdministrationService.java | 13 +++ .../main/webapp/js/archiva/general-admin.js | 5 -- .../src/main/webapp/js/redback/redback.js | 84 +++++++++++-------- 4 files changed, 77 insertions(+), 41 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 5bc34cfd4..180dec9bf 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 @@ -23,9 +23,9 @@ import org.apache.archiva.admin.model.beans.LegacyArtifactPath; import org.apache.archiva.admin.model.beans.NetworkConfiguration; import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; +import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.rest.api.model.AdminRepositoryConsumer; import org.apache.archiva.security.common.ArchivaRoleConstants; -import org.apache.archiva.redback.authorization.RedbackAuthorization; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -189,7 +189,7 @@ public interface ArchivaAdministrationService @Path( "getOrganisationInformation" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) - @RedbackAuthorization( noPermission = true, noRestriction = true) + @RedbackAuthorization( noPermission = true, noRestriction = true ) OrganisationInformation getOrganisationInformation() throws ArchivaRestServiceException; @@ -214,10 +214,20 @@ public interface ArchivaAdministrationService void setUiConfiguration( UiConfiguration uiConfiguration ) throws ArchivaRestServiceException; + @Path( "applicationUrl" ) + @GET + @Produces( MediaType.TEXT_PLAIN ) + @RedbackAuthorization( noRestriction = true, noPermission = true ) + /** + * @since 1.4-M3 + */ + String getApplicationUrl() + throws ArchivaRestServiceException; + @Path( "getNetworkConfiguration" ) @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) NetworkConfiguration getNetworkConfiguration() throws ArchivaRestServiceException; 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 abb4915b7..63aa63d09 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 @@ -369,6 +369,19 @@ public class DefaultArchivaAdministrationService } } + public String getApplicationUrl() + throws ArchivaRestServiceException + { + try + { + return archivaAdministration.getUiConfiguration().getApplicationUrl(); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage(), e ); + } + } + public NetworkConfiguration getNetworkConfiguration() 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 b925dfcad..2ac80163d 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 @@ -576,11 +576,6 @@ define("archiva.general-admin",["jquery","i18n","order!utils","order!jquery.tmpl var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,data.applicationUrl); var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration); ko.applyBindings(uiConfigurationViewModel,mainContent.get(0)); - /*var validator = mainContent.find("#network-configuration-edit-form").validate({ - showErrors: function(validator, errorMap, errorList) { - customShowError(mainContent.find("#network-configuration-edit-form" ).get(0),validator,errorMap,errorMap); - } - });*/ } }); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js index 116c376f3..f3bed7c82 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js @@ -116,11 +116,17 @@ define("redback",["jquery","order!utils","jquery.validate","jquery.json","order! //$("#modal-register").focus(); } + UserRegistrationRequest=function(user,applicationUrl){ + this.user=user; + this.applicationUrl=applicationUrl; + } + /** * validate the register form and call REST service */ register=function(){ - $.log("register.js#register"); + + $.log("redback.js#register"); var valid = $("#user-register-form").valid(); if (!valid) { return; @@ -130,40 +136,52 @@ define("redback",["jquery","order!utils","jquery.validate","jquery.json","order! $('#modal-register-footer').append(smallSpinnerImg()); - var user = {}; - user.username = $("#user-register-form-username").val(); - user.fullName = $("#user-register-form-fullname").val(); - user.email = $("#user-register-form-email").val(); - jQuery.ajax({ - url: 'restServices/redbackServices/userService/registerUser', - data: JSON.stringify(user), - type: 'POST', - contentType: "application/json", - success: function(result){ - var registered = false; - if (result == "-1") { - registered = false; - } else { - registered = true; - } + $.ajax({ + url: "restServices/archivaServices/archivaAdministrationService/applicationUrl", + type: "GET", + dataType: 'text', + success: function(data){ + $.log("applicationUrl ok:"+data); - if (registered == true) { - window.modalRegisterWindow.modal('hide'); - $("#register-link").hide(); - // FIXME i18n - displaySuccessMessage("registered your key has been sent"); + var user = { + username: $("#user-register-form-username").val(), + fullName: $("#user-register-form-fullname").val(), + email: $("#user-register-form-email").val() + }; + + var userRegistrationRequest=new UserRegistrationRequest(user,data); + $.ajax({ + url: 'restServices/redbackServices/userService/registerUser', + data: JSON.stringify(userRegistrationRequest), + type: 'POST', + contentType: "application/json", + success: function(result){ + var registered = false; + if (result == "-1") { + registered = false; + } else { + registered = true; + } + + if (registered == true) { + window.modalRegisterWindow.modal('hide'); + $("#register-link").hide(); + // FIXME i18n + displaySuccessMessage("registered your key has been sent"); + } + }, + complete: function(){ + $("#modal-register-ok").removeAttr("disabled"); + removeSmallSpinnerImg(); + }, + error: function(result) { + var obj = jQuery.parseJSON(result.responseText); + displayRedbackError(obj); + window.modalRegisterWindow.modal('hide'); + } + }); } - }, - complete: function(){ - $("#modal-register-ok").removeAttr("disabled"); - removeSmallSpinnerImg(); - }, - error: function(result) { - var obj = jQuery.parseJSON(result.responseText); - displayRedbackError(obj); - window.modalRegisterWindow.modal('hide'); - } - }) + }); }