]> source.dussan.org Git - archiva.git/commitdiff
fix display of error response when updating a managedRepository
authorOlivier Lamy <olamy@apache.org>
Mon, 16 Jan 2012 13:27:01 +0000 (13:27 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 16 Jan 2012 13:27:01 +0000 (13:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1231991 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js

index 077befc89c174bb39a29af72df67212911e56c08..96ed1e95de78d292f886930daf3d51ae8b688a3d 100644 (file)
@@ -84,7 +84,8 @@ $(function() {
               displaySuccessMessage($.i18n.prop('managedrepository.updated'));
             },
             error: function(data) {
-              displayErrorMessage(data);
+              var res = $.parseJSON(data.responseText);
+              displayRestError(res);
             }
         }
       );
index d4af31e09fa22c8bd737f82f37a5f6c3263512ec..5e6de8a78b043102048178e456c4e625692a51fb 100644 (file)
@@ -216,13 +216,38 @@ $.extend($.tmpl.tag, {
 });
 
 displayRestError=function(data,idToAppend){
-  if (data.archivaRestError){
-    if (data.archivaRestError.errorKey){
+
+  if (data.redbackRestError){
+    displayRedbackError(archivaRestError,idToAppend)
+  }
+
+  if (data.archivaRestError && data.archivaRestError.errorKey && data.archivaRestError.errorKey.length>0){
+      $.log("with errorKey:"+dataarchivaRestError.errorKey);
       displayErrorMessage($.i18n.prop( data.archivaRestError.errorKey ),idToAppend);
     } else {
+      $.log("data.errorMessage:"+data.archivaRestError.errorMessage);
       displayErrorMessage(data.archivaRestError.errorMessage,idToAppend);
+  }
+
+}
+
+/**
+ * display redback error from redback json error response
+ * {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}}
+ * @param obj
+ * @param idToAppend
+ */
+displayRedbackError=function(obj,idToAppend) {
+  if ($.isArray(obj.redbackRestError.errorMessages)) {
+    $.log("displayRedbackError with array");
+    for(var i=0; i<obj.redbackRestError.errorMessages.length; i++ ) {
+      if(obj.redbackRestError.errorMessages[i].errorKey) {
+        $.log("displayRedbackError with array loop");
+        displayErrorMessage($.i18n.prop( obj.redbackRestError.errorMessages[i].errorKey, obj.redbackRestError.errorMessages[i].args ),idToAppend);
+      }
     }
   } else {
-    // redback ??
+    $.log("displayRedbackError no array");
+    displayErrorMessage($.i18n.prop( obj.redbackRestError.errorMessages.errorKey, obj.redbackRestError.errorMessages.args ),idToAppend);
   }
 }
\ No newline at end of file
index e2c7054323116f01ae6d80bc16f2db9584067dc7..a4160292c851dc9e91c3918ca7f9ab290a413f6f 100644 (file)
@@ -21,27 +21,6 @@ $(function() {
   // define a container object with various datas
   window.redbackModel = {usersViewModel:null,userOperationNames:null,key:null,userCreate:false,i18n:$.i18n.map,rolesViewModel:null};
 
-  /**
-   * display redback error from redback json error response
-   * {"redbackRestError":{"errorMessages":{"args":1,"errorKey":"user.password.violation.numeric"}}}
-   * @param obj
-   * @param idToAppend
-   */
-  displayRedbackError=function(obj,idToAppend) {
-    if ($.isArray(obj.redbackRestError.errorMessages)) {
-      $.log("displayRedbackError with array");
-      for(var i=0; i<obj.redbackRestError.errorMessages.length; i++ ) {
-        if(obj.redbackRestError.errorMessages[i].errorKey) {
-          $.log("displayRedbackError with array loop");
-          displayErrorMessage($.i18n.prop( obj.redbackRestError.errorMessages[i].errorKey, obj.redbackRestError.errorMessages[i].args ),idToAppend);
-        }
-      }
-    } else {
-      $.log("displayRedbackError no array");
-      displayErrorMessage($.i18n.prop( obj.redbackRestError.errorMessages.errorKey, obj.redbackRestError.errorMessages.args ),idToAppend);
-    }
-  }
-
   // unbinding
   $("#user-create-form-cancel-button").on("click", function(){
     $('#user-create').hide();