aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-11-15 16:21:59 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-11-15 16:21:59 +0530
commite644f7fc1173b4b0ebe66648f4f26f6b6c46d573 (patch)
tree390626d3900f93e70157a32c4c0f6943c8340bfe
parent916e965c1b8005238c97c89dbd03f6ab29696112 (diff)
Fix csar-create to upload csar properly
Issue-ID: VNFSDK-334 Change-Id: Ica13dd1313684df759920d83e1d8416deb1de2d6 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
-rw-r--r--products/onap-casablanca/features/vnfsdk/src/main/resources/open-cli-schema/csar-create-schema.yaml2
-rw-r--r--profiles/http/pom.xml2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java14
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java1
4 files changed, 10 insertions, 9 deletions
diff --git a/products/onap-casablanca/features/vnfsdk/src/main/resources/open-cli-schema/csar-create-schema.yaml b/products/onap-casablanca/features/vnfsdk/src/main/resources/open-cli-schema/csar-create-schema.yaml
index 64b390e2..d1728745 100644
--- a/products/onap-casablanca/features/vnfsdk/src/main/resources/open-cli-schema/csar-create-schema.yaml
+++ b/products/onap-casablanca/features/vnfsdk/src/main/resources/open-cli-schema/csar-create-schema.yaml
@@ -46,8 +46,6 @@ http:
method: POST
body: ${csar-file}
multipart_entity_name: file
- headers:
- Content-Type: multipart/form-data
success_codes:
- 200
result_map:
diff --git a/profiles/http/pom.xml b/profiles/http/pom.xml
index d8ea2b49..ac2f089f 100644
--- a/profiles/http/pom.xml
+++ b/profiles/http/pom.xml
@@ -45,7 +45,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
- <version>4.0.1</version>
+ <version>4.3.5</version>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
index b21c2575..b86ef26b 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
@@ -54,9 +54,9 @@ import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.Cookie;
+import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
-import org.apache.http.entity.mime.MultipartEntity;
-import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.LaxRedirectStrategy;
@@ -365,10 +365,12 @@ public class OnapHttpConnection {
}
private HttpEntity getMultipartEntity(HttpInput input) {
- FileBody fileBody = new FileBody(new File(input.getBody().trim()));
- MultipartEntity multipartEntity = new MultipartEntity();
- String fileName = input.getMultipartEntityName() != "" ? input.getMultipartEntityName() : "upload";
- multipartEntity.addPart(fileName, fileBody);
+ String fileTag = input.getMultipartEntityName() != "" ? input.getMultipartEntityName() : "file";
+ File file = new File(input.getBody().trim());
+ HttpEntity multipartEntity = MultipartEntityBuilder
+ .create()
+ .addBinaryBody(fileTag, file, ContentType.create("application/octet-stream"), file.getName())
+ .build();
return multipartEntity;
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
index ed415335..a0c96cad 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
@@ -73,6 +73,7 @@ public class OnapCommandHttpUtils {
break;
}
}
+ inp.setMultipartEntityName(input.getMultipartEntityName());
inp.setBody(OnapCommandUtils.replaceLineFromInputParameters(input.getBody(), params));
inp.setUri(OnapCommandUtils.replaceLineFromInputParameters(input.getUri(), params));
inp.setMethod(input.getMethod().toLowerCase());