use configured applicationUrl to send registration email

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1342595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-05-25 12:33:18 +00:00
parent 2db8f333d8
commit 5f43a65cd8
4 changed files with 77 additions and 41 deletions

View File

@ -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;

View File

@ -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
{

View File

@ -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);
}
});*/
}
});
}

View File

@ -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');
}
})
});
}