diff options
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/asdc')
-rwxr-xr-x | vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMeta.java | 26 | ||||
-rwxr-xr-x | vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java | 27 |
2 files changed, 34 insertions, 19 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMeta.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMeta.java index 66938372..a5295c47 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMeta.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMeta.java @@ -1,9 +1,9 @@ /*-
- * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed 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
@@ -14,7 +14,7 @@ * 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. + * limitations under the License.
* ============LICENSE_END=========================================================
*/
@@ -104,12 +104,14 @@ public class ToscaMeta { try {
while ((line = br.readLine()) != null) {
- final String[] entry = line.split(":");
-
- if (entry.length != 2) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (more than 1 colon found on a single line");
- if (!entry[1].startsWith(" ")) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (: not immediately followed by ' ')");
-
- metadata.put(entry[0], entry[1].substring(1));
+ if ( line.length() > 0 ) {
+ final String[] entry = line.split(":");
+
+ if (entry.length != 2) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (more than 1 colon found on a single line");
+ if (!entry[1].startsWith(" ")) throw new AsdcCatalogException("TOSCA.meta file cannot be parsed (: not immediately followed by ' ')");
+
+ metadata.put(entry[0], entry[1].substring(1));
+ }
}
} catch (IOException e) {
metadata.clear();
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java index 26d45cc7..9f7c3a57 100755 --- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java @@ -22,16 +22,19 @@ package org.openecomp.vid.asdc.rest; import java.io.IOException;
import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
-import java.util.logging.Logger;
import java.util.zip.ZipFile;
import javax.ws.rs.NotFoundException;
@@ -44,6 +47,7 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.vid.asdc.AsdcCatalogException;
import org.openecomp.vid.asdc.AsdcClient;
import org.openecomp.vid.asdc.beans.Artifact;
@@ -64,8 +68,11 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; */
public class RestfulAsdcClient implements AsdcClient {
- /** The Constant LOGGER. */
- private static final Logger LOGGER = Logger.getLogger(RestfulAsdcClient.class.getName());
+ /** The Constant LOG. */
+ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);
+
+ /** The Constant dateFormat. */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
/** The client. */
private final Client client;
@@ -422,7 +429,6 @@ public class RestfulAsdcClient implements AsdcClient { */
private ToscaCsar getToscaModel(InputStream csarInputStream) throws AsdcCatalogException {
final Path csarFile;
-
try {
csarFile = Files.createTempFile("csar", ".zip");
Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);
@@ -444,10 +450,17 @@ public class RestfulAsdcClient implements AsdcClient { final ToscaCsar.Builder csarBuilder = new ToscaCsar.Builder(parentModel);
for (Map<String, Map<String, String>> imports : parentModel.getImports()) {
+ LOG.debug("imports = " + imports.toString());
for (Entry<String, Map<String, String>> entry : imports.entrySet()) {
- final InputStream toscaChildEntryYamlStream = csar.getInputStream(csar.getEntry("Definitions/" + entry.getValue().get("file")));
- final ToscaModel childModel = yaml.loadAs(toscaChildEntryYamlStream, ToscaModel.class);
- csarBuilder.addVnf(childModel);
+ if ( entry.getValue() != null) {
+ String fname = entry.getValue().get("file");
+ if ( ( fname != null ) && (fname.startsWith("service") || fname.startsWith("resource")) ) {
+ LOG.debug("fname = " + fname);
+ final InputStream toscaChildEntryYamlStream = csar.getInputStream(csar.getEntry("Definitions/" + fname ));
+ final ToscaModel childModel = yaml.loadAs(toscaChildEntryYamlStream, ToscaModel.class);
+ csarBuilder.addVnf(childModel);
+ }
+ }
}
}
|