From 49e0e7b486b707aaf7b61f73ca0bb93904d5c1c9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 31 Mar 2012 15:35:52 +0000 Subject: [PATCH] cleanup service to delete uploaded files, add form validation before starting upload git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1307831 13f79535-47bb-0310-9956-ffa450edef68 --- .../ui/services/api/DefaultFileUploadService.java | 12 +++--------- .../main/webapp/js/archiva/artifacts-management.js | 3 +++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultFileUploadService.java index d485d22b5..07253e372 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultFileUploadService.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultFileUploadService.java @@ -190,7 +190,7 @@ public class DefaultFileUploadService public Boolean clearUploadedFiles() throws ArchivaRestServiceException { - List fileMetadatas = getSessionFileMetadatas(); + List fileMetadatas = new ArrayList( getSessionFileMetadatas() ); for ( FileMetadata fileMetadata : fileMetadatas ) { deleteFile( fileMetadata.getServerFileName() ); @@ -222,13 +222,7 @@ public class DefaultFileUploadService { public boolean apply( FileMetadata fileMetadata ) { - if ( fileMetadata == null ) - { - return false; - } - return StringUtils.equals( groupId, fileMetadata.getGroupId() ) && StringUtils.equals( artifactId, - fileMetadata.getArtifactId() ) - && !fileMetadata.isPomFile(); + return fileMetadata != null && !fileMetadata.isPomFile(); } } ); Iterator iterator = filesToAdd.iterator(); @@ -245,7 +239,7 @@ public class DefaultFileUploadService { public boolean apply( @Nullable FileMetadata fileMetadata ) { - return fileMetadata.isPomFile(); + return fileMetadata != null && fileMetadata.isPomFile(); } } ); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js index 8e9a96ac6..44f486cd5 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js @@ -90,6 +90,9 @@ define("archiva.artifacts-management",["jquery","i18n","order!utils","order!jque }); $('#fileupload').fileupload({ add: function (e, data) { + if(!mainContent.find("#fileupload" ).valid()){ + return; + } data.formData = { groupId: artifactUploadViewModel.groupId(), artifactId: artifactUploadViewModel.artifactId(), -- 2.39.5