From d4be8968cfb9910f335009e1538292671aa67853 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 3 Mar 2019 00:11:52 +0100 Subject: [PATCH] Adding error handling for new validations. Fix web ui tests. --- .../org/apache/archiva/i18n/default.properties | 4 ++++ .../archiva-web/archiva-webapp-test/pom.xml | 1 + .../main/webapp/js/archiva/artifacts-management.js | 13 ++++++++----- .../src/main/webapp/js/archiva/utils.js | 2 +- .../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 122db4f3d..5f21bba7b 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 2dbe3d220..f3c4b01f1 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 @@ cleanup-files + initialize run 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 aa96a8339..ab8b307d7 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 7c0db1ce4..5802adcd5 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 b377fbb96..dc6e7672c 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) { %} {%=$.i18n.prop('fileupload.error')%} - {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%} + {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%} {% } else if (o.files.valid && !i) { %} @@ -692,7 +692,7 @@ {% if (file.error) { %} {%=$.i18n.prop('fileupload.error')%} - {%=$.i18n.prop('fileupload.errors.'+[file.error]) || file.error%} + {%=$.i18n.prop('fileupload.errors.'+file.error.replace(/\s+/,'_')) || file.error%} {% } else { %} -- 2.39.5