You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2019/03/02 23:12:03 UTC

[archiva] 03/03: Adding error handling for new validations. Fix web ui tests.

This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch archiva-2.x
in repository https://gitbox.apache.org/repos/asf/archiva.git

commit d4be8968cfb9910f335009e1538292671aa67853
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Sun Mar 3 00:11:52 2019 +0100

    Adding error handling for new validations. Fix web ui tests.
---
 .../resources/org/apache/archiva/i18n/default.properties    |  4 ++++
 archiva-modules/archiva-web/archiva-webapp-test/pom.xml     |  1 +
 .../src/main/webapp/js/archiva/artifacts-management.js      | 13 ++++++++-----
 .../archiva-webapp/src/main/webapp/js/archiva/utils.js      |  2 +-
 .../src/main/webapp/js/templates/archiva/general-admin.html |  4 ++--
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
index 122db4f..5f21bba 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
@@ -546,6 +546,7 @@ fileupload.errors.acceptFileTypes=Filetype not allowed
 fileupload.errors.maxNumberOfFiles=Max number of files exceeded
 fileupload.errors.uploadedBytes=Uploaded bytes exceed file size
 fileupload.errors.emptyResult=Empty file upload result
+fileupload.errors.Unprocessable_Entity=There were illegal characters in the parameters 
 fileupload.artifactId=Artifact ID
 fileupload.groupId=Groupd ID
 fileupload.version=Version
@@ -556,6 +557,9 @@ fileupload.save=Save Files
 fileupload.upload.required=You must upload your files first.
 fileupload.artifacts.saved=Artifacts for ''{0}:{1}:{2}'', packaged as ''{3}'', with {4} POM Generated, were uploaded and saved on Server side to ''{5}'' repository.
 fileupload.deleteAll=Select All
+fileupload.malformed.param=The field contains illegal characters.
+fileupload.malformed.filename=The filename contains illegal characters.
+fileupload.malformed.pomFile=The field pomFile has no boolean value.
 
 #reports
 report.title = Reports
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
index 2dbe3d2..f3c4b01 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
@@ -574,6 +574,7 @@
             <executions>
               <execution>
                 <id>cleanup-files</id>
+                <phase>initialize</phase>
                 <goals>
                   <goal>run</goal>
                 </goals>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
index aa96a83..ab8b307 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js
@@ -47,8 +47,11 @@ define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","kn
         displayErrorMessage( $.i18n.prop("fileupload.upload.required"));
         return;
       }
-      var url="restServices/archivaUiServices/fileUploadService/save/"+this.repositoryId()+"/"+this.groupId()+"/"+this.artifactId();
-      url+="/"+this.version()+"/"+this.packaging();
+      var url="restServices/archivaUiServices/fileUploadService/save/"+encodeURI(this.repositoryId())
+        +"/"+encodeURIComponent(this.groupId())
+        +"/"+encodeURIComponent(this.artifactId())
+        +"/"+encodeURIComponent(this.version())
+        +"/"+encodeURIComponent(this.packaging());
       $.log("this.generatePom():'"+this.generatePom()+"'");
       if (this.generatePom()==true){
         url+="?generatePom=true";
@@ -117,9 +120,9 @@ define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","kn
                   if (!data.formData){
                     data.formData={};
                   }
-                  data.formData.pomFile = pomFile;
-                  data.formData.classifier = classifier;
-                  data.formData.packaging = packaging;
+                  data.formData.pomFile = encodeURIComponent(pomFile);
+                  data.formData.classifier = encodeURIComponent(classifier);
+                  data.formData.packaging = encodeURIComponent(packaging);
                 });
               }
           });
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
index 7c0db1c..5802adc 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/utils.js
@@ -284,7 +284,7 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
       if (mainContent.find("#"+data.fieldName)){
         var message=null;
         if (data.errorKey) {
-          message=$.i18n.prop('data.errorKey');
+          message=$.i18n.prop(data.errorKey);
         } else {
           message=data.errorMessage;
         }
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
index b377fbb..dc6e767 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html
@@ -653,7 +653,7 @@
       {% if (file.error) { %}
       <td class="error" colspan="2">
         <span class="label label-important">{%=$.i18n.prop('fileupload.error')%}</span>
-        {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%}
+        {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%}
       </td>
       {% } else if (o.files.valid && !i) { %}
       <td>
@@ -692,7 +692,7 @@
     {% if (file.error) { %}
       <td class="error" colspan="2">
         <span class="label label-important">{%=$.i18n.prop('fileupload.error')%}</span>
-        {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%}
+        {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%}
       </td>
     {% } else { %}
       <td colspan="2"></td>