aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-11-15 01:38:18 +0000
committerOlivier Lamy <olamy@apache.org>2013-11-15 01:38:18 +0000
commit86c913a95e34f27e4b8afff607fde3ad5cbd8aaf (patch)
tree72e32d9f9811444bac8b81cf86d1106a8703ea27
parent76b43a92541e7d209908023d02a94896e65588d3 (diff)
downloadarchiva-86c913a95e34f27e4b8afff607fde3ad5cbd8aaf.tar.gz
archiva-86c913a95e34f27e4b8afff607fde3ad5cbd8aaf.zip
[MRM-1762] Upload Artifact page allows to uploading SNAPSHOT versions to non snapshot repositories
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1542152 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRestServiceException.java1
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java28
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/artifacts-management.js2
3 files changed, 29 insertions, 2 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRestServiceException.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRestServiceException.java
index e2a426ff5..272550d45 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRestServiceException.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRestServiceException.java
@@ -91,4 +91,5 @@ public class ArchivaRestServiceException
{
this.fieldName = fieldName;
}
+
}
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
index 90f114ecc..c13180385 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/api/DefaultFileUploadService.java
@@ -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>()
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 213ea43bf..cb4d45744 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
@@ -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',