]> source.dussan.org Git - archiva.git/commitdiff
use configured applicationUrl to send registration email
authorOlivier Lamy <olamy@apache.org>
Fri, 25 May 2012 12:33:18 +0000 (12:33 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 25 May 2012 12:33:18 +0000 (12:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1342595 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js

index 5bc34cfd43be0c2764792eccce710588b354603d..180dec9bfea9a1a919da62fd2e082953040205f5 100644 (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;
index abb4915b7fc07a6053e7ca8613c2978dcd683dca..63aa63d092874e1810c3d2784b742772e374c27a 100644 (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
     {
index b925dfcad584856466297fe77c4e8e0cd286344d..2ac80163d874a6d4b3efe3c90a09c31e0805587d 100644 (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);
-            }
-          });*/
         }
     });
   }
index 116c376f3fc59f68bfc8cf3ecd56ef884dd02123..f3bed7c82a1fa538db9c37f51294669e1cc5096c 100644 (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;
-        }
-
-        if (registered == true) {
-          window.modalRegisterWindow.modal('hide');
-          $("#register-link").hide();
-          // FIXME i18n
-          displaySuccessMessage("registered your key has been sent");
+    $.ajax({
+        url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
+        type: "GET",
+        dataType: 'text',
+        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',
+            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');
-      }
-    })
+    });
 
   }