summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-09-30 14:50:18 +0300
committerMichael Lando <michael.lando@intl.att.com>2018-10-02 08:55:23 +0000
commit4704cdfc9441679baf1b178c3d9846cba03b4de5 (patch)
tree92cfea5e88d3f576b50a7333090345eab7e10116 /catalog-be/src/main
parentd73c287364870a19351ec6e22e8c275727972560 (diff)
exception is thrown on import normative
Change-Id: I26cd77466d4c79836665929066d2bff5b6ead92b Issue-ID: SDC-1796 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index c4035206f2..14fc77acd5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -169,9 +169,8 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
- protected void validateZip(Wrapper<Response> responseWrapper, File file, String payloadName) throws FileNotFoundException {
- InputStream fileInputStream = new FileInputStream(file);
- Map<String, byte[]> unzippedFolder = ZipUtil.readZip(new ZipInputStream(fileInputStream));
+ protected void validateZip(Wrapper<Response> responseWrapper, File file, String payloadName) {
+ Map<String, byte[]> unzippedFolder = ZipUtil.readZip(file);
if (payloadName == null || payloadName.isEmpty() || !unzippedFolder.containsKey(payloadName)) {
log.info("Invalid json was received. payloadName should be yml file name");
Response errorResponse = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
@@ -179,9 +178,8 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
}
- protected void validateCsar(Wrapper<Response> responseWrapper, File file, String payloadName) throws FileNotFoundException {
- InputStream fileInputStream = new FileInputStream(file);
- Map<String, byte[]> unzippedFolder = ZipUtil.readZip(new ZipInputStream(fileInputStream));
+ protected void validateCsar(Wrapper<Response> responseWrapper, File file, String payloadName) {
+ Map<String, byte[]> unzippedFolder = ZipUtil.readZip(file);
if (payloadName == null || payloadName.isEmpty() || unzippedFolder.isEmpty()) {
log.info("Invalid json was received. payloadName should be yml file name");
Response errorResponse = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
@@ -190,20 +188,18 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
- protected void fillZipContents(Wrapper<String> yamlStringWrapper, File file) throws FileNotFoundException {
+ protected void fillZipContents(Wrapper<String> yamlStringWrapper, File file) {
extractZipContents(yamlStringWrapper, file);
}
- public static void extractZipContents(Wrapper<String> yamlStringWrapper, File file) throws FileNotFoundException {
- InputStream fileInputStream = new FileInputStream(file);
- Map<String, byte[]> unzippedFolder = ZipUtil.readZip(new ZipInputStream(fileInputStream));
+ public static void extractZipContents(Wrapper<String> yamlStringWrapper, File file) {
+ Map<String, byte[]> unzippedFolder = ZipUtil.readZip(file);
String ymlName = unzippedFolder.keySet().iterator().next();
fillToscaTemplateFromZip(yamlStringWrapper, ymlName, file);
}
- private static void fillToscaTemplateFromZip(Wrapper<String> yamlStringWrapper, String payloadName, File file) throws FileNotFoundException {
- InputStream fileInputStream = new FileInputStream(file);
- Map<String, byte[]> unzippedFolder = ZipUtil.readZip(new ZipInputStream(fileInputStream));
+ private static void fillToscaTemplateFromZip(Wrapper<String> yamlStringWrapper, String payloadName, File file) {
+ Map<String, byte[]> unzippedFolder = ZipUtil.readZip(file);
byte[] yamlFileInBytes = unzippedFolder.get(payloadName);
String yamlAsString = new String(yamlFileInBytes, StandardCharsets.UTF_8);
log.debug("received yaml: {}", yamlAsString);