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.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration; 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.rest.api.model.AdminRepositoryConsumer;
import org.apache.archiva.security.common.ArchivaRoleConstants; import org.apache.archiva.security.common.ArchivaRoleConstants;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -189,7 +189,7 @@ public interface ArchivaAdministrationService
@Path( "getOrganisationInformation" ) @Path( "getOrganisationInformation" )
@GET @GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
@RedbackAuthorization( noPermission = true, noRestriction = true) @RedbackAuthorization( noPermission = true, noRestriction = true )
OrganisationInformation getOrganisationInformation() OrganisationInformation getOrganisationInformation()
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@ -214,10 +214,20 @@ public interface ArchivaAdministrationService
void setUiConfiguration( UiConfiguration uiConfiguration ) void setUiConfiguration( UiConfiguration uiConfiguration )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "applicationUrl" )
@GET
@Produces( MediaType.TEXT_PLAIN )
@RedbackAuthorization( noRestriction = true, noPermission = true )
/**
* @since 1.4-M3
*/
String getApplicationUrl()
throws ArchivaRestServiceException;
@Path( "getNetworkConfiguration" ) @Path( "getNetworkConfiguration" )
@GET @GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
NetworkConfiguration getNetworkConfiguration() NetworkConfiguration getNetworkConfiguration()
throws ArchivaRestServiceException; 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() public NetworkConfiguration getNetworkConfiguration()
throws ArchivaRestServiceException 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 uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,data.applicationUrl);
var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration); var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration);
ko.applyBindings(uiConfigurationViewModel,mainContent.get(0)); 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(); //$("#modal-register").focus();
} }
UserRegistrationRequest=function(user,applicationUrl){
this.user=user;
this.applicationUrl=applicationUrl;
}
/** /**
* validate the register form and call REST service * validate the register form and call REST service
*/ */
register=function(){ register=function(){
$.log("register.js#register");
$.log("redback.js#register");
var valid = $("#user-register-form").valid(); var valid = $("#user-register-form").valid();
if (!valid) { if (!valid) {
return; return;
@ -130,13 +136,23 @@ define("redback",["jquery","order!utils","jquery.validate","jquery.json","order!
$('#modal-register-footer').append(smallSpinnerImg()); $('#modal-register-footer').append(smallSpinnerImg());
var user = {}; $.ajax({
user.username = $("#user-register-form-username").val(); url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
user.fullName = $("#user-register-form-fullname").val(); type: "GET",
user.email = $("#user-register-form-email").val(); dataType: 'text',
jQuery.ajax({ success: function(data){
$.log("applicationUrl ok:"+data);
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', url: 'restServices/redbackServices/userService/registerUser',
data: JSON.stringify(user), data: JSON.stringify(userRegistrationRequest),
type: 'POST', type: 'POST',
contentType: "application/json", contentType: "application/json",
success: function(result){ success: function(result){
@ -163,7 +179,9 @@ define("redback",["jquery","order!utils","jquery.validate","jquery.json","order!
displayRedbackError(obj); displayRedbackError(obj);
window.modalRegisterWindow.modal('hide'); window.modalRegisterWindow.modal('hide');
} }
}) });
}
});
} }