]> source.dussan.org Git - archiva.git/commitdiff
cleanup service to delete uploaded files, add form validation before starting upload
authorOlivier Lamy <olamy@apache.org>
Sat, 31 Mar 2012 15:35:52 +0000 (15:35 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 31 Mar 2012 15:35:52 +0000 (15:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1307831 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultFileUploadService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/artifacts-management.js

index d485d22b5fe32bac3e92dbee33c3b5de27d2bbea..07253e372ce40af730244858d0549ae6865a3ca1 100644 (file)
@@ -190,7 +190,7 @@ public class DefaultFileUploadService
     public Boolean clearUploadedFiles()
         throws ArchivaRestServiceException
     {
-        List<FileMetadata> fileMetadatas = getSessionFileMetadatas();
+        List<FileMetadata> 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<FileMetadata> iterator = filesToAdd.iterator();
@@ -245,7 +239,7 @@ public class DefaultFileUploadService
         {
             public boolean apply( @Nullable FileMetadata fileMetadata )
             {
-                return fileMetadata.isPomFile();
+                return fileMetadata != null && fileMetadata.isPomFile();
             }
         } );
 
index 8e9a96ac644523aad5f7e77cd5e26f8ef5d1f125..44f486cd513a30e022c0f061b2e9287b6a6770ac 100644 (file)
@@ -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(),