Handle multipart form correctly also for PUT
diff --git a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java index 800b778..4a62c6e 100644 --- a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java +++ b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ApplicationApi.java
@@ -179,7 +179,7 @@ @Beta @PUT @Path("/{application}") - @Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_FORM_URLENCODED}) + @Consumes({MediaType.APPLICATION_FORM_URLENCODED}) @ApiOperation( value = "[BETA] Create and start a new application from YAML and format with the given id", response = org.apache.brooklyn.rest.domain.TaskSummary.class @@ -188,7 +188,7 @@ @ApiResponse(code = 404, message = "Undefined entity or location"), @ApiResponse(code = 409, message = "Application already registered") }) - public Response createFromYamlAndFormatAndAppId( + public Response createFromYamlAndFormatAndAppIdForm( @ApiParam(name = "plan", value = "Plan", required = true) @FormParam("plan") String yaml, @ApiParam(name = "format", value = "Format eg broolyn-camp", required = false) @@ -196,6 +196,27 @@ @ApiParam(name = "application", value = "Application id", required = true) @PathParam("application") String appId); + @Beta + @PUT + @Path("/{application}") + @Consumes({MediaType.MULTIPART_FORM_DATA}) + @ApiOperation( + value = "[BETA] Create and start a new application from YAML and format with the given id", + response = org.apache.brooklyn.rest.domain.TaskSummary.class + ) + @ApiResponses(value = { + @ApiResponse(code = 404, message = "Undefined entity or location"), + @ApiResponse(code = 409, message = "Application already registered") + }) + public Response createFromYamlAndFormatAndAppIdMultipart( + @ApiParam(name = "plan", value = "Plan", required = true) + @Multipart("plan") String yaml, + @ApiParam(name = "format", value = "Format eg broolyn-camp", required = false) + @Multipart("format") String format, + @ApiParam(name = "application", value = "Application id", required = true) + @Multipart("application") String appId); + + /** @deprecated since 1.1 use {@link #createWithFormat(byte[], String)} instead */ @Deprecated @POST
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java index 8ceb1b9..b202816 100644 --- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java +++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
@@ -406,6 +406,15 @@ } @Override + public Response createFromYamlAndFormatAndAppIdForm(String yaml, String format, String appId) { + return createFromYamlAndFormatAndAppId(yaml, format, appId); + } + + @Override + public Response createFromYamlAndFormatAndAppIdMultipart(String yaml, String format, String appId) { + return createFromYamlAndFormatAndAppId(yaml, format, appId); + } + public Response createFromYamlAndFormatAndAppId(String yaml, String format, String appId) { return createFromYaml(yaml, format, Optional.of(appId)); }
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/api/ApplicationApiTest.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/api/ApplicationApiTest.java index 9ede0d0..9bcd635 100644 --- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/api/ApplicationApiTest.java +++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/api/ApplicationApiTest.java
@@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.brooklyn.rest.api; import com.google.common.collect.ImmutableMap;