]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1762] Upload Artifact page allows to uploading SNAPSHOT versions to non snapshot...
authorOlivier Lamy <olamy@apache.org>
Fri, 15 Nov 2013 01:38:18 +0000 (01:38 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 15 Nov 2013 01:38:18 +0000 (01:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1542152 13f79535-47bb-0310-9956-ffa450edef68

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

index 90f114ecc5680964e62351364bdeb12bc77c0bb1..c1318038534c652834d28730cca068dcfe93800b 100644 (file)
@@ -128,7 +128,7 @@ public class DefaultFileUploadService
             // skygo: http header form pomFile was once sending 1 for true and void for false
             // leading to permanent false value for pomFile if using toBoolean(); use , "1", ""
             boolean pomFile = BooleanUtils.toBoolean( getStringValue( multipartBody, "pomFile" ) );
-            
+
             Attachment file = multipartBody.getAttachment( "files[]" );
 
             //Content-Disposition: form-data; name="files[]"; filename="org.apache.karaf.features.command-2.2.2.jar"
@@ -219,6 +219,32 @@ public class DefaultFileUploadService
         {
             return Boolean.FALSE;
         }
+
+        try
+        {
+            ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repositoryId );
+
+            if ( managedRepository == null )
+            {
+                // TODO i18n ?
+                throw new ArchivaRestServiceException( "Cannot find managed repository with id " + repositoryId,
+                                                       Response.Status.BAD_REQUEST.getStatusCode(), null );
+            }
+
+            if ( VersionUtil.isSnapshot( version ) && !managedRepository.isSnapshots() )
+            {
+                // TODO i18n ?
+                throw new ArchivaRestServiceException(
+                    "Managed repository with id " + repositoryId + " do not accept snapshots",
+                    Response.Status.BAD_REQUEST.getStatusCode(), null );
+            }
+        }
+        catch ( RepositoryAdminException e )
+        {
+            throw new ArchivaRestServiceException( e.getMessage(),
+                                                   Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
+        }
+
         // get from the session file with groupId/artifactId
 
         Iterable<FileMetadata> filesToAdd = Iterables.filter( fileMetadatas, new Predicate<FileMetadata>()
index 213ea43bfbc5b1252308a4dde509350e2dffeac8..cb4d457441f67e613e85fdc922b48b180c9c6fdb 100644 (file)
@@ -82,7 +82,7 @@ define("archiva.artifacts-management",["jquery","i18n","utils","jquery.tmpl","kn
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          mainContent.html($("#file-upload-screen" ).html());
+          mainContent.html($("#file-upload-screen").html());
           $.ajax("restServices/archivaServices/browseService/userRepositories", {
               type: "GET",
               dataType: 'json',