[VID-55] Upgrade Tosca Parser (merge) 15/10215/1
authorOfir Sonsino <os0695@att.com>
Mon, 4 Sep 2017 11:52:07 +0000 (14:52 +0300)
committerOfir Sonsino <os0695@att.com>
Mon, 4 Sep 2017 11:52:07 +0000 (14:52 +0300)
Change-Id: I5389f1641ef22df3ed569a154b3c367117c04d04
Signed-off-by: Ofir Sonsino <os0695@att.com>
69 files changed:
epsdk-app-onap/src/main/resources/portal_template.properties
vid-app-common/pom.xml
vid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java
vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
vid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java
vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
vid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java
vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParser.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java
vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java
vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java
vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java [deleted file]
vid-app-common/src/main/java/org/openecomp/vid/model/Network.java
vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java
vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java
vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java
vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java
vid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java
vid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java
vid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java
vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java [new file with mode: 0644]
vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java [new file with mode: 0644]
vid-app-common/src/main/resources/catalog.json [new file with mode: 0644]
vid-app-common/src/main/resources/sdcservices.json [new file with mode: 0644]
vid-app-common/src/main/resources/service-vf-csar.zip [new file with mode: 0644]
vid-app-common/src/main/resources/service-vl-csar.zip [new file with mode: 0644]
vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js
vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java [new file with mode: 0644]
vid-app-common/src/test/java/org/opencomp/vid/testUtils/TestUtils.java [new file with mode: 0644]
vid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java
vid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java
vid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java
vid-app-common/src/test/resources/asdc.properties [new file with mode: 0644]
vid-app-common/src/test/resources/sampleTosca.csar [new file with mode: 0644]
vid-app-common/src/test/resources/vf-csar.JSON [new file with mode: 0644]
vid-app-common/src/test/resources/vl-csar.JSON [new file with mode: 0644]

index ed69401..c26be55 100755 (executable)
@@ -1,6 +1,6 @@
 # Properties read by ECOMP Framework library, ecompFW.jar\r
 \r
-portal.api.impl.class = org.openecomp.portalapp.service.OnBoardingApiServiceImpl\r
+portal.api.impl.class = org.openecomp.portalsdk.core.onboarding.client.OnBoardingApiServiceImpl\r
 portal.api.prefix = /api\r
 max.idle.time = 5\r
 user.attribute.name = user_attribute\r
index fbe74df..fbc9d47 100755 (executable)
                        <artifactId>snakeyaml</artifactId>\r
                        <version>1.16</version>\r
                </dependency>\r
+               <dependency>\r
+                   <groupId>org.skyscreamer</groupId>\r
+                   <artifactId>jsonassert</artifactId>\r
+                   <version>1.5.0</version>\r
+               </dependency>\r
+               <dependency>\r
+                   <groupId>org.openecomp.sdc.sdc-tosca</groupId>\r
+                   <artifactId>sdc-tosca</artifactId>\r
+                   <version>1.1.32-SNAPSHOT</version>\r
+               </dependency>\r
+               <dependency>\r
+                   <groupId>net.javacrumbs.json-unit</groupId>\r
+                   <artifactId>json-unit</artifactId>\r
+                   <version>1.23.0</version>\r
+                   <scope>test</scope>\r
+               </dependency>\r
        </dependencies>\r
 </project>\r
index ca710f6..9716ba8 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index cd50951..2434100 100755 (executable)
@@ -276,43 +276,22 @@ public class AAIRestInterface {
                if (xml)\r
                        responseType = "application/xml";\r
                   \r
-            initRestClient();\r
-\r
-                       String clientCert = SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT);\r
-\r
-                       boolean useClientCert = false;\r
-                       if (clientCert != null &&\r
-                                       SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {\r
-                               useClientCert  = true;\r
-                       }\r
+            initRestClient();    \r
     \r
             url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL_BASE) + path;\r
 \r
-            final Response cres;\r
-                       if (useClientCert == true) {\r
-                               cres = client.target(url)\r
-                                               .request()\r
-                                               .accept(responseType)\r
-                                               .header("X-TransactionId", transId)\r
-                                               .header("X-FromAppId",  fromAppId)\r
-                                               .header("Content-Type", "application/json")\r
-                                               .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
-                       } else {\r
-\r
-                               String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);\r
-                               String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));\r
-                               String encodeThis = vidUsername + ":" + vidPassword;\r
-\r
-                               cres = client.target(url)\r
-                                               .request()\r
-                                               .accept(responseType)\r
-                                               .header("X-TransactionId", transId)\r
-                                               .header("X-FromAppId", fromAppId)\r
-                                               .header("Content-Type", "application/json")\r
-                                               .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))\r
-                                               .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
-                       }\r
-\r
+            String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);\r
+                       String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));\r
+                       String encodeThis = vidUsername + ":" + vidPassword;\r
+                       \r
+            final Response cres = client.target(url)\r
+                 .request()\r
+                 .accept(responseType)\r
+                 .header("X-TransactionId", transId)\r
+                 .header("X-FromAppId",  fromAppId)\r
+                 .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))\r
+                 .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
+            \r
                if (cres.getStatus() == 200 && cres.getStatus() <= 299) {\r
                        logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");\r
                        logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");\r
index 2623d6b..1ed0792 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 8335d15..6a3665e 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index e4c4bce..e31b0c1 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index aafb11c..c807872 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index c4a8b1c..314ea03 100755 (executable)
@@ -20,6 +20,8 @@
 \r
 package org.openecomp.vid.asdc;\r
 \r
+import java.io.IOException;\r
+import java.nio.file.Path;\r
 import java.util.Collection;\r
 import java.util.Map;\r
 import java.util.UUID;\r
@@ -27,7 +29,6 @@ import java.util.UUID;
 import org.openecomp.vid.asdc.beans.Artifact;\r
 import org.openecomp.vid.asdc.beans.Resource;\r
 import org.openecomp.vid.asdc.beans.Service;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;\r
 \r
 /**\r
  * The Interface AsdcClient.\r
@@ -77,7 +78,7 @@ public interface AsdcClient {
         * @return the resource tosca model\r
         * @throws AsdcCatalogException the sdc catalog exception\r
         */\r
-       public ToscaCsar getResourceToscaModel(UUID uuid) throws AsdcCatalogException;\r
+       public Path getResourceToscaModel(UUID uuid) throws AsdcCatalogException;\r
        \r
        /**\r
         * Gets the service.\r
@@ -122,7 +123,7 @@ public interface AsdcClient {
         * @return the service tosca model\r
         * @throws AsdcCatalogException the asdc catalog exception\r
         */\r
-       public ToscaCsar getServiceToscaModel(UUID uuid) throws AsdcCatalogException;\r
+       public Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;\r
        \r
        //TODO: Collect TOSCA information from CSAR\r
 }\r
index d24d123..4974d44 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 3911c69..000aae1 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index fa898e5..2a83cbe 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 6d7fb41..cd3ec7f 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 21a50d3..0d3f17a 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index b68b51a..a91f383 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 package org.openecomp.vid.asdc.beans.tosca;\r
index 275db3c..4d31faa 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 33f3175..d64a580 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index f988207..e5eec01 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
 package org.openecomp.vid.asdc.beans.tosca;\r
 \r
+import org.openecomp.sdc.toscaparser.api.elements.constraints.*;\r
+\r
 import java.util.List;\r
 import java.util.ArrayList;\r
 \r
@@ -42,7 +44,7 @@ public class Input {
        private Input entry_schema;\r
        \r
        /** The constraints */\r
-       private List<Constraint> constraints;\r
+       private List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> constraints;\r
        \r
        /** The required field. If not set, the default is true */\r
        private boolean required = true;\r
@@ -51,7 +53,7 @@ public class Input {
         * Instantiates a new input.\r
         */\r
        public Input() {\r
-               constraints = new ArrayList<Constraint>();\r
+               constraints = new ArrayList<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint>();\r
        }\r
        \r
        /**\r
@@ -144,7 +146,7 @@ public class Input {
         *\r
         * @param c the new constraints\r
         */\r
-       public void setConstraints(List<Constraint> c) {\r
+       public void setConstraints(List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> c) {\r
                this.constraints = c;\r
        }\r
        /**\r
@@ -152,7 +154,7 @@ public class Input {
         *\r
         * @return the constraints\r
         */\r
-       public List<Constraint> getConstraints() {\r
+       public List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> getConstraints() {\r
                return constraints;\r
        }\r
        \r
index 73eead9..97740b3 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index c8f048c..16b921e 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index fce41ec..acb2509 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index bd3a2f0..f77c1b4 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 026f29b..f59f246 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index ce7ce57..25b2c2c 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index cca4ae7..9e9e1d0 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
index 41c7ca5..d42c1f1 100755 (executable)
@@ -61,9 +61,6 @@ public class ToscaMetadata {
        /** The resource vendor release. */\r
        private String resourceVendorRelease;\r
        \r
-       /** the resourceVendorModelNumber */\r
-       private String resourceVendorModelNumber;\r
-\r
        /** The service ecomp naming. */\r
        private String serviceEcompNaming;\r
        \r
@@ -91,11 +88,6 @@ public class ToscaMetadata {
        \r
        /** The vf module model version. */\r
        private String vfModuleModelVersion;\r
-\r
-        /** serviceType */\r
-        private String serviceType;\r
-        /** serviceRole */\r
-        private String serviceRole;\r
        \r
        /**\r
         * Instantiates a new tosca metadata.\r
@@ -466,26 +458,4 @@ public class ToscaMetadata {
                \r
                return vfModuleModelCustomizationUUID;\r
        }\r
-\r
-        /** serviceType */\r
-        public String getServiceType() {\r
-                return serviceType;\r
-        }\r
-        public void setServiceType(String serviceType) {\r
-                this.serviceType= serviceType;\r
-        }\r
-        /** serviceRole */\r
-        public String getServiceRole() {\r
-                return serviceRole;\r
-        }\r
-        public void setServiceRole(String serviceRole) {\r
-                this.serviceRole= serviceRole;\r
-        }\r
-        /** resourceVendorModelNumber */\r
-        public String getResourceVendorModelNumber() {\r
-                return resourceVendorModelNumber;\r
-        }\r
-        public void setResourceVendorModelNumber(String resourceVendorModelNumber) {\r
-                this.resourceVendorModelNumber= resourceVendorModelNumber;\r
-        }\r
 }\r
index c9e42f2..77fbe91 100755 (executable)
@@ -1,9 +1,9 @@
 /*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
@@ -14,7 +14,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
  * See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
  * ============LICENSE_END=========================================================\r
  */\r
 \r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java
new file mode 100644 (file)
index 0000000..8538f6b
--- /dev/null
@@ -0,0 +1,388 @@
+package org.openecomp.vid.asdc.local;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.AsdcClient;
+import org.openecomp.vid.asdc.beans.Artifact;
+import org.openecomp.vid.asdc.beans.Resource;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;
+import org.openecomp.vid.asdc.beans.tosca.ToscaMeta;
+import org.openecomp.vid.asdc.beans.tosca.ToscaModel;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.*;
+import java.util.zip.ZipFile;
+
+/**
+ * The Class LocalAsdcClient.
+ */
+public class LocalAsdcClient implements AsdcClient {
+
+
+    /**
+     * The catalog.
+     */
+    private final JSONObject catalog;
+
+    /**
+     * The mapper.
+     */
+    private final ObjectMapper mapper;
+
+    /**
+     * The Class Builder.
+     */
+    public static class Builder {
+
+        /**
+         * The catalog.
+         */
+        private JSONObject catalog = new JSONObject()
+                .put("resources", new JSONObject())
+                .put("services", new JSONObject());
+
+        /**
+         * The mapper.
+         */
+        private ObjectMapper mapper = new ObjectMapper();
+
+        /**
+         * Instantiates a new builder.
+         */
+        public Builder() {
+        }
+
+        /**
+         * Catalog.
+         *
+         * @param catalog the catalog
+         * @return the builder
+         */
+        public org.openecomp.vid.asdc.local.LocalAsdcClient.Builder catalog(JSONObject catalog) {
+            this.catalog = catalog;
+            return this;
+        }
+
+        /**
+         * Mapper.
+         *
+         * @param mapper the mapper
+         * @return the builder
+         */
+        public org.openecomp.vid.asdc.local.LocalAsdcClient.Builder mapper(ObjectMapper mapper) {
+            this.mapper = mapper;
+            return this;
+        }
+
+        /**
+         * Builds the.
+         *
+         * @return the in local sdc client
+         */
+        public org.openecomp.vid.asdc.local.LocalAsdcClient build() {
+            return new org.openecomp.vid.asdc.local.LocalAsdcClient(this);
+        }
+    }
+
+    /**
+     * Instantiates a new in local sdc client.
+     *
+     * @param builder the builder
+     */
+    private LocalAsdcClient(org.openecomp.vid.asdc.local.LocalAsdcClient.Builder builder) {
+        catalog = builder.catalog;
+        mapper = builder.mapper;
+    }
+
+    /**
+     * Gets the catalog.
+     *
+     * @return the catalog
+     */
+    private JSONObject getCatalog() {
+        return catalog;
+    }
+
+    /**
+     * Gets the mapper.
+     *
+     * @return the mapper
+     */
+    private ObjectMapper getMapper() {
+        return mapper;
+    }
+
+    /**
+     * Convert.
+     *
+     * @param <T>   the generic type
+     * @param json  the json
+     * @param clazz the clazz
+     * @return the t
+     * @throws AsdcCatalogException the sdc catalog exception
+     */
+    private <T> T convert(JSONObject json, Class<T> clazz) throws AsdcCatalogException {
+        try {
+            return getMapper().readValue(json.toString(), clazz);
+        } catch (JsonParseException e) {
+            throw new AsdcCatalogException("Failed to parse SDC response (bad data)", e);
+        } catch (JsonMappingException e) {
+            throw new AsdcCatalogException("Failed to map SDC response to internal VID data structure(s)", e);
+        } catch (IOException e) {
+            throw new AsdcCatalogException("Failed to get a response from SDC", e);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)
+     */
+    public Resource getResource(UUID uuid) throws AsdcCatalogException {
+        final JSONObject resource = getCatalog().getJSONObject("resources")
+                .getJSONObject(uuid.toString());
+        return convert(resource, Resource.class);
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getResources()
+     */
+    public Collection<Resource> getResources() throws AsdcCatalogException {
+        final Collection<Resource> resources = new LinkedList<Resource>();
+
+        for (String key : getCatalog().getJSONObject("resources").keySet()) {
+            final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+            final Resource resource = convert(json, Resource.class);
+            resources.add(resource);
+        }
+
+        return resources;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)
+     */
+    public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
+        final Collection<Resource> resources = new LinkedList<Resource>();
+
+        for (String key : getCatalog().getJSONObject("resources").keySet()) {
+            final JSONObject json = getCatalog().getJSONObject("resources").getJSONObject(key);
+
+            boolean filterMatch = true;
+
+            for (Map.Entry<String, String[]> entry : filter.entrySet()) {
+                for (int i = 0; i < entry.getValue().length; i++) {
+                    if (!json.getString(entry.getKey()).equals(entry.getValue()[i])) {
+                        filterMatch = false;
+                        break;
+                    }
+                }
+            }
+
+            if (filterMatch) resources.add(convert(json, Resource.class));
+        }
+
+        return resources;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)
+     */
+    public Service getService(UUID uuid) throws AsdcCatalogException {
+
+        JSONObject serviceJsonObject = null;
+        final JSONArray categoryJsonArray = getCatalog().getJSONArray("services");
+
+        for (int i = 0; i < categoryJsonArray.length() ; i++) {
+            JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
+            if (jsonServiceObject.get("uuid").equals(uuid.toString())) {
+                serviceJsonObject = jsonServiceObject;
+                break;
+            }
+        }
+
+        if (serviceJsonObject != null)
+            return convert(serviceJsonObject, Service.class);
+        else return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getServices()
+     */
+    public Collection<Service> getServices() throws AsdcCatalogException {
+        final Collection<Service> services = new LinkedList<Service>();
+
+        JSONArray servicesArr = getCatalog().getJSONArray("services");
+
+        for (Object objService : servicesArr) {
+            JSONObject jsonServiceItem = (JSONObject) objService;
+            final Service service = convert(jsonServiceItem, Service.class);
+            services.add(service);
+        }
+
+        return services;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecompt.vid.asdc.AsdcClient#getServices(java.util.Map)
+     */
+    public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
+        final Collection<Service> services = new LinkedList<Service>();
+
+        JSONArray catalogServices = catalog.getJSONArray("services");
+
+        for (int i = 0; i < catalogServices.length(); i++) {
+
+            JSONObject serviceJson = catalogServices.getJSONObject(i);
+
+            boolean filterMatch = true;
+
+            for (Map.Entry<String, String[]> entry : filter.entrySet()) {
+                for (int j = 0; j < entry.getValue().length; j++) {
+                    if (!serviceJson.getString(entry.getKey()).equals(entry.getValue()[j])) {
+                        filterMatch = false;
+                        break;
+                    }
+                }
+            }
+            if (filterMatch) services.add(convert(serviceJson, Service.class));
+        }
+        return services;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
+     */
+    public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
+        final JSONArray artifacts = getCatalog().getJSONObject("resources")
+                .getJSONObject(resourceUuid.toString())
+                .getJSONArray("artifacts");
+
+        for (int i = 0; i < artifacts.length(); i++) {
+            final JSONObject artifact = artifacts.getJSONObject(i);
+
+            if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+                return convert(artifact, Artifact.class);
+            }
+        }
+
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
+     */
+    public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
+        final JSONArray artifacts = getCatalog().getJSONObject("services")
+                .getJSONObject(serviceUuid.toString())
+                .getJSONArray("artifacts");
+
+        for (int i = 0; i < artifacts.length(); i++) {
+            final JSONObject artifact = artifacts.getJSONObject(i);
+
+            if (artifact.getString("artifactUUID").equals(artifactUuid.toString())) {
+                return convert(artifact, Artifact.class);
+            }
+        }
+
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
+     */
+    public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+        final String toscaModelURL = getCatalog().getJSONObject("resources")
+                .getJSONObject(resourceUuid.toString())
+                .getString("toscaModelURL");
+
+
+        final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+        if (toscaModelStream == null) return null;
+
+        return null;//getToscaModel(toscaModelStream);
+    }
+
+    /* (non-Javadoc)
+     * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
+     */
+    public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+
+        String toscaModelURL = null;
+
+        final JSONArray categoryJsonArray = getCatalog().getJSONArray("services");
+
+        for (int i = 0; i < categoryJsonArray.length() ; i++) {
+
+            JSONObject jsonServiceObject = categoryJsonArray.getJSONObject(i);
+            if (jsonServiceObject.get("uuid").equals(serviceUuid.toString())) {
+                toscaModelURL = jsonServiceObject.getString("toscaModelURL");
+            }
+        }
+
+        final InputStream toscaModelStream = getClass().getClassLoader().getResourceAsStream(toscaModelURL);
+
+        ClassLoader classLoader = getClass().getClassLoader();
+        File file = new File(classLoader.getResource(toscaModelURL).getFile());
+        Path path = Paths.get(file.getPath());
+
+        if (toscaModelStream == null) return null;
+
+        return path;
+    }
+
+    /**
+     * Gets the tosca model.
+     *
+     * @param csarInputStream the csar input stream
+     * @return the tosca model
+     * @throws AsdcCatalogException the asdc catalog exception
+     */
+    private ToscaCsar getToscaModel(InputStream csarInputStream) throws AsdcCatalogException {
+        final Path csarFile;
+
+        try {
+            csarFile = Files.createTempFile("csar", ".zip");
+            Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);
+        } catch (IOException e) {
+            throw new AsdcCatalogException("Caught IOException while creating CSAR", e);
+        }
+
+        try (final ZipFile csar = new ZipFile(csarFile.toFile())) {
+
+            final InputStream toscaMetaStream = csar.getInputStream(csar.getEntry("TOSCA-Metadata/TOSCA.meta"));
+            final ToscaMeta toscaMeta = new ToscaMeta.Builder(toscaMetaStream).build();
+            final String entryDefinitions = toscaMeta.get("Entry-Definitions");
+            final InputStream toscaParentEntryYamlStream = csar.getInputStream(csar.getEntry(entryDefinitions));
+
+            final Yaml yaml = new Yaml();
+            final ToscaModel parentModel = yaml.loadAs(toscaParentEntryYamlStream, ToscaModel.class);
+
+            final ToscaCsar.Builder csarBuilder = new ToscaCsar.Builder(parentModel);
+
+            for (Map<String, Map<String, String>> imports : parentModel.getImports()) {
+                for (Map.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);
+                }
+            }
+
+            return csarBuilder.build();
+        } catch (IOException e) {
+            throw new AsdcCatalogException("Caught IOException while processing CSAR", e);
+        }
+    }
+
+}
index c5134bf..123cc57 100755 (executable)
@@ -7,7 +7,7 @@
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *     \r
  *      http://www.apache.org/licenses/LICENSE-2.0\r
  * \r
  * Unless required by applicable law or agreed to in writing, software\r
@@ -168,7 +168,6 @@ public class InMemoryAsdcClient implements AsdcClient {
        }\r
 \r
        /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResources()\r
         */\r
        public Collection<Resource> getResources() throws AsdcCatalogException {\r
                final Collection<Resource> resources = new LinkedList<Resource> ();\r
@@ -299,7 +298,7 @@ public class InMemoryAsdcClient implements AsdcClient {
        /* (non-Javadoc)\r
         * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)\r
         */\r
-       public ToscaCsar getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {\r
+       public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {\r
                final String toscaModelURL = getCatalog().getJSONObject("resources")\r
                                .getJSONObject(resourceUuid.toString())\r
                                .getString("toscaModelURL");\r
@@ -309,13 +308,13 @@ public class InMemoryAsdcClient implements AsdcClient {
                \r
                if (toscaModelStream == null) return null;\r
                \r
-               return getToscaModel(toscaModelStream);\r
+               return null;//getToscaModel(toscaModelStream);\r
        }\r
 \r
        /* (non-Javadoc)\r
         * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)\r
         */\r
-       public ToscaCsar getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {\r
+       public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {\r
                final String toscaModelURL = getCatalog().getJSONObject("services")\r
                                                .getJSONObject(serviceUuid.toString())\r
                                                .getString("toscaModelURL");\r
@@ -324,7 +323,7 @@ public class InMemoryAsdcClient implements AsdcClient {
                \r
                if (toscaModelStream == null) return null;\r
                \r
-               return getToscaModel(toscaModelStream);\r
+               return null;//getToscaModel(toscaModelStream);\r
        }\r
 \r
        /**\r
@@ -369,4 +368,5 @@ public class InMemoryAsdcClient implements AsdcClient {
                        throw new AsdcCatalogException("Caught IOException while processing CSAR", e);\r
                }\r
        }\r
+\r
 }\r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParser.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParser.java
new file mode 100644 (file)
index 0000000..eb16698
--- /dev/null
@@ -0,0 +1,15 @@
+package org.openecomp.vid.asdc.parser;
+
+import java.nio.file.Path;
+
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.model.ServiceModel;
+
+public interface ToscaParser{
+       ToscaCsar parse(Path path) throws AsdcCatalogException;
+       
+       ServiceModel makeServiceModel(String uuid,Path path,Service asdcServiceMetadata) throws Exception;
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl.java
new file mode 100644 (file)
index 0000000..bea5da8
--- /dev/null
@@ -0,0 +1,225 @@
+package org.openecomp.vid.asdc.parser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Map.Entry;
+import java.util.zip.ZipFile;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.asdc.beans.tosca.NodeTemplate;
+import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;
+import org.openecomp.vid.asdc.beans.tosca.ToscaMeta;
+import org.openecomp.vid.asdc.beans.tosca.ToscaModel;
+import org.openecomp.vid.model.ModelConstants;
+import org.openecomp.vid.model.Network;
+import org.openecomp.vid.model.Node;
+import org.openecomp.vid.model.ServiceModel;
+import org.openecomp.vid.model.VNF;
+import org.openecomp.vid.properties.VidProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class ToscaParserImpl implements ToscaParser {
+       /** The Constant LOG. */
+       static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ToscaParserImpl.class);
+
+       @Autowired
+       private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+
+       private static final String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
+       private static final String vnfTag = asdcModelNamespace + ModelConstants.VNF;
+       private static final String networkTag = asdcModelNamespace + ModelConstants.NETWORK;
+       private static final String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+
+       
+       @Override
+       public ToscaCsar parse(Path path) throws AsdcCatalogException {
+               return getToscaCsar(path);
+       }
+
+       private ToscaCsar getToscaCsar(final Path csarFile) throws AsdcCatalogException {
+               try (final ZipFile csar = new ZipFile(csarFile.toFile())) {
+
+                       final InputStream toscaMetaStream = csar.getInputStream(csar.getEntry("TOSCA-Metadata/TOSCA.meta"));
+                       final ToscaMeta toscaMeta = new ToscaMeta.Builder(toscaMetaStream).build();
+                       final String entryDefinitions = toscaMeta.get("Entry-Definitions");
+                       final InputStream toscaParentEntryYamlStream = csar.getInputStream(csar.getEntry(entryDefinitions));
+
+                       try {
+                               final Yaml yaml = new Yaml();
+                               final ToscaModel parentModel = yaml.loadAs(toscaParentEntryYamlStream, ToscaModel.class);
+
+                               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()) {
+                                               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);
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               return csarBuilder.build();
+                       } catch (YAMLException e) {
+                               throw new AsdcCatalogException("Caught exception while processing TOSCA YAML", e);
+                       }
+               } catch (IOException e) {
+                       throw new AsdcCatalogException("Caught IOException while processing CSAR", e);
+               }
+       }
+       
+       public ServiceModel makeServiceModel(String uuid, final Path serviceCsar,Service service ) throws AsdcCatalogException, SdcToscaParserException {
+                
+                       
+               final ServiceModel serviceModel = new ServiceModel();
+               ToscaCsar toscaCsar = getToscaCsar(serviceCsar);
+               String methodName = "getServices";
+               LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+               Boolean isNewFlow = false;
+               final Map<String, VNF> vnfs = new HashMap<String, VNF>();
+               final Map<String, Network> networks = new HashMap<String, Network>();
+               final ToscaModel asdcServiceToscaModel = toscaCsar.getParent();
+               serviceModel.setService(ServiceModel.extractService(asdcServiceToscaModel, service));
+
+
+               populateVnfsAndNetwork(methodName, isNewFlow, vnfs, networks, asdcServiceToscaModel, serviceModel);
+
+               // If we see customization uuid under vnf or network, follow 1702 flow
+               if (isNewFlow) {
+                       return (getCustomizedServices(asdcServiceToscaModel, serviceModel));
+               } else {
+                       VNF vnf = null;
+                       for (ToscaModel vnfModel : toscaCsar.getChildren()) {
+                               // using uuid to match should only be valid for 1610 models
+                               final String vnfUuid = (vnfModel.getMetadata().getUUID());
+                               // find the VNF with that uuid, uuid is not the key anymore
+                               vnf = findVNFAccordingToUUID(vnfs, vnfUuid);
+                               if (vnf == null) {
+                                       LOG.warn("Couldn't find VNF object " + vnfUuid + ". Problem with Tosca model?");
+                                       continue;
+                               }
+                               extractAndUpdateInputs(vnf, vnfModel);
+                               ServiceModel.extractGroups(vnfModel, serviceModel);
+                       }
+
+                       serviceModel.setVnfs(vnfs);
+                       serviceModel.setNetworks(networks);
+                       return serviceModel;
+               }
+       }
+
+       private VNF findVNFAccordingToUUID(final Map<String, VNF> vnfs,  final String vnfUuid) {
+               VNF vnf = null;
+               for (Entry<String, VNF> vnfComp : vnfs.entrySet()) {
+                       if (((vnfComp.getValue().getUuid()).equalsIgnoreCase(vnfUuid))) {
+                               // found the vnf
+                               vnf = vnfComp.getValue();
+                       }
+               }
+               return vnf;
+       }
+
+       private void extractAndUpdateInputs(VNF vnf, ToscaModel vnfModel) {
+               vnf.setInputs(vnfModel.gettopology_template().getInputs());
+       }
+
+       private static void populateVnfsAndNetwork(String methodName, Boolean isNewFlow, final Map<String, VNF> vnfs,
+                       final Map<String, Network> networks, final ToscaModel asdcServiceToscaModel, ServiceModel serviceModel)
+                                       throws AsdcCatalogException, SdcToscaParserException {
+               for (Entry<String, NodeTemplate> component : extractNodeTemplates(asdcServiceToscaModel)) {
+                       final String modelCustomizationName = component.getKey();
+                       LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName
+                                       + " model customization name: " + modelCustomizationName);
+                       final NodeTemplate nodeTemplate = component.getValue();
+                       final String type = nodeTemplate.getType();
+
+                       if (type.startsWith(vnfTag)) {
+                               LOG.debug(EELFLoggerDelegate.debugLogger,
+                                               dateFormat.format(new Date()) + methodName + " found node template type: " + type);
+                               final VNF vnf = new VNF();
+                               vnf.extractVnf(modelCustomizationName, nodeTemplate);
+//                             populateNodeVersionIfMissing(nodeTemplate, vnf,service);
+                               LOG.debug(EELFLoggerDelegate.debugLogger,
+                                               dateFormat.format(new Date()) + methodName + " VNF commands: " + vnf.getCommands());
+                               vnfs.put(modelCustomizationName, vnf);
+                               isNewFlow = isNewFlow(vnf);
+                       }
+                       // Networks
+                       if (type.startsWith(networkTag)) {
+                               LOG.debug(EELFLoggerDelegate.debugLogger,
+                                               dateFormat.format(new Date()) + methodName + " found node template type: " + type);
+                               final Network network = new Network();
+                               network.extractNetwork(modelCustomizationName, nodeTemplate);
+//                             populateNodeVersionIfMissing(nodeTemplate, network, service);
+                               isNewFlow = isNewFlow(network);
+                               networks.put(modelCustomizationName, network);
+
+                       }
+               }
+               serviceModel.setVnfs(vnfs);
+               serviceModel.setNetworks(networks);
+
+       }
+
+       private static Set<Entry<String, NodeTemplate>> extractNodeTemplates(final ToscaModel asdcServiceToscaModel) {
+               return asdcServiceToscaModel.gettopology_template().getnode_templates().entrySet();
+       }
+
+       private static boolean isNewFlow(Node node) {
+               return (node.getCustomizationUuid() != null) && (node.getCustomizationUuid().length() > 0);
+       }
+
+       private static boolean isNodeVersionMissing(Node Node) {
+               return Node.getVersion() == null;
+       }
+
+       private static void populateNodeVersionIfMissing(final NodeTemplate nodeTemplate, final Node node, Service service)
+                       throws AsdcCatalogException {
+               if (isNodeVersionMissing(node)) {
+                       node.setVersion(service.getVersion());
+               }
+       }
+       
+       private ServiceModel getCustomizedServices(ToscaModel asdcServiceToscaModel, ServiceModel serviceModel) {
+               String methodName = "asdcServiceToscaModel";
+               LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+
+               // asdcServiceToscaModel should have vf modules and vol groups populated
+               // at this point but
+               // they are not associated with the VNFs
+               ServiceModel.extractGroups(asdcServiceToscaModel,serviceModel);
+               // Now put the vf modules and volume groups under the VNF they belong
+               // too
+               serviceModel.associateGroups();
+               return (serviceModel);
+       }
+
+
+       private UUID extractUUIDFromNodeTemplate(final NodeTemplate nodeTemplate) {
+               return UUID.fromString(nodeTemplate.getMetadata().getUUID());
+       }
+
+
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java
new file mode 100644 (file)
index 0000000..4819cae
--- /dev/null
@@ -0,0 +1,226 @@
+package org.openecomp.vid.asdc.parser;
+
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.sdc.tosca.parser.impl.FilterType;
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
+import org.openecomp.sdc.toscaparser.api.Group;
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;
+import org.openecomp.sdc.toscaparser.api.Property;
+import org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint;
+import org.openecomp.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.model.*;
+
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ToscaParserImpl2 {
+
+    
+       public class Constants {
+               public final static String uuid = "UUID";
+               public final static String description = "description";
+               public final static String ecompGeneratedNaming = "ecompGeneratedNaming";
+               public final static String customizationUUID = "customizationUUID";
+               public final static String vfModuleModelVersion = "vfModuleModelVersion";
+               public final static String vfModuleModelCustomizationUUID = "vfModuleModelCustomizationUUID";
+               public final static String volume_group = "volume_group";
+               public final static String vfModuleModelInvariantUUID = "vfModuleModelInvariantUUID";
+               public final static String vfModuleModelUUID = "vfModuleModelUUID";
+               public final static String invariantUUID = "invariantUUID";
+               public final static String version = "version";
+               public final static String name = "name";
+               public final static String category = "category";
+               public final static String vfModuleModelName = "vfModuleModelName";
+               public final static String getInput = "get_input";
+       }
+       
+       public ToscaParserImpl2() {
+
+    }
+
+    public ServiceModel makeServiceModel(Path path, Service asdcServiceMetadata) throws Exception {
+        ServiceModel serviceModel = new ServiceModel();
+        SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
+        ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(path.toFile().getAbsolutePath());
+        serviceModel.setService(extractServiceFromCsar(asdcServiceMetadata, sdcCsarHelper));
+        serviceModel.setVolumeGroups(extractVolumeGroups(sdcCsarHelper));
+        serviceModel.setVfModules(extractVfModuleFromCsar(sdcCsarHelper));
+        serviceModel.setVnfs(extractVnfsFromCsar(sdcCsarHelper));
+        serviceModel.setNetworks(extractNetworksFromCsar(sdcCsarHelper));
+        return serviceModel;
+    }
+
+    private  org.openecomp.vid.model.Service extractServiceFromCsar(Service asdcServiceMetadata, ISdcCsarHelper csarHelper) throws SdcToscaParserException {
+        org.openecomp.vid.model.Service service = new  org.openecomp.vid.model.Service();
+
+        service.setName(csarHelper.getServiceMetadata().getValue(Constants.name));
+        service.setCategory(csarHelper.getServiceMetadata().getValue(Constants.category));
+        service.setInvariantUuid(csarHelper.getServiceMetadata().getValue(Constants.invariantUUID));
+        service.setUuid(csarHelper.getServiceMetadata().getValue(Constants.uuid));
+        service.setVersion(asdcServiceMetadata.getVersion());
+        service.setDescription(csarHelper.getServiceMetadata().getValue(Constants.description));
+        service.setInputs(inputsListToInputsMap(csarHelper.getServiceInputs()));
+        service.setServiceEcompNaming(csarHelper.getServiceMetadata().getValue(Constants.ecompGeneratedNaming));
+        return service;
+    }
+    
+    private Map<String, VNF> extractVnfsFromCsar(ISdcCsarHelper csarHelper) {
+        List<NodeTemplate> nodeTemplates = csarHelper.getServiceVfList();
+        Map<String, VNF> vnfsMaps = new HashMap<String, VNF>();
+
+        for (NodeTemplate nodeTemplate : nodeTemplates) {
+            VNF vnf = new VNF();
+            populateNodeFromNodeTemplate(nodeTemplate, csarHelper, vnf);
+            vnf.setModelCustomizationName(nodeTemplate.getName());
+            vnfsMaps.put(nodeTemplate.getName(), vnf);
+        }
+        return vnfsMaps;
+    }
+
+    private Map<String, Network> extractNetworksFromCsar(ISdcCsarHelper csarHelper) {
+        List<NodeTemplate> nodeTemplates = csarHelper.getServiceVlList();
+        Map<String, Network> networksMap = new HashMap<String, Network>();
+
+        for (NodeTemplate nodeTemplate : nodeTemplates) {
+            Network newNetwork = new Network();
+            populateNodeFromNodeTemplate(nodeTemplate, csarHelper, newNetwork);
+            newNetwork.setModelCustomizationName(nodeTemplate.getName());
+            networksMap.put(nodeTemplate.getName(), newNetwork);
+        }
+        return networksMap;
+    }
+
+    private Map<String, VfModule> extractVfModuleFromCsar(ISdcCsarHelper csarHelper) {
+        List<NodeTemplate> serviceVfList = csarHelper.getServiceVfList();
+        HashMap<String, VfModule> vfModuleHashMap = new HashMap<>();
+
+        for (NodeTemplate nodeTemplate : serviceVfList) {
+            List<Group> groups = csarHelper.getVfModulesByVf(nodeTemplate.getMetaData().getValue(Constants.customizationUUID));
+            for (Group group : groups) {
+                vfModuleHashMap.put(group.getName(), populateVfModuleFromGroup(group));
+            }
+        }
+        return vfModuleHashMap;
+    }
+
+
+    private Map<String, VolumeGroup> extractVolumeGroups(ISdcCsarHelper csarHelper) {
+        HashMap<String, VolumeGroup> volumeGroupHashMap = new HashMap<>();
+        for (NodeTemplate nodeTemplate : csarHelper.getServiceVfList()) {
+            List<Group> groups = csarHelper.getVfModulesByVf(csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
+            for (Group group : groups) {
+                boolean isVolumeGroup = Boolean.valueOf(group.getPropertyValue(Constants.volume_group).toString());
+                if (isVolumeGroup) {
+                    volumeGroupHashMap.put(group.getName(), populateVolumeGroupFromGroup(group));
+                }
+            }
+        }
+        return volumeGroupHashMap;
+    }
+
+    private Map<String, org.openecomp.vid.asdc.beans.tosca.Input> inputsListToInputsMap(List<org.openecomp.sdc.toscaparser.api.parameters.Input> inputList) {
+        Map<String, org.openecomp.vid.asdc.beans.tosca.Input> inputs = new HashMap<>();
+        for (org.openecomp.sdc.toscaparser.api.parameters.Input input : inputList) {
+            inputs.put(input.getName(), convertInput(input, new org.openecomp.vid.asdc.beans.tosca.Input()));
+        }
+        return inputs;
+    }
+
+    private Node populateNodeFromNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode) {
+        newNode.setCustomizationUuid(csarHelper.getNodeTemplateCustomizationUuid(nodeTemplate));
+        newNode.setDescription(nodeTemplate.getMetaData().getValue(Constants.description));
+        newNode.setInvariantUuid(nodeTemplate.getMetaData().getValue(Constants.invariantUUID));
+        newNode.setUuid(nodeTemplate.getMetaData().getValue(Constants.uuid));
+        newNode.setName(nodeTemplate.getMetaData().getValue(Constants.name));
+        newNode.setVersion(nodeTemplate.getMetaData().getValue(Constants.version));
+        newNode.setInputs(extractInputsAndCommandsForNodeTemplate(nodeTemplate, csarHelper, newNode));
+        Map<String, String> propertiesMap = setPropertiesOfVnf(nodeTemplate.getPropertiesObjects());
+        newNode.setProperties(propertiesMap);
+        return newNode;
+    }
+
+    private VfModule populateVfModuleFromGroup(Group group){
+        VfModule vfModule = new VfModule();
+
+        vfModule.setVersion(group.getMetadata().getValue(Constants.vfModuleModelVersion));
+        vfModule.setCustomizationUuid(group.getMetadata().getValue(Constants.vfModuleModelCustomizationUUID));
+        vfModule.setModelCustomizationName(group.getMetadata().getValue(Constants.vfModuleModelName));
+        vfModule.setName(group.getMetadata().getValue(Constants.vfModuleModelName));
+        vfModule.setVolumeGroupAllowed(Boolean.valueOf((group.getPropertyValue(Constants.volume_group)).toString()));
+        vfModule.setDescription(group.getDescription());
+        vfModule.setInvariantUuid(group.getMetadata().getValue(Constants.vfModuleModelInvariantUUID));
+        vfModule.setUuid(group.getMetadata().getValue(Constants.vfModuleModelUUID));
+        return vfModule;
+    }
+
+    private VolumeGroup populateVolumeGroupFromGroup(Group group){
+        VolumeGroup volumeGroup = new VolumeGroup();
+        volumeGroup.setDescription(group.getDescription());
+        volumeGroup.setInvariantUuid(group.getMetadata().getValue(Constants.vfModuleModelInvariantUUID));
+        volumeGroup.setName(group.getMetadata().getValue(Constants.vfModuleModelName));
+        volumeGroup.setModelCustomizationName(group.getMetadata().getValue(Constants.vfModuleModelName));
+        volumeGroup.setVersion(group.getMetadata().getValue(Constants.vfModuleModelVersion));
+        volumeGroup.setUuid(group.getMetadata().getValue(Constants.vfModuleModelUUID));
+        return volumeGroup;
+    }
+
+
+    private Map<String, org.openecomp.vid.asdc.beans.tosca.Input> extractInputsAndCommandsForNodeTemplate(NodeTemplate nodeTemplate, ISdcCsarHelper csarHelper, Node newNode){
+        Map<String, org.openecomp.vid.asdc.beans.tosca.Input> inputMap = new HashMap<>();
+        Map<String, CommandProperty> commandPropertyMap = new HashMap<>();
+
+        List<Input> inputs = csarHelper.getServiceInputs();
+        Map<String, String> properties  = csarHelper.filterNodeTemplatePropertiesByValue(nodeTemplate, FilterType.CONTAINS, Constants.getInput);
+        for (Map.Entry<String, String> property : properties.entrySet()) {
+            String inputKey = property.getValue();
+            String key = extractInputValue(inputKey);
+            for (Input input: inputs){
+                if(input.getName().equals(key)){
+                    org.openecomp.vid.asdc.beans.tosca.Input localInput = new org.openecomp.vid.asdc.beans.tosca.Input();
+                    localInput = convertInput(input, localInput);
+                    String name = property.getKey();
+                    commandPropertyMap.put(name, extractCommands(name, key));
+                    inputMap.put(name, localInput);
+                }
+            }
+        }
+        newNode.setCommands(commandPropertyMap);
+        return inputMap;
+    }
+
+    private String extractInputValue(String inputKey) {
+        return inputKey.substring(inputKey.indexOf(":") + 1);
+    }
+
+    private org.openecomp.vid.asdc.beans.tosca.Input convertInput(Input parserInput, org.openecomp.vid.asdc.beans.tosca.Input localInput){
+        localInput.setDefault(parserInput.getDefault());
+        localInput.setDescription(parserInput.getDescription());
+        localInput.setRequired(parserInput.isRequired());
+        localInput.setType(parserInput.getType());
+        localInput.setConstraints(parserInput.getConstraints());
+//        localInput.setentry_schema()
+        return localInput;
+    }
+
+    private CommandProperty extractCommands(String displayName, String inputName){
+        CommandProperty commandProperty = new CommandProperty();
+        commandProperty.setDisplayName(displayName);
+        commandProperty.setCommand(Constants.getInput);
+        commandProperty.setInputName(inputName);
+        return commandProperty;
+    }
+
+    private Map<String, String> setPropertiesOfVnf(List<Property> properties) {
+        Map<String, String> propertiesMap = new HashMap<String, String>();
+        for (Property property : properties) {
+            propertiesMap.put(property.getName(), property.getValue().toString());
+        }
+        return propertiesMap;
+    }
+
+
+}
\ No newline at end of file
index 9f7c3a5..5b783f5 100755 (executable)
 \r
 package org.openecomp.vid.asdc.rest;\r
 \r
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;\r
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.openecomp.vid.asdc.AsdcCatalogException;\r
+import org.openecomp.vid.asdc.AsdcClient;\r
+import org.openecomp.vid.asdc.beans.Artifact;\r
+import org.openecomp.vid.asdc.beans.Resource;\r
+import org.openecomp.vid.asdc.beans.Service;\r
+import org.openecomp.vid.asdc.parser.ToscaParserImpl;\r
+import org.openecomp.vid.model.ModelConstants;\r
+import org.openecomp.vid.properties.VidProperties;\r
+\r
+import javax.ws.rs.NotFoundException;\r
+import javax.ws.rs.ProcessingException;\r
+import javax.ws.rs.WebApplicationException;\r
+import javax.ws.rs.client.Client;\r
+import javax.ws.rs.client.ResponseProcessingException;\r
+import javax.ws.rs.client.WebTarget;\r
+import javax.ws.rs.core.GenericType;\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.MultivaluedHashMap;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
-import java.io.FileInputStream;\r
-import java.io.File;\r
 import java.net.URI;\r
 import java.nio.file.Files;\r
 import java.nio.file.Path;\r
@@ -35,441 +53,413 @@ import java.util.Collections;
 import java.util.Map;\r
 import java.util.Map.Entry;\r
 import java.util.UUID;\r
-import java.util.zip.ZipFile;\r
-\r
-import javax.ws.rs.NotFoundException;\r
-import javax.ws.rs.ProcessingException;\r
-import javax.ws.rs.WebApplicationException;\r
-import javax.ws.rs.client.Client;\r
-import javax.ws.rs.client.ResponseProcessingException;\r
-import javax.ws.rs.client.WebTarget;\r
-import javax.ws.rs.core.GenericType;\r
-import javax.ws.rs.core.MediaType;\r
-import javax.ws.rs.core.MultivaluedHashMap;\r
-\r
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
-import org.openecomp.vid.asdc.AsdcCatalogException;\r
-import org.openecomp.vid.asdc.AsdcClient;\r
-import org.openecomp.vid.asdc.beans.Artifact;\r
-import org.openecomp.vid.asdc.beans.Resource;\r
-import org.openecomp.vid.asdc.beans.Service;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaMeta;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaModel;\r
-import org.openecomp.vid.model.ModelConstants;\r
-import org.yaml.snakeyaml.Yaml;\r
-import org.yaml.snakeyaml.error.YAMLException;\r
-\r
-import org.openecomp.vid.properties.VidProperties;\r
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;\r
 \r
 /**\r
  * The Class RestfulAsdcClient.\r
  */\r
 public class RestfulAsdcClient implements AsdcClient {\r
 \r
-       /** The Constant LOG. */\r
-       private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);\r
-       \r
-       /** The Constant dateFormat. */\r
-       final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");\r
-       \r
-       /** The client. */\r
-       private final Client client;\r
-       \r
-       /** The uri. */\r
-       private final URI uri;\r
-       \r
-       /** The common headers. */\r
-       private final MultivaluedHashMap<String, Object> commonHeaders;\r
-       \r
-       /** The auth. */\r
-       private final String auth;\r
-       \r
-       /**\r
-        * The Class Builder.\r
-        */\r
-       public static class Builder {\r
-       \r
-               /** The client. */\r
-               private final Client client;\r
-               \r
-               /** The uri. */\r
-               private final URI uri;\r
-               \r
-               /** The auth. */\r
-               private String auth = null;\r
-               \r
-               /**\r
-                * Instantiates a new builder.\r
-                *\r
-                * @param client the client\r
-                * @param uri the uri\r
-                */\r
-               public Builder(Client client, URI uri) {\r
-                       this.client = client;\r
-                       this.client.register(JacksonJsonProvider.class);\r
-                       this.uri = uri;\r
-               }\r
-               \r
-               /**\r
-                * Auth.\r
-                *\r
-                * @param auth the auth\r
-                * @return the builder\r
-                */\r
-               public Builder auth(String auth) {\r
-                       this.auth = auth;\r
-                       return this;\r
-               }\r
-               \r
-               /**\r
-                * Builds the.\r
-                *\r
-                * @return the restful asdc client\r
-                */\r
-               public RestfulAsdcClient build() {\r
-                       return new RestfulAsdcClient(this);\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Instantiates a new restful asdc client.\r
-        *\r
-        * @param builder the builder\r
-        */\r
-       private RestfulAsdcClient(Builder builder) {\r
-               client = builder.client;\r
-               uri = builder.uri;\r
-               auth = builder.auth;\r
-               \r
-               commonHeaders = new MultivaluedHashMap<String, Object> ();\r
-               commonHeaders.put("X-ECOMP-InstanceID", Collections.singletonList((Object) "VID"));\r
-               commonHeaders.put("Authorization",  Collections.singletonList((Object) (auth)));\r
-       }\r
-       \r
-       /**\r
-        * Gets the client.\r
-        *\r
-        * @return the client\r
-        */\r
-       private Client getClient() { return client; }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)\r
-        */\r
-       public Resource getResource(UUID uuid) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path(path + "/" + uuid.toString() + "/metadata")\r
-                                       .request(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(Resource.class);\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResources()\r
-        */\r
-       public Collection<Resource> getResources() throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path(path)\r
-                                       .request(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(new GenericType<Collection<Resource>> () {});\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)\r
-        */\r
-       public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
-               WebTarget target = getClient()\r
-                               .target(uri)\r
-                               .path(path);\r
-               \r
-               for (Entry<String, String[]> filterEntry : filter.entrySet()) {\r
-                       target = target.queryParam(filterEntry.getKey(), (Object []) filterEntry.getValue());\r
-               }\r
-               \r
-               try {\r
-                       return target.request()\r
-                                       .accept(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(new GenericType<Collection<Resource>> () {});\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (NotFoundException e) {\r
-                       throw e;\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)\r
-        */\r
-       public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path(path + "/" + resourceUuid + "/artifacts/" + artifactUuid)\r
-                                       .request(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(Artifact.class);\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)\r
-        */\r
-       public Service getService(UUID uuid) throws AsdcCatalogException {\r
-               \r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path( path + "/" + uuid.toString() + "/metadata")\r
-                                       .request(MediaType.APPLICATION_JSON)\r
-                                       .headers(commonHeaders)\r
-                                       .get(Service.class);\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getServices()\r
-        */\r
-       public Collection<Service> getServices() throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path(path)\r
-                                       .request()\r
-                                       .accept(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(new GenericType<Collection<Service>> () {});\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getServices(java.util.Map)\r
-        */\r
-       public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {\r
-               \r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
-               WebTarget target = getClient()\r
-                               .target(uri)\r
-                               .path(path);\r
-               \r
-                       \r
-               for (Entry<String, String[]> filterEntry : filter.entrySet()) {\r
-                       target = target.queryParam(filterEntry.getKey(), (Object []) filterEntry.getValue());\r
-               }\r
-               \r
-               try {\r
-                       return target.request()\r
-                                       .accept(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(new GenericType<Collection<Service>> () {});\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (NotFoundException e) {\r
-                       throw e;\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)\r
-        */\r
-       public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
-               try {\r
-                       return getClient()\r
-                                       .target(uri)\r
-                                       .path(path + "/" + serviceUuid + "/artifacts/" + artifactUuid)\r
-                                       .request(MediaType.APPLICATION_JSON_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_JSON)\r
-                                       .get(Artifact.class);\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)\r
-        */\r
-       public ToscaCsar getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
-               try (final InputStream csarInputStream = (InputStream) getClient()\r
-                               .target(uri)\r
-                               .path(path + "/" + resourceUuid + "/toscaModel")\r
-                               .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)\r
-                               .headers(commonHeaders)\r
-                               .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)\r
-                               .get(InputStream.class)) {\r
-\r
-                       return getToscaModel(csarInputStream);\r
-               } catch (IOException e) {\r
-                       throw new AsdcCatalogException("Failed to retrieve resource TOSCA model from ASDC", e);\r
-               }\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)\r
-        */\r
-       public ToscaCsar getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {\r
-               String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
-               try {\r
-                       final InputStream csarInputStream = (InputStream) getClient()\r
-                                       .target(uri)\r
-                                       .path(path + "/" + serviceUuid + "/toscaModel")\r
-                                       .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)\r
-                                       .headers(commonHeaders)\r
-                                       .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)\r
-                                       .get(InputStream.class);\r
-                                       \r
-                       return getToscaModel(csarInputStream);\r
-               } catch (ResponseProcessingException e) {\r
-                       //Couldn't convert response to Java type\r
-                       throw new AsdcCatalogException("ASDC response could not be processed", e);\r
-               } catch (ProcessingException e) {\r
-                       //IO problems during request\r
-                       throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
-               } catch (WebApplicationException e) {\r
-                       //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
-                       throw new AsdcCatalogException(e);\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Gets the tosca model.\r
-        *\r
-        * @param csarInputStream the csar input stream\r
-        * @return the tosca model\r
-        * @throws AsdcCatalogException the asdc catalog exception\r
-        */\r
-       private ToscaCsar getToscaModel(InputStream csarInputStream) throws AsdcCatalogException {\r
-               final Path csarFile;\r
-               try {\r
-                       csarFile = Files.createTempFile("csar", ".zip");\r
-                       Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);\r
-               } catch (IOException e) {\r
-                       throw new AsdcCatalogException("Caught IOException while creating CSAR", e);\r
-               }\r
+    /**\r
+     * The Class Builder.\r
+     */\r
+    public static class Builder {\r
+\r
+        /**\r
+         * The client.\r
+         */\r
+        private final Client client;\r
+\r
+        /**\r
+         * The uri.\r
+         */\r
+        private final URI uri;\r
+\r
+        /**\r
+         * The auth.\r
+         */\r
+        private String auth = null;\r
+\r
+        /**\r
+         * Instantiates a new builder.\r
+         *\r
+         * @param client the client\r
+         * @param uri    the uri\r
+         */\r
+        public Builder(Client client, URI uri) {\r
+            this.client = client;\r
+            this.client.register(JacksonJsonProvider.class);\r
+            this.uri = uri;\r
+        }\r
+\r
+        /**\r
+         * Auth.\r
+         *\r
+         * @param auth the auth\r
+         * @return the builder\r
+         */\r
+        public Builder auth(String auth) {\r
+            this.auth = auth;\r
+            return this;\r
+        }\r
+\r
+        /**\r
+         * Builds the.\r
+         *\r
+         * @return the restful asdc client\r
+         */\r
+        public RestfulAsdcClient build() {\r
+            return new RestfulAsdcClient(this);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * The Constant LOG.\r
+     */\r
+    static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);\r
+\r
+    /**\r
+     * The Constant dateFormat.\r
+     */\r
+    final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");\r
+\r
+    /**\r
+     * The client.\r
+     */\r
+    private final Client client;\r
+\r
+    /**\r
+     * The uri.\r
+     */\r
+    private final URI uri;\r
+\r
+    /**\r
+     * The common headers.\r
+     */\r
+    private final MultivaluedHashMap<String, Object> commonHeaders;\r
+\r
+    /**\r
+     * The auth.\r
+     */\r
+    private final String auth;\r
+\r
+    ToscaParserImpl p = new ToscaParserImpl();\r
+\r
+    /**\r
+     * Instantiates a new restful asdc client.\r
+     *\r
+     * @param builder the builder\r
+     */\r
+    private RestfulAsdcClient(Builder builder) {\r
+        client = builder.client;\r
+        uri = builder.uri;\r
+        auth = builder.auth;\r
+\r
+        commonHeaders = new MultivaluedHashMap<String, Object>();\r
+        commonHeaders.put("X-ECOMP-InstanceID", Collections.singletonList((Object) "VID"));\r
+        commonHeaders.put("Authorization", Collections.singletonList((Object) (auth)));\r
+    }\r
+\r
+    private Path createTmpFile(InputStream csarInputStream) throws AsdcCatalogException {\r
+        final Path csarFile;\r
+        try {\r
+            csarFile = Files.createTempFile("csar", ".zip");\r
+            Files.copy(csarInputStream, csarFile, StandardCopyOption.REPLACE_EXISTING);\r
+        } catch (IOException e) {\r
+            throw new AsdcCatalogException("Caught IOException while creating CSAR", e);\r
+        }\r
+        return csarFile;\r
+    }\r
+\r
+    /**\r
+     * Gets the client.\r
+     *\r
+     * @return the client\r
+     */\r
+    private Client getClient() {\r
+        return client;\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)\r
+     */\r
+    public Resource getResource(UUID uuid) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path + "/" + uuid.toString() + "/metadata")\r
+                    .request(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(Resource.class);\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)\r
+     */\r
+    public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path + "/" + resourceUuid + "/artifacts/" + artifactUuid)\r
+                    .request(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(Artifact.class);\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getResources()\r
+     */\r
+    public Collection<Resource> getResources() throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path)\r
+                    .request(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(new GenericType<Collection<Resource>>() {\r
+                    });\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)\r
+     */\r
+    public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
+        WebTarget target = getClient()\r
+                .target(uri)\r
+                .path(path);\r
+\r
+        for (Entry<String, String[]> filterEntry : filter.entrySet()) {\r
+            target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());\r
+        }\r
+\r
+        try {\r
+            return target.request()\r
+                    .accept(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(new GenericType<Collection<Resource>>() {\r
+                    });\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (NotFoundException e) {\r
+            throw e;\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)\r
+     */\r
+    public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);\r
+        try (final InputStream csarInputStream = (InputStream) getClient()\r
+                .target(uri)\r
+                .path(path + "/" + resourceUuid + "/toscaModel")\r
+                .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)\r
+                .headers(commonHeaders)\r
+                .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)\r
+                .get(InputStream.class)) {\r
+\r
+            return getToscaCsar(csarInputStream);\r
+        } catch (IOException e) {\r
+            throw new AsdcCatalogException("Failed to retrieve resource TOSCA model from ASDC", e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)\r
+     */\r
+    public Service getService(UUID uuid) throws AsdcCatalogException {\r
+\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path + "/" + uuid.toString() + "/metadata")\r
+                    .request(MediaType.APPLICATION_JSON)\r
+                    .headers(commonHeaders)\r
+                    .get(Service.class);\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)\r
+     */\r
+    public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
                \r
-               try (final ZipFile csar = new ZipFile(csarFile.toFile())) {\r
-                       \r
-                       final InputStream toscaMetaStream = csar.getInputStream(csar.getEntry("TOSCA-Metadata/TOSCA.meta"));\r
-                       final ToscaMeta toscaMeta = new ToscaMeta.Builder(toscaMetaStream).build();\r
-                       final String entryDefinitions = toscaMeta.get("Entry-Definitions");\r
-                       final InputStream toscaParentEntryYamlStream = csar.getInputStream(csar.getEntry(entryDefinitions));\r
-                       \r
-                       try {\r
-                               final Yaml yaml = new Yaml();\r
-                               final ToscaModel parentModel = yaml.loadAs(toscaParentEntryYamlStream, ToscaModel.class);\r
-       \r
-                               final ToscaCsar.Builder csarBuilder = new ToscaCsar.Builder(parentModel);\r
-                               \r
-                               for (Map<String, Map<String, String>> imports : parentModel.getImports()) {\r
-                                       LOG.debug("imports = " + imports.toString());\r
-                                       for (Entry<String, Map<String, String>> entry : imports.entrySet()) {\r
-                                               if ( entry.getValue() != null) {\r
-                                                       String fname = entry.getValue().get("file");\r
-                                                       if ( ( fname != null ) && (fname.startsWith("service") || fname.startsWith("resource")) ) {\r
-                                                               LOG.debug("fname = " + fname);\r
-                                                               final InputStream toscaChildEntryYamlStream = csar.getInputStream(csar.getEntry("Definitions/" + fname ));\r
-                                                               final ToscaModel childModel = yaml.loadAs(toscaChildEntryYamlStream, ToscaModel.class);\r
-                                                               csarBuilder.addVnf(childModel);\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               }\r
-                               \r
-                               return csarBuilder.build();\r
-                       } catch (YAMLException e) {\r
-                               throw new AsdcCatalogException("Caught exception while processing TOSCA YAML", e);\r
-                       }\r
-               } catch (IOException e) {\r
-                       throw new AsdcCatalogException("Caught IOException while processing CSAR", e);\r
-               }\r
-       }\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path + "/" + serviceUuid + "/artifacts/" + artifactUuid)\r
+                    .request(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(Artifact.class);\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getServices()\r
+     */\r
+    public Collection<Service> getServices() throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
+        try {\r
+            return getClient()\r
+                    .target(uri)\r
+                    .path(path)\r
+                    .request()\r
+                    .accept(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(new GenericType<Collection<Service>>() {\r
+                    });\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getServices(java.util.Map)\r
+     */\r
+    public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {\r
+\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
+        WebTarget target = getClient()\r
+                .target(uri)\r
+                .path(path);\r
+\r
+\r
+        for (Entry<String, String[]> filterEntry : filter.entrySet()) {\r
+            target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());\r
+        }\r
+\r
+        try {\r
+            return target.request()\r
+                    .accept(MediaType.APPLICATION_JSON_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_JSON)\r
+                    .get(new GenericType<Collection<Service>>() {\r
+                    });\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (NotFoundException e) {\r
+            throw e;\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)\r
+     */\r
+    public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {\r
+        String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);\r
+        try {\r
+            final InputStream csarInputStream = (InputStream) getClient()\r
+                    .target(uri)\r
+                    .path(path + "/" + serviceUuid + "/toscaModel")\r
+                    .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)\r
+                    .headers(commonHeaders)\r
+                    .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)\r
+                    .get(InputStream.class);\r
+\r
+\r
+            return getToscaCsar(csarInputStream);\r
+        } catch (ResponseProcessingException e) {\r
+            //Couldn't convert response to Java type\r
+            throw new AsdcCatalogException("ASDC response could not be processed", e);\r
+        } catch (ProcessingException e) {\r
+            //IO problems during request\r
+            throw new AsdcCatalogException("Failed to get a response from ASDC service", e);\r
+        } catch (WebApplicationException e) {\r
+            //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)\r
+            throw new AsdcCatalogException(e);\r
+        }\r
+    }\r
+\r
+\r
+    /**\r
+     * Gets the tosca model.\r
+     *\r
+     * @param csarInputStream the csar input stream\r
+     * @return the tosca model\r
+     * @throws AsdcCatalogException the asdc catalog exception\r
+     */\r
+    private Path getToscaCsar(InputStream csarInputStream) throws AsdcCatalogException {\r
+        return createTmpFile(csarInputStream);\r
+    }\r
 }\r
index 92b7528..861ddf8 100755 (executable)
@@ -302,7 +302,6 @@ public class AaiController extends RestrictedBaseController{
         * @param namedQueryId the named query id\r
         * @param globalCustomerId the global customer id\r
         * @param serviceType the service type\r
-        * @param serviceInstance the service instance\r
         * @return ResponseEntity The response entity\r
         */\r
        @RequestMapping(value="/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET)\r
index f7bf3a5..9972ae5 100755 (executable)
 \r
 package org.openecomp.vid.controller;\r
 \r
-import java.io.InputStream;\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.text.DateFormat;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-import java.util.UUID;\r
-\r
-import javax.net.ssl.SSLContext;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.client.ClientBuilder;\r
-import javax.ws.rs.client.Client;\r
-\r
-import org.json.JSONObject;\r
-import org.json.JSONTokener;\r
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;\r
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;\r
+import org.openecomp.vid.asdc.AsdcCatalogException;\r
 import org.openecomp.vid.exceptions.VidServiceUnavailableException;\r
-import org.openecomp.vid.model.ModelUtil;\r
-import org.openecomp.vid.model.ModelConstants;\r
-import org.openecomp.vid.model.Network;\r
 import org.openecomp.vid.model.ServiceModel;\r
-import org.openecomp.vid.model.VNF;\r
-import org.openecomp.vid.model.VfModule;\r
-import org.openecomp.vid.model.VolumeGroup;\r
-//import org.openecomp.vid.model.Service;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.annotation.Bean;\r
 import org.springframework.web.bind.annotation.PathVariable;\r
 import org.springframework.web.bind.annotation.RequestMapping;\r
 import org.springframework.web.bind.annotation.RequestMethod;\r
 import org.springframework.web.bind.annotation.RestController;\r
 import org.springframework.web.servlet.ModelAndView;\r
+import org.openecomp.vid.services.*;\r
 \r
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;\r
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
-import org.openecomp.vid.asdc.AsdcCatalogException;\r
-import org.openecomp.vid.asdc.AsdcClient;\r
-import org.openecomp.vid.asdc.beans.Resource;\r
-import org.openecomp.vid.asdc.beans.Service;\r
-import org.openecomp.vid.asdc.beans.tosca.Group;\r
-import org.openecomp.vid.asdc.beans.tosca.NodeTemplate;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;\r
-import org.openecomp.vid.asdc.beans.tosca.ToscaModel;\r
-import org.openecomp.vid.asdc.memory.InMemoryAsdcClient;\r
-import org.openecomp.vid.asdc.rest.RestfulAsdcClient;\r
-import org.openecomp.vid.properties.AsdcClientConfiguration;\r
-import org.openecomp.vid.properties.AsdcClientConfiguration.AsdcClientType;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import org.openecomp.vid.properties.VidProperties;\r
-import java.security.KeyManagementException;\r
-import java.security.NoSuchAlgorithmException;\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+//import org.openecomp.vid.model.Service;\r
 \r
-/**\r
- * The Class VidController.\r
- */\r
 @RestController\r
 public class VidController extends RestrictedBaseController {\r
        \r
-       /** The Constant LOG. */\r
        private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class);\r
-       \r
-       /** The Constant dateFormat. */\r
-       final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");\r
-\r
-       /** The app context. */\r
-       @Autowired\r
-       private ApplicationContext appContext;\r
-       \r
-       /**\r
-        * Gets the object mapper.\r
-        *\r
-        * @return the object mapper\r
-        */\r
-       @Bean\r
-       public ObjectMapper getObjectMapper() {\r
-               return new ObjectMapper();\r
-       }\r
-       \r
-       /**\r
-        * Gets the asdc client.\r
-        *\r
-        * @return the asdc client\r
-        */\r
-       @Bean\r
-       public AsdcClient getAsdcClient() {\r
-               \r
-               final AsdcClientConfiguration asdcClientConfig = appContext.getBean(AsdcClientConfiguration.class);\r
 \r
-               switch (asdcClientConfig.getAsdcClientType()) {\r
-               case IN_MEMORY:\r
-                       final InputStream asdcCatalogFile = VidController.class.getClassLoader().getResourceAsStream("catalog.json");\r
-                       final JSONTokener tokener = new JSONTokener(asdcCatalogFile);\r
-                       final JSONObject catalog = new JSONObject(tokener);\r
+       private final VidService service;\r
 \r
-                       return new InMemoryAsdcClient.Builder().catalog(catalog).build();\r
-               case REST:\r
+       @Autowired\r
+       public VidController(VidService vidService) throws SdcToscaParserException{\r
 \r
-                       final String protocol = asdcClientConfig.getAsdcClientProtocol();\r
-                       final String host = asdcClientConfig.getAsdcClientHost();\r
-                       final int port = asdcClientConfig.getAsdcClientPort();\r
-                       final String auth = asdcClientConfig.getAsdcClientAuth();\r
-                       Client cl = null;\r
-                       if ( protocol.equalsIgnoreCase("https") ) {\r
-                               try {\r
-                                       SSLContext ctx = SSLContext.getInstance("TLSv1.2");\r
-                                       ctx.init(null, null, null);\r
-                                       cl = ClientBuilder.newBuilder().sslContext(ctx).build();\r
-                               }\r
-                               catch ( NoSuchAlgorithmException n ) {\r
-                                       throw new RuntimeException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);\r
-                               }\r
-                               catch ( KeyManagementException k ) {\r
-                                       throw new RuntimeException("SDC Client could not be instantiated due to a key management exception", k);\r
-                               }\r
-                       }\r
-                       else {\r
-                               cl = ClientBuilder.newBuilder().build();\r
-                       }\r
-                       \r
-                       try {\r
-                               final URI uri = new URI(protocol + "://" + host + ":" + port + "/");\r
-                               return new RestfulAsdcClient.Builder(cl, uri)\r
-                                                               .auth(auth)\r
-                                                               .build();\r
-                       } catch (URISyntaxException e) {\r
-                               throw new RuntimeException("SDC Client could not be instantiated due to a syntax error in the URI", e);\r
-                       }\r
-                       \r
-               default:\r
-                       throw new RuntimeException(asdcClientConfig.getAsdcClientType() + " is invalid; must be one of " + Arrays.toString(AsdcClientType.values()));\r
-               }\r
+               service = vidService;\r
        }\r
-       \r
+//     \r
        /**\r
         * Gets the services.\r
         *\r
@@ -168,7 +63,8 @@ public class VidController extends RestrictedBaseController {
        @RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)\r
        public Collection<org.openecomp.vid.asdc.beans.Service> getServices(HttpServletRequest request) throws VidServiceUnavailableException {\r
                try {\r
-                       return getAsdcClient().getServices(request.getParameterMap());\r
+                       Map<String, String[]> requestParams = request.getParameterMap();\r
+                       return service.getServices(requestParams);\r
                } catch (AsdcCatalogException e) {\r
                        LOG.error("Failed to retrieve service definitions from SDC", e);\r
                        throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);\r
@@ -188,159 +84,14 @@ public class VidController extends RestrictedBaseController {
         */\r
        @RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET)\r
        public ServiceModel getServices(@PathVariable("uuid") String uuid) throws VidServiceUnavailableException {\r
-               String methodName = "getServices";\r
-        LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");\r
-        boolean isNewFlow = false;\r
-        \r
-        String asdcModelNamespaces[] = VidProperties.getAsdcModelNamespace();\r
-        String[] vnfTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VNF);\r
-        String[] networkTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.NETWORK);\r
-        String[] vfModuleTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VF_MODULE);\r
-        \r
                try {\r
-                       final ServiceModel serviceModel = new ServiceModel();\r
-                       final Map<String, VNF> vnfs = new HashMap<String, VNF> ();\r
-                       final Map<String, Network> networks = new HashMap<String, Network> ();\r
-                       \r
-                       final ToscaCsar serviceCsar = getAsdcClient().getServiceToscaModel(UUID.fromString(uuid));\r
-                       final Service asdcServiceMetadata = getAsdcClient().getService(UUID.fromString(uuid));\r
-                       final ToscaModel asdcServiceToscaModel = serviceCsar.getParent();\r
-                       \r
-                       serviceModel.setService(ServiceModel.extractService(asdcServiceToscaModel, asdcServiceMetadata));\r
-                       \r
-                       for (Entry<String, NodeTemplate> component: asdcServiceToscaModel.gettopology_template().getnode_templates().entrySet()) {\r
-                               final String modelCustomizationName = component.getKey();\r
-                               LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " model customization name: " + modelCustomizationName);\r
-                               final NodeTemplate nodeTemplate = component.getValue();\r
-                               final String type = nodeTemplate.getType();\r
-                               \r
-                               // is it a VNF?\r
-                               if ( ModelUtil.isType (type, vnfTags) ) {\r
-                    LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " found node template type: " + type);\r
-\r
-                                       final UUID vnfUuid = UUID.fromString(nodeTemplate.getMetadata().getUUID());\r
-                                       final VNF vnf = new VNF();\r
-                                       vnf.extractVnf(modelCustomizationName, nodeTemplate);\r
-                                       \r
-                                       if (vnf.getVersion() == null) {\r
-                                               // vnf version should always be populated. The call below may not return the correct metadata since\r
-                                               // uuid is not unique\r
-                                               final Resource vnfMetadata = getAsdcClient().getResource(UUID.fromString(nodeTemplate.getMetadata().getUUID()));\r
-                                               vnf.setVersion(vnfMetadata.getVersion());\r
-                                       }\r
-              \r
-                    LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " VNF commands: " + vnf.getCommands());\r
-                                       vnfs.put(modelCustomizationName, vnf);\r
-                                       if ( (vnf.getCustomizationUuid() != null) && (vnf.getCustomizationUuid().length() > 0 ) ) {\r
-                                               isNewFlow = true;\r
-                                       }\r
-                               }\r
-                               \r
-                               // is it a Network?\r
-                               if ( ModelUtil.isType (type, networkTags) ) {\r
-                                       LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " found node template type: " + type);\r
-                                       final UUID networkUuid = UUID.fromString(nodeTemplate.getMetadata().getUUID());\r
-                                       final Network network = new Network();\r
-                                       network.extractNetwork(modelCustomizationName, nodeTemplate);\r
-                                       \r
-                                       if (network.getVersion() == null) {\r
-                                               // network version should always be populated. The call below may not return the correct metadata since\r
-                                               // uuid is not unique\r
-                                               final Resource networkMetadata = getAsdcClient().getResource(UUID.fromString(nodeTemplate.getMetadata().getUUID()));\r
-                                               network.setVersion(networkMetadata.getVersion());\r
-                                       }\r
-                                       if ( (network.getCustomizationUuid() != null) && (network.getCustomizationUuid().length() > 0 ) ) {\r
-                                               isNewFlow = true;\r
-                                       }\r
-                                       networks.put(modelCustomizationName, network);\r
-                                       \r
-                               }               \r
-                       }\r
-                       serviceModel.setVnfs(vnfs);\r
-                       serviceModel.setNetworks(networks);\r
-                       // If we see customization uuid under vnf or network, follow 1702 flow\r
-                       if ( isNewFlow ) {\r
-                               return ( getCustomizedServices(asdcServiceToscaModel, serviceModel) );\r
-                       }\r
-                       VNF vnf = null;\r
-                       for (ToscaModel vnfModel : serviceCsar.getChildren()) {\r
-                               \r
-                               // using uuid to match should only be valid for 1610 models\r
-                               \r
-                               final String vnfUuid = (vnfModel.getMetadata().getUUID());\r
-                               // find the VNF with that uuid, uuid is not the key anymore\r
-                               for ( Entry<String, VNF> vnfComp : vnfs.entrySet() ) {\r
-                                       if ( ( ( vnfComp.getValue().getUuid() ).equalsIgnoreCase(vnfUuid) ) ) {\r
-                                               // found the vnf\r
-                                               vnf = vnfComp.getValue();\r
-                                       }\r
-                               }\r
-                               final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();\r
-                               final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();\r
-                               \r
-                               if (vnf == null) {\r
-                                       LOG.warn("Couldn't find VNF object " + vnfUuid + ". Problem with Tosca model?");\r
-                                       continue;\r
-                               }\r
-\r
-                               vnf.setInputs(vnfModel.gettopology_template().getInputs());\r
-\r
-                               for (Entry<String, Group> component1 : vnfModel.gettopology_template().getGroups().entrySet()) {\r
-                                       final Group group = component1.getValue();\r
-                                       final String type = group.getType();\r
-                                       final String modelCustomizationName = component1.getKey();\r
-                                       \r
-                                       // VF Module Customization UUID: We may have the complete set of all VF Modules for all VNFs under service and VF Modules under each VNF.\r
-                                       // Keep using the VF Modules under VNFs but we need to get the customization uuid from the service level and put them\r
-                                       // under each VF module at the VNF level\r
-                                       if ( ModelUtil.isType (type, vfModuleTags) ) {\r
-                                       \r
-                                               VfModule vfMod = VfModule.extractVfModule(modelCustomizationName, group);\r
-                                               \r
-                                               // Add the vf module customization uuid from the service model\r
-                                               // The key of the VF Module in the service level will be the VF instance name appended to the VF Module name: \r
-                                               // <VF instance name>..<VF Module name>\r
-                                               /* String normalizedVnfCustomizationName = VNF.normalizeName (vnf.getModelCustomizationName());\r
-                                               org.openecomp.vid.model.Service.extractVfModuleCustomizationUUID (serviceModel.getService(), normalizedVnfCustomizationName, vfMod);*/\r
-                                                               \r
-                                               vfModules.put(modelCustomizationName, vfMod);\r
-                                               \r
-                                               if ( vfMod.isVolumeGroupAllowed() ) {\r
-                                                               volumeGroups.put(modelCustomizationName, VolumeGroup.extractVolumeGroup(modelCustomizationName, group));\r
-                                               }\r
-                                               \r
-                                       }\r
-                               }\r
-                               \r
-                               vnf.setVfModules(vfModules);\r
-                               vnf.setVolumeGroups(volumeGroups);\r
-                       }\r
-                       \r
-                       serviceModel.setVnfs(vnfs);\r
-                       serviceModel.setNetworks(networks);\r
-                       \r
-                       return serviceModel;\r
+                       return service.getService(uuid);\r
                } catch (AsdcCatalogException e) {\r
                        LOG.error("Failed to retrieve service definitions from SDC", e);\r
                        throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);\r
                }\r
-               catch (Exception e) {\r
-                       LOG.error("Failed to retrieve service definitions from SDC", e);\r
-                       throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);\r
-               }\r
        }\r
 \r
-       public ServiceModel getCustomizedServices(ToscaModel asdcServiceToscaModel, ServiceModel serviceModel) {\r
-               String methodName = "asdcServiceToscaModel";\r
-        LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");\r
-        \r
-        // asdcServiceToscaModel should have vf modules and vol groups populated at this point but \r
-        // they are not associated with the VNFs\r
-               serviceModel.extractGroups(asdcServiceToscaModel);\r
-               // Now put the vf modules and volume groups under the VNF they belong too\r
-               serviceModel.associateGroups();\r
-               return (serviceModel);\r
-       }\r
 \r
        /**\r
         * Gets the services view.\r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java
new file mode 100644 (file)
index 0000000..9a258a1
--- /dev/null
@@ -0,0 +1,106 @@
+package org.openecomp.vid.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.openecomp.vid.asdc.AsdcClient;
+import org.openecomp.vid.asdc.local.LocalAsdcClient;
+import org.openecomp.vid.asdc.memory.InMemoryAsdcClient;
+import org.openecomp.vid.asdc.rest.RestfulAsdcClient;
+import org.openecomp.vid.asdc.parser.ToscaParserImpl2;
+import org.openecomp.vid.properties.AsdcClientConfiguration;
+import org.openecomp.vid.properties.AsdcClientConfiguration.AsdcClientType;
+import org.openecomp.vid.services.VidService;
+import org.openecomp.vid.services.VidServiceImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.net.ssl.SSLContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+
+@Configuration
+public class WebConfig {
+
+    /**
+     * Gets the object mapper.
+     *
+     * @return the object mapper
+     */
+    @Bean
+    public ObjectMapper getObjectMapper() {
+        return new ObjectMapper();
+    }
+
+    @Bean
+    public VidService vidService(AsdcClient asdcClient) {
+        return new VidServiceImpl(asdcClient);
+    }
+
+    @Bean
+    public AsdcClient asdcClient(AsdcClientConfiguration asdcClientConfig) throws IOException {
+        switch (asdcClientConfig.getAsdcClientType()) {
+            case IN_MEMORY:
+                final InputStream asdcCatalogFile = VidController.class.getClassLoader().getResourceAsStream("catalog.json");
+                final JSONTokener tokener = new JSONTokener(asdcCatalogFile);
+                final JSONObject catalog = new JSONObject(tokener);
+
+                return new InMemoryAsdcClient.Builder().catalog(catalog).build();
+            case REST:
+
+                final String protocol = asdcClientConfig.getAsdcClientProtocol();
+                final String host = asdcClientConfig.getAsdcClientHost();
+                final int port = asdcClientConfig.getAsdcClientPort();
+                final String auth = asdcClientConfig.getAsdcClientAuth();
+                Client cl = null;
+                if (protocol.equalsIgnoreCase("https")) {
+                    try {
+                        SSLContext ctx = SSLContext.getInstance("TLSv1.2");
+                        ctx.init(null, null, null);
+                        cl = ClientBuilder.newBuilder().sslContext(ctx).build();
+                    } catch (NoSuchAlgorithmException n) {
+                        throw new RuntimeException("SDC Client could not be instantiated due to unsupported protocol TLSv1.2", n);
+                    } catch (KeyManagementException k) {
+                        throw new RuntimeException("SDC Client could not be instantiated due to a key management exception", k);
+                    }
+                } else {
+                    cl = ClientBuilder.newBuilder().build();
+                }
+
+                try {
+                    final URI uri = new URI(protocol + "://" + host + ":" + port + "/");
+                    return new RestfulAsdcClient.Builder(cl, uri)
+                            .auth(auth)
+                            .build();
+                } catch (URISyntaxException e) {
+                    throw new RuntimeException("SDC Client could not be instantiated due to a syntax error in the URI", e);
+                }
+
+            case LOCAL:
+
+                final InputStream asdcServicesFile = VidController.class.getClassLoader().getResourceAsStream("sdcservices.json");
+
+                final JSONTokener jsonTokener = new JSONTokener(IOUtils.toString(asdcServicesFile));
+                final JSONObject sdcServicesCatalog = new JSONObject(jsonTokener);
+
+                return new LocalAsdcClient.Builder().catalog(sdcServicesCatalog).build();
+
+            default:
+                throw new RuntimeException(asdcClientConfig.getAsdcClientType() + " is invalid; must be one of " + Arrays.toString(AsdcClientType.values()));
+        }
+    }
+
+    @Bean
+    public ToscaParserImpl2 getToscaParser() {
+        return new ToscaParserImpl2();
+    }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java
deleted file mode 100755 (executable)
index 4606aa0..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-\r
- * ============LICENSE_START=======================================================\r
- * VID\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.openecomp.vid.model;\r
-\r
-/**\r
- * The Class ModelUtil.\r
- *\r
- */\r
-public class ModelUtil {\r
-       /**\r
-        * Gets the tags for the given element according to the configured namespace\r
-        * @param namespaces the namespace list from the configuration\r
-        * @param constantValue the constant portion of the tag name, i.e. resource.vf...\r
-        * @return the tags\r
-        */\r
-       public static String[] getTags ( String[] namespaces, String constantValue ) {\r
-               String[] tags;\r
-               if ( namespaces == null || namespaces.length == 0 ) {\r
-                       return null;\r
-               }\r
-               int le = namespaces.length;\r
-               tags = new String[le];\r
-               for ( int i = 0; i < le; i++ ) {\r
-                       tags[i] = namespaces[i] + constantValue;\r
-               }\r
-               return (tags);\r
-       }\r
-       /**\r
-        * Determine if a note template type matches a set of configurable tags\r
-        * @param type the node template type\r
-        * @param tags the model configurable namespaces\r
-        * @return true if type starts with a tag in the array, false otherwise\r
-        */\r
-       public static boolean isType ( String type, String[] tags ) {\r
-               if ( (tags != null) && (tags.length > 0) ) {\r
-                       for ( int i = 0; i < tags.length; i++ ) {\r
-                               if ( type.startsWith (tags[i]) ) {\r
-                                       return (true);\r
-                               }\r
-                       }\r
-               }\r
-               return (false);\r
-       }\r
-}\r
index 5ab5588..e763496 100755 (executable)
@@ -49,7 +49,7 @@ public class Network extends Node {
         *\r
         * @param modelCustomizationName the new model customization name\r
         */\r
-       private void setModelCustomizationName(String modelCustomizationName) {\r
+       public void setModelCustomizationName(String modelCustomizationName) {\r
                this.modelCustomizationName = modelCustomizationName;\r
        }\r
        \r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java
new file mode 100644 (file)
index 0000000..48e3a55
--- /dev/null
@@ -0,0 +1,56 @@
+/*-
+ * ============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
+ * 
+ *      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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.model;
+
+import org.openecomp.vid.asdc.beans.tosca.NodeTemplate;
+
+/**
+ * The Class Network.
+ */
+public class NewNetwork extends NewNode {
+
+       /** The model customization name. */
+       private String modelCustomizationName;
+
+       /**
+        * Instantiates a new network.
+        */
+       public NewNetwork() {
+               super();
+       }
+       /**
+        * Gets the model customization name.
+        *
+        * @return the model customization name
+        */
+       public String getModelCustomizationName() {
+               return modelCustomizationName;
+       }
+       /**
+        * Sets the model customization name.
+        *
+        * @param modelCustomizationName the new model customization name
+        */
+       public void setModelCustomizationName(String modelCustomizationName) {
+               this.modelCustomizationName = modelCustomizationName;
+       }
+       
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java
new file mode 100644 (file)
index 0000000..681131f
--- /dev/null
@@ -0,0 +1,209 @@
+package org.openecomp.vid.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.vid.asdc.beans.tosca.Input;
+
+
+public class NewNode {
+       
+       /** The Constant LOG. */
+       private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(Node.class);
+       
+       /** The Constant dateFormat. */
+       final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+       /** The uuid. */
+       private String uuid;
+       
+       /** The invariant uuid. */
+       private String invariantUuid;
+       
+       /** The description. */
+       private String description;
+       
+       /** The name. */
+       private String name;
+       
+       /** The version. */
+       private String version;
+       
+       /** The model customization uuid. */
+       private String customizationUuid;
+       
+       /** The inputs. */
+       private Map<String, Input> inputs;
+       
+       /** The get_input or other constructs from node template properties. */
+       private Map<String, CommandProperty> commands;
+       
+       /** The get_input or other constructs from node template properties. */
+       private Map<String, String> properties;
+       /**
+        * Instantiates a new node.
+        */
+       public NewNode() {
+               this.commands = new HashMap<String, CommandProperty>();
+               this.properties = new HashMap<String, String>();
+       }
+       
+       /**
+        * Gets the uuid.
+        *
+        * @return the uuid
+        */
+       public String getUuid() {
+               return uuid;
+       }
+
+       /**
+        * Gets the invariant uuid.
+        *
+        * @return the invariant uuid
+        */
+       public String getInvariantUuid() {
+               return invariantUuid;
+       }
+
+       /**
+        * Gets the description.
+        *
+        * @return the description
+        */
+       public String getDescription() {
+               return description;
+       }
+
+       /**
+        * Gets the name.
+        *
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * Gets the version.
+        *
+        * @return the version
+        */
+       public String getVersion() {
+               return version;
+       }
+       
+       /**
+        * Gets the customization uuid.
+        *
+        * @return the model customization uuid
+        */
+       public String getCustomizationUuid() {
+               return customizationUuid;
+       }
+       /**
+        * Gets the inputs.
+        *
+        * @return the inputs
+        */
+       public Map<String, Input> getInputs() {
+               return inputs;
+       }
+       /**
+        * Gets the commands.
+        *
+        * @return the commands
+        */
+       public Map<String, CommandProperty> getCommands() {
+               return commands;
+       }
+       /**
+        * Gets the properties.
+        *
+        * @return the properties
+        */
+       public Map<String, String> getProperties() {
+               return properties;
+       }
+       /**
+        * Sets the uuid.
+        *
+        * @param uuid the new uuid
+        */
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+
+       /**
+        * Sets the invariant uuid.
+        *
+        * @param invariantUuid the new invariant uuid
+        */
+       public void setInvariantUuid(String invariantUuid) {
+               this.invariantUuid = invariantUuid;
+       }
+
+       /**
+        * Sets the description.
+        *
+        * @param description the new description
+        */
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       /**
+        * Sets the name.
+        *
+        * @param name the new name
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       /**
+        * Sets the version.
+        *
+        * @param version the new version
+        */
+       public void setVersion(String version) {
+               this.version = version;
+       }
+       /**
+        * Sets the customization uuid.
+        *
+        * @param u the new customization uuid
+        */
+       public void setCustomizationUuid(String u) {
+               this.customizationUuid = u;
+       }
+
+       /**
+        * Sets the inputs.
+        *
+        * @param inputs the inputs
+        */
+       public void setInputs(Map<String, Input> inputs) {
+               this.inputs = inputs;
+       }
+       /**
+        * Sets the commands.
+        *
+        * @param m the commands
+        */
+       public void setCommands( Map<String, CommandProperty>m ) {
+               commands = m;
+       }
+       /**
+        * Sets the properties.
+        *
+        * @param p the properties
+        */
+       public void setProperties( Map<String, String>p) {
+               properties = p;
+       }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java
new file mode 100644 (file)
index 0000000..1dcf022
--- /dev/null
@@ -0,0 +1,252 @@
+/*-
+ * ============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
+ * 
+ *      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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.model;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.openecomp.vid.asdc.beans.tosca.Input;
+
+/**
+ * The Class Service.
+ */
+public class NewService {
+
+       /** The uuid. */
+       private String uuid;
+       
+       /** The invariant uuid. */
+       private String invariantUuid;
+       
+       /** The name. */
+       private String name;
+       
+       /** The version. */
+       private String version;
+       
+       /** The tosca model URL. */
+       private String toscaModelURL;
+       
+       /** The category. */
+       private String category;
+       
+       /** The description. */
+       private String description;
+       
+       /** The service ecomp naming flag */
+       private String serviceEcompNaming;
+       
+       /** The inputs. */
+       private Map<String, Input> inputs;
+       
+       /**
+        * Gets the uuid.
+        *
+        * @return the uuid
+        */
+       public String getUuid() {
+               return uuid;
+       }
+       
+       /**
+        * Gets the invariant uuid.
+        *
+        * @return the invariant uuid
+        */
+       public String getInvariantUuid() {
+               return invariantUuid;
+       }
+       
+       /**
+        * Gets the name.
+        *
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+       
+       /**
+        * Gets the version.
+        *
+        * @return the version
+        */
+       public String getVersion() {
+               return version;
+       }
+       
+       /**
+        * Gets the tosca model URL.
+        *
+        * @return the tosca model URL
+        */
+       public String getToscaModelURL() {
+               return toscaModelURL;
+       }
+       
+       /**
+        * Gets the category.
+        *
+        * @return the category
+        */
+       public String getCategory() {
+               return category;
+       }
+       
+       /**
+        * Gets the description.
+        *
+        * @return the description
+        */
+       public String getDescription() {
+               return description;
+       }
+       
+       /**
+        * Gets the inputs.
+        *
+        * @return the inputs
+        */
+       public Map<String, Input> getInputs() {
+               return inputs;
+       }
+       /**
+        * Get the serviceEcompNaming value
+        *
+        * @return serviceEcompNaming
+        */
+       public String getServiceEcompNaming() {
+               return serviceEcompNaming;
+       } 
+       /**
+        * Sets the uuid.
+        *
+        * @param uuid the new uuid
+        */
+       public void setUuid(String uuid) {
+               this.uuid = uuid;
+       }
+       
+       /**
+        * Sets the invariant uuid.
+        *
+        * @param invariantUuid the new invariant uuid
+        */
+       public void setInvariantUuid(String invariantUuid) {
+               this.invariantUuid = invariantUuid;
+       }
+       
+       /**
+        * Sets the name.
+        *
+        * @param name the new name
+        */
+       public void setName(String name) {
+               this.name = name;
+       }
+       
+       /**
+        * Sets the version.
+        *
+        * @param version the new version
+        */
+       public void setVersion(String version) {
+               this.version = version;
+       }
+       
+       /**
+        * Sets the tosca model URL.
+        *
+        * @param toscaModelURL the new tosca model URL
+        */
+       public void setToscaModelURL(String toscaModelURL) {
+               this.toscaModelURL = toscaModelURL;
+       }
+       
+       /**
+        * Sets the category.
+        *
+        * @param category the new category
+        */
+       public void setCategory(String category) {
+               this.category = category;
+       }
+       
+       /**
+        * Sets the description.
+        *
+        * @param description the new description
+        */
+       public void setDescription(String description) {
+               this.description = description;
+       }
+       
+       /**
+        * Sets the inputs.
+        *
+        * @param inputs the inputs
+        */
+       public void setInputs(Map<String, Input> inputs) {
+               this.inputs = inputs;
+       }
+       /**
+        * Sets the service ecomp naming.
+        *
+        * @param serviceEcompNaming the new service ecomp naming
+        */
+       public void setServiceEcompNaming(String serviceEcompNaming) {
+               this.serviceEcompNaming = serviceEcompNaming;
+       }
+       /* (non-Javadoc)
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               final UUID uuid = UUID.fromString(getUuid());
+               
+               return uuid.hashCode();
+       }
+       
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object o) {
+               if (o == this) return true;
+               if (!(o instanceof NewService)) return false;
+               
+               final NewService service = (NewService) o;
+               
+               return (service.getUuid().equals(getUuid()));
+       }
+       /*public static void extractVfModuleCustomizationUUID (Service s, String vnfCustomizationName, VfModule vfMod ) {
+               
+               //Look for vnfCustomizationName..vfModuleCustomizationName
+               String nameToFind = vnfCustomizationName + ".." + vfMod.getModelCustomizationName();
+               for (Entry<UUID, VfModule> vfModuleComponent : s.getVfModules().entrySet()) {
+                       VfModule xMod = vfModuleComponent.getValue();
+                       if ( (xMod.getModelCustomizationName() != null) && (xMod.getModelCustomizationName().equalsIgnoreCase(nameToFind)) ) {
+                               vfMod.setCustomizationUuid( xMod.getCustomizationUuid());
+                               return;
+                       }
+               }
+       }*/
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java
new file mode 100644 (file)
index 0000000..6fda979
--- /dev/null
@@ -0,0 +1,259 @@
+/*-
+ * ============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
+ * 
+ *      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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.vid.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.openecomp.vid.asdc.beans.tosca.Group;
+import org.openecomp.vid.asdc.beans.tosca.ToscaModel;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.vid.properties.VidProperties;
+/**
+ * The Class ServiceModel.
+ */
+public class NewServiceModel {
+
+       /** The Constant LOG. */
+       private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(NewServiceModel.class);
+       
+       /** The Constant dateFormat. */
+       final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+       /** The service. */
+       private Service service;
+       
+       /** The vnfs. */
+       private Map<String, VNF> vnfs;
+       
+       /** The networks. */
+       private Map<String, Network> networks;
+
+       /** 
+        * The vf modules. The VNF also has vfmodules but the vfmodules at the service level may have additional info
+        * that is not present in the VNF, like the vf module customization String 
+        */
+       private Map<String, VfModule> vfModules;
+       /**
+        * The volume groups. The VNF also has volume groups but the volume groups will be populated at the service level
+        * for newer models
+        */
+       private Map<String, VolumeGroup> volumeGroups;
+       /**
+        * Instantiates a new service model.
+        */
+       public NewServiceModel() {}
+       
+       /**
+        * Gets the service.
+        *
+        * @return the service
+        */
+       public Service getService() {
+               return service;
+       }
+
+       /**
+        * Gets the vnfs.
+        *
+        * @return the vnfs
+        */
+       public Map<String, VNF> getVnfs() {
+               return vnfs;
+       }
+
+       /**
+        * Gets the networks.
+        *
+        * @return the networks
+        */
+       public Map<String, Network> getNetworks() {
+               return networks;
+       }
+
+       /**
+        * Sets the service.
+        *
+        * @param service the new service
+        */
+       public void setService(Service service) {
+               this.service = service;
+       }
+
+       /**
+        * Sets the vnfs.
+        *
+        * @param vnfs the vnfs
+        */
+       public void setVnfs(Map<String, VNF> vnfs) {
+               this.vnfs = vnfs;
+       }
+
+       /**
+        * Sets the networks.
+        *
+        * @param networks the networks
+        */
+       public void setNetworks(Map<String, Network> networks) {
+               this.networks = networks;
+       }
+       /**
+        * Gets the vf modules.
+        *
+        * @return the vf modules
+        */
+       public Map<String, VfModule> getVfModules() {
+               return vfModules;
+       }
+       /**
+        * Gets the volume groups.
+        *
+        * @return the volume groups
+        */
+       public Map<String, VolumeGroup> getVolumeGroups() {
+               return volumeGroups;
+       }
+       /**
+        * Sets the vf modules.
+        *
+        * @param vfModules the vf modules
+        */
+       public void setVfModules(Map<String, VfModule> vfModules) {
+               this.vfModules = vfModules;
+       }
+       /**
+        * Sets the volume groups.
+        *
+        * @param volumeGroups the volume groups
+        */
+       public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+               this.volumeGroups = volumeGroups;
+       }
+       /**
+        * Extract service.
+        *
+        * @param serviceToscaModel the service tosca model
+        * @param asdcServiceMetadata the asdc service metadata
+        * @return the service
+        */
+       public static Service extractService(ToscaModel serviceToscaModel, org.openecomp.vid.asdc.beans.Service asdcServiceMetadata) {
+               
+               final Service service = new Service();
+               
+               service.setCategory(serviceToscaModel.getMetadata().getCategory());
+               service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID());
+               service.setName(serviceToscaModel.getMetadata().getName());
+               service.setUuid(serviceToscaModel.getMetadata().getUUID());
+               service.setDescription(serviceToscaModel.getMetadata().getDescription());
+               service.setServiceEcompNaming(serviceToscaModel.getMetadata().getServiceEcompNaming());
+               service.setInputs(serviceToscaModel.gettopology_template().getInputs());
+               //FIXME: SDC is not sending the Version with the Tosca Model for 1610 - they should send it in 1702
+               //THIS IS A TEMPORARY FIX, AT SOME POINT UNCOMMENT ME
+               //service.setVersion(serviceToscaModel.getMetadata().getVersion());
+               service.setVersion(asdcServiceMetadata.getVersion());
+
+               return service;
+       }
+       public static void extractGroups (ToscaModel serviceToscaModel,NewServiceModel serviceModel) {
+               // Get the groups. The groups may duplicate the groups that are in the VNF model and have
+               // additional data like the VF module customization String>
+               
+               final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();
+               final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();
+               
+               String asdcModelNamespace = VidProperties.getAsdcModelNamespace();
+       String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;
+       
+               for (Entry<String, Group> component : serviceToscaModel.gettopology_template().getGroups().entrySet()) {
+                       final Group group = component.getValue();
+                       final String type = group.getType();
+                       final String customizationName = component.getKey();
+                       
+                       if (type.startsWith(vfModuleTag)) {
+                               VfModule vfMod = VfModule.extractVfModule(customizationName, group);
+                               vfModules.put(customizationName, vfMod);
+                               if ( vfMod.isVolumeGroupAllowed() ) {
+                                       //volume groups have the same customization name as the vf module
+                                       volumeGroups.put(customizationName, VolumeGroup.extractVolumeGroup(customizationName,group));
+                               }
+                       }
+               }
+               // add this point vfModules and volume groups are disconnected from VNF
+               serviceModel.setVfModules (vfModules);
+               serviceModel.setVolumeGroups (volumeGroups);
+               
+       }
+       /**
+        * Populate the vf modules and volume groups that we may have under the service level under each VNF.
+        */
+//     public void associateGroups() {
+//             String methodName = "associateGroups()";
+//        LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
+//             // go through the vnfs, get the vnf normalized name and look for a vf module with a customization name that starts
+//             // with vnf + ".."
+//             String vnfCustomizationName = null;
+//             String normalizedVnfCustomizationName = null;
+//             String vfModuleCustomizationName = null;
+//             NewVNF tmpVnf = null;
+//
+//             if ( ( getVnfs() != null ) && (!(getVnfs().isEmpty())) ) {
+//                     for (Entry<String, NewVNF> vnfComponent : getVnfs().entrySet()) {
+//                             vnfCustomizationName = vnfComponent.getValue().getModelCustomizationName();
+//                             normalizedVnfCustomizationName = VNF.normalizeName(vnfCustomizationName);
+//
+//                             LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+//                                             " VNF customizationName=" + vnfCustomizationName + "normalized customization name=" + normalizedVnfCustomizationName);
+//
+//                             // now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName
+//
+//                             if (( getVfModules() != null ) && (!(getVfModules().isEmpty()))) {
+//                                     for (Entry<String, VfModule> vfModuleComponent : getVfModules().entrySet()) {
+//                                             vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName();
+//
+//                                             LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+//                                                             " VF Module customizationName=" + vfModuleCustomizationName );
+//                                             if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) {
+//
+//                                                     // this vf module belongs to the VNF
+//                                                     tmpVnf = vnfComponent.getValue();
+//                                                     (tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue());
+//
+//                                                     LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName +
+//                                                                     " Associated VF Module customizationName=" + vfModuleComponent.getKey() + " with VNF customization name=" + vnfCustomizationName);
+//
+//                                                     // now find if this vf module has volume groups, if so, find the volume group with the same customization name and put it under the VNF
+//                                                     if ( vfModuleComponent.getValue().isVolumeGroupAllowed() ) {
+//                                                             if (( getVolumeGroups() != null ) && (!(getVolumeGroups().isEmpty()))) {
+//                                                                     if (getVolumeGroups().containsKey((vfModuleCustomizationName))) {
+//                                                                             (vnfComponent.getValue().getVolumeGroups()).put(vfModuleCustomizationName, (getVolumeGroups()).get(vfModuleCustomizationName));
+//                                                                     }
+//                                                             }
+//                                                     }
+//                                             }
+//                                     }
+//                             }
+//                     }
+//             }
+               
+//     }
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java b/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java
new file mode 100644 (file)
index 0000000..e84f963
--- /dev/null
@@ -0,0 +1,123 @@
+package org.openecomp.vid.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.vid.asdc.beans.tosca.NodeTemplate;
+
+public class NewVNF extends NewNode {
+       
+       /** The Constant LOG. */
+       private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VNF.class);
+       
+       /** The Constant dateFormat. */
+       final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+       /** The pattern used to normalize VNF names */
+       final static Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+");
+       
+       /** The model customization name. */
+       private String modelCustomizationName;
+       
+       /** The vf modules. */
+       private Map<String, VfModule> vfModules = new HashMap<String, VfModule>();
+       
+       /** The volume groups. */
+       private Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup>();
+       
+       /**
+        * Instantiates a newvnf.
+        */
+       public NewVNF() {
+               super();
+       }
+
+       /**
+        * Gets the model customization name.
+        *
+        * @return the model customization name
+        */
+       public String getModelCustomizationName() {
+               return modelCustomizationName;
+       }
+
+       /**
+        * Gets the vf modules.
+        *
+        * @return the vf modules
+        */
+       public Map<String, VfModule> getVfModules() {
+               return vfModules;
+       }
+
+       /**
+        * Sets the vf modules.
+        *
+        * @param vfModules the vf modules
+        */
+       public void setVfModules(Map<String, VfModule> vfModules) {
+               this.vfModules = vfModules;
+       }
+
+       /**
+        * Gets the volume groups.
+        *
+        * @return the volume groups
+        */
+       public Map<String, VolumeGroup> getVolumeGroups() {
+               return volumeGroups;
+       }
+
+       /**
+        * Sets the volume groups.
+        *
+        * @param volumeGroups the volume groups
+        */
+       public void setVolumeGroups(Map<String, VolumeGroup> volumeGroups) {
+               this.volumeGroups = volumeGroups;
+       }
+
+
+       /**
+        * Sets the model customization name.
+        *
+        * @param modelCustomizationName the new model customization name
+        */
+       public void setModelCustomizationName(String modelCustomizationName) {
+               this.modelCustomizationName = modelCustomizationName;
+       }
+       /**
+        * Normalize the VNF name
+        * @param originalName
+        * @return the normalized name
+        */
+       public static String normalizeName (String originalName) {
+
+               String normalizedName = originalName.toLowerCase();
+               normalizedName = COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" ");
+               String[] splitArr = null;
+               
+               try {
+                       splitArr = normalizedName.split(" ");
+               }
+               catch (Exception ex ) {
+                       return (normalizedName);
+               }
+               StringBuffer sb = new StringBuffer();
+               if ( splitArr != null ) {
+                       for (String splitElement : splitArr) {
+                               sb.append(splitElement);
+                       }
+                       return (sb.toString());
+               }
+               else {
+                       return (normalizedName);
+               }
+               
+       }
+
+}
index 98e6531..8742931 100755 (executable)
@@ -30,11 +30,11 @@ import java.util.Map.Entry;
 import org.openecomp.vid.asdc.beans.tosca.Group;\r
 import org.openecomp.vid.asdc.beans.tosca.ToscaModel;\r
 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
-import org.openecomp.vid.controller.VidController;\r
 import org.openecomp.vid.properties.VidProperties;\r
 /**\r
  * The Class ServiceModel.\r
  */\r
+@SuppressWarnings("ALL")\r
 public class ServiceModel {\r
 \r
        /** The Constant LOG. */\r
@@ -176,21 +176,22 @@ public class ServiceModel {
 \r
                return service;\r
        }\r
-       public void extractGroups (ToscaModel serviceToscaModel) {\r
+       public static void extractGroups (ToscaModel serviceToscaModel,ServiceModel serviceModel) {\r
                // Get the groups. The groups may duplicate the groups that are in the VNF model and have\r
                // additional data like the VF module customization String>\r
                \r
                final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();\r
                final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();\r
-       String asdcModelNamespaces[] = VidProperties.getAsdcModelNamespace();\r
-        String[] vfModuleTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VF_MODULE);\r
-    \r
+               \r
+               String asdcModelNamespace = VidProperties.getAsdcModelNamespace();\r
+       String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE;\r
+       \r
                for (Entry<String, Group> component : serviceToscaModel.gettopology_template().getGroups().entrySet()) {\r
                        final Group group = component.getValue();\r
                        final String type = group.getType();\r
                        final String customizationName = component.getKey();\r
                        \r
-                       if ( ModelUtil.isType (type, vfModuleTags) ) {\r
+                       if (type.startsWith(vfModuleTag)) {\r
                                VfModule vfMod = VfModule.extractVfModule(customizationName, group);\r
                                vfModules.put(customizationName, vfMod);\r
                                if ( vfMod.isVolumeGroupAllowed() ) {\r
@@ -200,8 +201,8 @@ public class ServiceModel {
                        }\r
                }\r
                // add this point vfModules and volume groups are disconnected from VNF\r
-               this.setVfModules (vfModules);\r
-               this.setVolumeGroups (volumeGroups);\r
+               serviceModel.setVfModules (vfModules);\r
+               serviceModel.setVolumeGroups (volumeGroups);\r
                \r
        }\r
        /**\r
index be37c94..62e101e 100755 (executable)
@@ -130,7 +130,7 @@ public class VNF extends Node {
         *\r
         * @param modelCustomizationName the new model customization name\r
         */\r
-       private void setModelCustomizationName(String modelCustomizationName) {\r
+       public void setModelCustomizationName(String modelCustomizationName) {\r
                this.modelCustomizationName = modelCustomizationName;\r
        }\r
        /**\r
index 4a031a6..3f6f1da 100755 (executable)
@@ -207,7 +207,7 @@ public class VfModule {
         *\r
         * @param volumeGroupAllowed the new volume group allowed\r
         */\r
-       private void setVolumeGroupAllowed(boolean volumeGroupAllowed) {\r
+       public void setVolumeGroupAllowed(boolean volumeGroupAllowed) {\r
                this.volumeGroupAllowed = volumeGroupAllowed;\r
        }\r
        /**\r
@@ -223,7 +223,7 @@ public class VfModule {
         *\r
         * @param modelCustomizationName the new model customization name\r
         */\r
-       private void setModelCustomizationName(String modelCustomizationName) {\r
+       public void setModelCustomizationName(String modelCustomizationName) {\r
                this.modelCustomizationName = modelCustomizationName;\r
        }\r
        /**\r
index ea8e151..d09ef9a 100755 (executable)
@@ -170,7 +170,7 @@ public class VolumeGroup {
         *\r
         * @param u the new customization name\r
         */\r
-       private void setModelCustomizationName(String u) {\r
+       public void setModelCustomizationName(String u) {\r
                this.modelCustomizationName = u;\r
                \r
        }\r
index b0dc906..1a6dbcc 100755 (executable)
@@ -70,7 +70,7 @@ public interface MsoRestInterfaceIfc {
         */\r
        public <T> void Post(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) throws Exception;\r
        \r
-       /**\r
+       /***\r
         * Log request.\r
         *\r
         * @param r the r\r
index 6d5f952..232023b 100755 (executable)
@@ -24,31 +24,36 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;\r
 import org.springframework.context.annotation.Configuration;\r
 import org.springframework.context.annotation.PropertySource;\r
+import org.springframework.context.annotation.PropertySources;\r
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;\r
 \r
 /**\r
  * The Class AsdcClientConfiguration.\r
  */\r
 @Configuration\r
-@PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties")\r
+\r
+@PropertySources({\r
+               @PropertySource(value="asdc.properties",  ignoreResourceNotFound = true),\r
+               @PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties", ignoreResourceNotFound = true)\r
+})\r
 public class AsdcClientConfiguration {\r
-       \r
-    @Bean \r
-    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { \r
-        return new PropertySourcesPlaceholderConfigurer(); \r
+\r
+    @Bean\r
+    public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {\r
+        return new PropertySourcesPlaceholderConfigurer();\r
     }\r
 \r
        @Value("${asdc.client.type}")\r
        private AsdcClientType asdcClientType;\r
-       \r
+\r
        /** The asdc client host. */\r
        @Value("${asdc.client.rest.host}")\r
        private String asdcClientHost;\r
-       \r
+\r
        /** The asdc client port. */\r
        @Value("${asdc.client.rest.port}")\r
        private int asdcClientPort;\r
-       \r
+\r
        /** The asdc client auth. */\r
        @Value("${asdc.client.rest.auth}")\r
        public String asdcClientAuth;\r
@@ -56,7 +61,7 @@ public class AsdcClientConfiguration {
        /** The asdc client protocol. */\r
        @Value("${asdc.client.rest.protocol}")\r
        public String asdcClientProtocol;\r
-       \r
+\r
        /**\r
         * Gets the asdc client type.\r
         *\r
@@ -101,16 +106,19 @@ public class AsdcClientConfiguration {
        public String getAsdcClientProtocol() {\r
                return asdcClientProtocol;\r
        }\r
-       \r
+\r
        /**\r
         * The Enum AsdcClientType.\r
         */\r
        public enum AsdcClientType {\r
-               \r
+\r
                /** The in memory. */\r
                IN_MEMORY,\r
-               \r
+\r
                /** The rest. */\r
-               REST\r
+               REST,\r
+\r
+               /** The local. */\r
+               LOCAL\r
        }\r
 }\r
index 38062df..141b9b2 100755 (executable)
@@ -53,27 +53,21 @@ public class VidProperties extends SystemProperties {
         * \r
         * @return the property value or a default value\r
         */\r
-       public static String[] getAsdcModelNamespace() {\r
+       public static String getAsdcModelNamespace() {\r
                String methodName = "getAsdcModelNamespace ";\r
-               String[] asdcModelNamespaces = null;\r
-               String value = null;\r
+               String asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;\r
            try {\r
-               value = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);\r
-               if ( value == null || value.isEmpty()) {\r
-                       asdcModelNamespaces = new String[1];\r
-                       asdcModelNamespaces[0] = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;\r
+               asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);\r
+               if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {\r
+                       asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;\r
                    }\r
-               else {\r
-                       asdcModelNamespaces = value.split(",");\r
-               }\r
            }\r
            catch ( Exception e ) {\r
                LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "\r
                                + ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);\r
-               asdcModelNamespaces = new String[1];\r
-               asdcModelNamespaces[0] = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;\r
+               asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;\r
            }\r
-           return (asdcModelNamespaces);\r
+           return (asdcModelNamespace);\r
        }\r
        /**\r
         * Gets the specified property value. If the property is not defined, returns a default value.\r
@@ -96,5 +90,4 @@ public class VidProperties extends SystemProperties {
            }\r
            return (propValue);\r
        }\r
-       \r
 }\r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java
new file mode 100644 (file)
index 0000000..4fb0ff1
--- /dev/null
@@ -0,0 +1,17 @@
+package org.openecomp.vid.services;
+
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.model.ServiceModel;
+
+import java.util.Collection;
+import java.util.Map;
+
+public interface VidService {
+
+       Collection<Service> getServices(Map<String, String[]> requestParams)
+                       throws AsdcCatalogException;
+
+       ServiceModel getService(String uuid) throws AsdcCatalogException;
+
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java
new file mode 100644 (file)
index 0000000..9844842
--- /dev/null
@@ -0,0 +1,79 @@
+package org.openecomp.vid.services;
+
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.AsdcClient;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.asdc.parser.ToscaParser;
+import org.openecomp.vid.asdc.parser.ToscaParserImpl;
+import org.openecomp.vid.asdc.parser.ToscaParserImpl2;
+import org.openecomp.vid.model.ServiceModel;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.nio.file.Path;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * The Class VidController.
+ */
+
+public class VidServiceImpl implements VidService {
+    /**
+     * The Constant LOG.
+     */
+    private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidServiceImpl.class);
+    /**
+     * The Constant dateFormat.
+     */
+    private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+    protected final AsdcClient asdcClient;
+    @Autowired
+    private ToscaParserImpl2 toscaParser;
+
+    public VidServiceImpl(AsdcClient asdcClient) {
+        this.asdcClient = asdcClient;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.openecomp.vid.controller.VidService#getServices(java.util.Map)
+     */
+    @Override
+    public Collection<Service> getServices(Map<String, String[]> requestParams)
+            throws AsdcCatalogException {
+        return asdcClient.getServices(requestParams);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.openecomp.vid.controller.VidService#getService(java.lang.String)
+     */
+    @Override
+    public ServiceModel getService(String uuid) throws AsdcCatalogException {
+        final Path serviceCsar = asdcClient.getServiceToscaModel(UUID.fromString(uuid));
+        ToscaParser tosca = new ToscaParserImpl();
+        serviceCsar.toFile().getAbsolutePath();
+        ServiceModel serviceModel = null;
+        try {
+            final Service asdcServiceMetadata = asdcClient.getService(UUID.fromString(uuid));
+            try {
+                serviceModel = toscaParser.makeServiceModel(serviceCsar, asdcServiceMetadata);
+            }
+            catch (SdcToscaParserException e){
+                serviceModel = tosca.makeServiceModel(uuid, serviceCsar, asdcServiceMetadata);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return serviceModel;
+    }
+
+
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/resources/catalog.json b/vid-app-common/src/main/resources/catalog.json
new file mode 100644 (file)
index 0000000..20c7d57
--- /dev/null
@@ -0,0 +1,174 @@
+{
+       "services": {
+               "0346aa9f-57b7-458a-9681-daf5b19d52b0": {
+                       "uuid": "0346aa9f-57b7-458a-9681-daf5b19d52b0",
+                       "name": "The Worst Service",
+                       "version": "1.0",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "category": "Bad Services",
+                       "lifecycleState": "NOT_CERTIFIED_CHECKOUT",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "distributionStatus": "DISTRIBUTION_REJECTED",
+                       "artifacts": [],
+                       "resources": []
+               },
+               "1346aa9f-57b7-458a-9681-daf5b19d52b1": {
+                       "uuid": "1346aa9f-57b7-458a-9681-daf5b19d52b1",
+                       "name": "The Worst Service",
+                       "version": "1.1",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "category": "Bad Services",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "distributionStatus": "DISTRIBUTED",
+                       "artifacts": [],
+                       "resources": []
+               },
+               "3346aa9f-57b7-458a-9681-daf5b19d52b3": {
+                       "uuid": "3346aa9f-57b7-458a-9681-daf5b19d52b3",
+                       "name": "Bland Service",
+                       "version": "1.9",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "category": "Neutral Services",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "distributionStatus": "DISTRIBUTION_NOT_APPROVED",
+                       "artifacts": [],
+                       "resources": []
+               },
+               "2346aa9f-57b7-458a-9681-daf5b19d52b2": {
+                       "uuid": "2346aa9f-57b7-458a-9681-daf5b19d52b2",
+                       "name": "The Best Service",
+                       "version": "1.3",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "category": "Good Services",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "distributionStatus": "DISTRIBUTION_APPROVED",
+                       "artifacts": [
+                                       {
+                                               "artifactUUID": "0cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       },
+                                       {
+                                               "artifactUUID": "1cf78c81-1246-45e7-a190-eaa309ee5681",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       },
+                                       {
+                                               "artifactUUID": "2cf78c81-1246-45e7-a190-eaa309ee5682",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       }
+                       ],
+                       "resources": []
+               }
+       },
+       "resources": {
+               "2f92b5b0-10ff-4cf4-9531-88546fe88a42": {
+                       "uuid": "2f92b5b0-10ff-4cf4-9531-88546fe88a42",
+                       "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+                       "name": "The Worst Resource",
+                       "version": "0.1",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "toscaModel": "http://www.openecomp.org/",
+                       "toscaResourceName": "The Worst Resource (TOSCA)",
+                       "category": "Bad Resources",
+                       "subCategory": "Really Bad Resources",
+                       "resourceType": "VF",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "artifacts": [
+                                       {
+                                               "artifactUUID": "0cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       },
+                                       {
+                                               "artifactUUID": "1cf78c81-1246-45e7-a190-eaa309ee5681",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       },
+                                       {
+                                               "artifactUUID": "2cf78c81-1246-45e7-a190-eaa309ee5682",
+                                               "generatedFromUUID": "3cf78c81-1246-45e7-a190-eaa309ee5680",
+                                               "artifactName": "The Worst Artifact",
+                                               "artifactType": "HEAT",
+                                               "artifactDescription": "This is the worst artifact",
+                                               "artifactURL": "http://www.openecomp.org/",
+                                               "artifactTimeout": "60",
+                                               "artifactChecksum": "A worthy checksum",
+                                               "artifactVersion": "0.1"
+                                       }
+                       ]
+               },
+               "0f92b5b0-10ff-4cf4-9531-88546fe88a40": {
+                       "uuid": "0f92b5b0-10ff-4cf4-9531-88546fe88a40",
+                       "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+                       "name": "The Worst Resource",
+                       "version": "0.1",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "toscaModel": "http://www.openecomp.org/",
+                       "toscaResourceName": "The Worst Resource (TOSCA)",
+                       "category": "Bad Resources",
+                       "subCategory": "Really Bad Resources",
+                       "resourceType": "VF",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "artifacts": []
+               },
+               "1f92b5b0-10ff-4cf4-9531-88546fe88a41": {
+                       "uuid": "1f92b5b0-10ff-4cf4-9531-88546fe88a41",
+                       "invariantUUID": "df92b5b0-10ff-4cf4-9531-88546fe88a4d",
+                       "name": "The Worst Resource",
+                       "version": "0.1",
+                       "toscaModelURL": "sampleTosca.csar",
+                       "toscaModel": "http://www.openecomp.org/",
+                       "toscaResourceName": "The Worst Resource (TOSCA)",
+                       "category": "Bad Resources",
+                       "subCategory": "Really Bad Resources",
+                       "resourceType": "VF",
+                       "lifecycleState": "CERTIFIED",
+                       "lastUpdaterUserId": "example@example.org",
+                       "lastUpdaterFullName": "Example User",
+                       "artifacts": []
+               }
+       }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/resources/sdcservices.json b/vid-app-common/src/main/resources/sdcservices.json
new file mode 100644 (file)
index 0000000..9ef37c3
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "services": [
+    {
+      "uuid": "f430728a-4530-42be-a577-1206b9484cef",
+      "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
+      "name": "1707vidnf",
+      "version": "1.0",
+      "toscaModelURL": "./service-vf-csar.zip",
+      "category": "Mobility",
+      "lifecycleState": "CERTIFIED",
+      "lastUpdaterUserId": "sa997j",
+      "distributionStatus": "DISTRIBUTED"
+    },
+    {
+      "uuid": "f430728a-4530-42be-a577-1206b9484cef",
+      "invariantUUID": "f430728a-4530-42be-a577-1206b9484cef",
+      "name": "4-27_vMME_Service",
+      "version": "1.0",
+      "toscaModelURL": "./service-vf-csar.zip",
+      "category": "Mobility",
+      "lifecycleState": "CERTIFIED",
+      "lastUpdaterUserId": "rg276b",
+      "lastUpdaterFullName": null,
+      "distributionStatus": "DISTRIBUTED",
+      "artifacts": null,
+      "resources": null
+    }
+  ]
+}
\ No newline at end of file
diff --git a/vid-app-common/src/main/resources/service-vf-csar.zip b/vid-app-common/src/main/resources/service-vf-csar.zip
new file mode 100644 (file)
index 0000000..f66d084
Binary files /dev/null and b/vid-app-common/src/main/resources/service-vf-csar.zip differ
diff --git a/vid-app-common/src/main/resources/service-vl-csar.zip b/vid-app-common/src/main/resources/service-vl-csar.zip
new file mode 100644 (file)
index 0000000..121192a
Binary files /dev/null and b/vid-app-common/src/main/resources/service-vl-csar.zip differ
index cc5b680..e7cbc48 100755 (executable)
@@ -33,15 +33,22 @@ appDS2.constant("COMPONENT", (function() {
     GET_SUB_DETAILS : "getSubDetails",
     GLOBAL_CUSTOMER_ID : "globalCustomerId",
     MACRO : "Macro",
+    MODEL_NAME_IISBC : "Intercarrier Interconnect Session Border Controller",
+       MODEL_NAME_VISBCOAMNETWORK : "vIsbcOamNetwork",
+       MODEL_NAME_VISBCRTPEXPANSIONMODULE : "vIsbcRtpExpansionModule",
+       MODEL_NAME_VISBC : "vIsbc",
+       MODEL_NAME_WANBONDING : "WanBonding",
        MODEL_VERSION_1 : "1",
        MSO_CREATE_REQ : "createInstance",
        MSO_DELETE_REQ : "deleteInstance",
     NAME : "name",
        NETWORK : "network",
        NETWORKS : "networks",
-
+       PRODUCT_NAME_TRINITY : "Trinity",
        QUERY_SERVICE_INSTANCE : "queryServiceInstance",
        REFRESH_PROPERTIES : "refreshProperties",
+       SDN_L3_BONDING : "SDN-L3-BONDING",
+       SDN_ETHERNET_INTERNET : "SDN-ETHERNET-INTERNET",
        SERVICE : "service",
        SERVICE_TYPE : "serviceType",
        SHOW_COMPONENT_DETAILS : "showComponentDetails",
@@ -50,7 +57,7 @@ appDS2.constant("COMPONENT", (function() {
        TENANT_ID : "tenantID",
        TENANT_NAME : "tenantName",
        TRUE : "true",
-       
+       UCPE_VMS : "uCPE-VMS",
        VF_MODULE : "vfModule",
        VNF : "vnf",
        VNF_CODE : "vnfCode",
index 23ff56b..65e15f2 100755 (executable)
@@ -127,6 +127,7 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) {
     };\r
 \r
     var KEY = {\r
+       LCP_REGION_TEXT : "AAIAIC25"\r
     };\r
    \r
     /*\r
index 496c06f..eac79ed 100755 (executable)
@@ -41,7 +41,7 @@ appDS2.controller("aaiSubscriberController", [ "COMPONENT", "FIELD", "PARAMETER"
        $scope.defaultBaseUrl = "";\r
        $scope.responseTimeoutMsec = 60000;\r
 \r
-       $scope.serviceTypes=[ FIELD.PROMPT.SELECT_SERVICE];\r
+       $scope.serviceTypes=[ FIELD.PROMPT.SELECT_SERVICE, COMPONENT.UCPE_VMS, COMPONENT.SDN_L3_BONDING, COMPONENT.SDN_ETHERNET_INTERNET];\r
        $scope.defaultSubscriberName=[ FIELD.PROMPT.SELECT_SUB ];\r
 \r
        var callbackFunction = function(response) {\r
index 2cf689e..06cbf05 100755 (executable)
@@ -238,7 +238,144 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
                        });\r
                }\r
        \r
+               /*\r
+                * Test data objects:\r
+                */\r
        \r
+               var subscriberInfo = {\r
+                       globalSubscriberId : COMPONENT.GLOBAL_SUBSCRIBER_ID_1,\r
+                       subscriberName : COMPONENT.SUBSCRIBER_NAME_GED12\r
+               };\r
+       \r
+               var createServiceRequestDetails = {\r
+                       modelInfo : {\r
+                               modelType : COMPONENT.SERVICE,\r
+                               modelId : COMPONENT.MODEL_ID_1,\r
+                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
+                               modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
+                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                       },\r
+                       subscriberInfo : subscriberInfo,\r
+                       requestParameters : {\r
+                               vpnId : COMPONENT.VPN_ID_1,\r
+                               productName : COMPONENT.PRODUCT_NAME_TRINITY,\r
+                               customerId : COMPONENT.CUSTOMER_ID_1\r
+                       }\r
+               };\r
+       \r
+               var deleteServiceRequestDetails = {\r
+                       modelInfo : {\r
+                               modelType : COMPONENT.SERVICE,\r
+                               modelId : COMPONENT.MODEL_ID_1,\r
+                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,\r
+                               modelName : COMPONENT.MODEL_NAME_WANBONDING,\r
+                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                       }\r
+               };\r
+       \r
+               var createNetworkRequestDetails = {\r
+                       modelInfo : {\r
+                               modelType : COMPONENT.NETWORK,\r
+                               modelId : COMPONENT.MODEL_ID_2,\r
+                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
+                               modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
+                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                       },\r
+                       relatedModelList : [\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_1,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.SERVICE,\r
+                                                               modelId : COMPONENT.MODEL_ID_3,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
+                                                               modelName : COMPONENT.MODEL_NAME_IISBC,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       },\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_2,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.VNF,\r
+                                                               modelId : COMPONENT.MODEL_ID_4,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
+                                                               modelName : COMPONENT.MODEL_NAME_VISBC,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       },\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_3,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.VF_MODULE,\r
+                                                               modelId : COMPONENT.MODEL_ID_5,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
+                                                               modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       } ],\r
+                       subscriberInfo : subscriberInfo,\r
+                       requestParameters : {\r
+                               /*\r
+                                * FYI: quotes around field names are needed due to embedded "-"\r
+                                * characters\r
+                                */\r
+                               "cidr-mask" : COMPONENT.CIDR_MASK_1,\r
+                               "gateway-address" : COMPONENT.GATEWAY_ADDRESS_1,\r
+                               "dhcp-enabled" : COMPONENT.TRUE\r
+                       }\r
+               };\r
+       \r
+               var deleteNetworkRequestDetails = {\r
+                       modelInfo : {\r
+                               modelType : COMPONENT.NETWORK,\r
+                               modelId : COMPONENT.MODEL_ID_2,\r
+                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,\r
+                               modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,\r
+                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                       },\r
+                       relatedModelList : [\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_1,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.SERVICE,\r
+                                                               modelId : COMPONENT.MODEL_ID_3,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,\r
+                                                               modelName : COMPONENT.MODEL_NAME_IISBC,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       },\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_2,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.VNF,\r
+                                                               modelId : COMPONENT.MODEL_ID_4,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,\r
+                                                               modelName : COMPONENT.MODEL_NAME_VISBC,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       },\r
+                                       {\r
+                                               relatedModel : {\r
+                                                       instanceId : COMPONENT.INSTANCE_ID_3,\r
+                                                       modelInfo : {\r
+                                                               modelType : COMPONENT.VF_MODULE,\r
+                                                               modelId : COMPONENT.MODEL_ID_5,\r
+                                                               modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,\r
+                                                               modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,\r
+                                                               modelVersion : COMPONENT.MODEL_VERSION_1\r
+                                                       }\r
+                                               }\r
+                                       } ]\r
+               };\r
                $scope.getSubscriberDet = function(selectedCustomer){\r
                        window.location.href = COMPONENT.SUBDETAILS_SELECTEDSUBSCRIBER + selectedCustomer;\r
                };\r
diff --git a/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java b/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java
new file mode 100644 (file)
index 0000000..05ca8c3
--- /dev/null
@@ -0,0 +1,128 @@
+package org.opencomp.vid.controller;
+
+import net.javacrumbs.jsonunit.JsonAssert;
+import org.apache.commons.io.IOUtils;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.AsdcClient;
+import org.openecomp.vid.asdc.parser.ToscaParserImpl2;
+import org.openecomp.vid.controller.WebConfig;
+import org.openecomp.vid.model.*;
+import org.openecomp.vid.properties.AsdcClientConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.opencomp.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {WebConfig.class, AsdcClientConfiguration.class})
+public class VidControllerTest {
+
+    @Autowired
+    private AsdcClient asdcClient;
+
+    private String uuid = "f430728a-4530-42be-a577-1206b9484cef";
+    //TODO: add as a test case.
+    private String vfFilePath = "vf-csar.JSON";
+    private String vlFilePath = "vl-csar.JSON";
+
+    private ToscaParserImpl2 p2 = new ToscaParserImpl2();
+    private ObjectMapper om = new ObjectMapper();
+    final InputStream jsonFile = VidControllerTest.class.getClassLoader().getResourceAsStream(vfFilePath);
+
+
+    @Test
+    public void assertEqualsBetweenServices() throws Exception {
+        Service expectedService = getExpectedServiceModel().getService();
+        Service actualService = p2.makeServiceModel(getCsarPath(), getServiceByUuid()).getService();
+        JsonAssert.assertJsonEquals(expectedService, actualService);
+    }
+
+    @Test
+    public void assertEqualBetweenObjects() throws Exception {
+        ServiceModel actualServiceModel = p2.makeServiceModel(getCsarPath(), getServiceByUuid());
+        JsonAssert.assertJsonEquals(getExpectedServiceModel(), actualServiceModel);
+    }
+
+    @Test
+    public void assertEqualsBetweenNetworkNodes() throws Exception {
+        Map<String, Network> expectedNetworksMap = getExpectedServiceModel().getNetworks();
+        Map<String, Network> actualNetworksMap = p2.makeServiceModel(getCsarPath(), getServiceByUuid()).getNetworks();
+        for (Map.Entry<String, Network> entry : expectedNetworksMap.entrySet()) {
+            Network expectedNetwork = entry.getValue();
+            Network actualNetwork = actualNetworksMap.get(entry.getKey());
+            Assert.assertEquals(expectedNetwork.getModelCustomizationName(), actualNetwork.getModelCustomizationName());
+            verifyBaseNodeProperties(expectedNetwork, actualNetwork);
+            compareProperties(expectedNetwork.getProperties(), actualNetwork.getProperties());
+        }
+    }
+
+    //Because we are not supporting the old flow, the JSON are different by definition.
+    @Test
+    public void assertEqualsBetweenVnfsOfTosca() throws Exception {
+        Map<String, VNF> expectedVnfsMap = getExpectedServiceModel().getVnfs();
+        Map<String, VNF> actualVnfsMap = p2.makeServiceModel(getCsarPath(), getServiceByUuid()).getVnfs();
+        for (Map.Entry<String, VNF> entry : expectedVnfsMap.entrySet()) {
+            VNF expectedVnf = entry.getValue();
+            VNF actualVnf = actualVnfsMap.get(entry.getKey());
+            verifyBaseNodeProperties(expectedVnf, actualVnf);
+            Assert.assertEquals(expectedVnf.getModelCustomizationName(), actualVnf.getModelCustomizationName());
+            compareProperties(expectedVnf.getProperties(), actualVnf.getProperties());
+            assertJsonStringEqualsIgnoreNulls(om.writeValueAsString(expectedVnf), om.writeValueAsString(actualVnf));
+        }
+    }
+
+    @Test
+    public void assertEqualsBetweenVolumeGroups() throws Exception {
+        Map<String, VolumeGroup> actualVolumeGroups = p2.makeServiceModel(getCsarPath(), getServiceByUuid()).getVolumeGroups();
+        Map<String, VolumeGroup> expectedVolumeGroups = getExpectedServiceModel().getVolumeGroups();
+        JsonAssert.assertJsonEquals(actualVolumeGroups, expectedVolumeGroups);
+    }
+
+    @Test
+    public void assertEqualsBetweenVfModules() throws Exception {
+        Map<String, VfModule> actualVfModules = p2.makeServiceModel(getCsarPath(), getServiceByUuid()).getVfModules();
+        Map<String, VfModule> expectedVfModules = getExpectedServiceModel().getVfModules();
+        JsonAssert.assertJsonEquals(actualVfModules, expectedVfModules);
+    }
+
+    private void verifyBaseNodeProperties(Node expectedNode, Node actualNode) {
+        Assert.assertEquals(expectedNode.getName(), actualNode.getName());
+        Assert.assertEquals(expectedNode.getCustomizationUuid(), actualNode.getCustomizationUuid());
+        Assert.assertEquals(expectedNode.getDescription(), actualNode.getDescription());
+        Assert.assertEquals(expectedNode.getInvariantUuid(), actualNode.getInvariantUuid());
+        Assert.assertEquals(expectedNode.getUuid(), actualNode.getUuid());
+        Assert.assertEquals(expectedNode.getVersion(), actualNode.getVersion());
+    }
+
+    private void compareProperties(Map<String, String> expectedProperties, Map<String, String> actualProperties) {
+        for (Map.Entry<String, String> property : expectedProperties.entrySet()) {
+            String expectedValue = property.getValue();
+            String key = property.getKey();
+            String actualValue = actualProperties.get(key);
+            Assert.assertEquals(expectedValue, actualValue);
+        }
+    }
+
+    private NewServiceModel getExpectedServiceModel() throws IOException {
+        String expectedJsonAsString  = IOUtils.toString(jsonFile).toString();
+        return om.readValue(expectedJsonAsString,NewServiceModel.class);
+    }
+
+    private Path getCsarPath() throws AsdcCatalogException {
+        return asdcClient.getServiceToscaModel(UUID.fromString(uuid));
+    }
+
+    private org.openecomp.vid.asdc.beans.Service getServiceByUuid() throws AsdcCatalogException {
+        return asdcClient.getService(UUID.fromString(uuid));
+    }
+}
\ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/opencomp/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/opencomp/vid/testUtils/TestUtils.java
new file mode 100644 (file)
index 0000000..29115e0
--- /dev/null
@@ -0,0 +1,65 @@
+package org.opencomp.vid.testUtils;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Assert;
+
+import java.util.Iterator;
+
+import static fj.parser.Parser.fail;
+
+/**
+ * Created by Oren on 6/7/17.
+ */
+public class TestUtils {
+
+    /**
+     * The method compares between two jsons. the function assert that the actual object does not reduce or change the functionallity/parsing of the expected json.
+     * This means that if the expected JSON has a key which is null or the JSON doesn't have a key which contained in the expected JSON the assert will succeed and the will pass.
+     * For example : For JSON expected = {a:null} and actual {a:3} the test will pass
+     * Other example : For JSON expected = {a:3} and actual {a:null} the test will fail
+     *
+     * @param expected JSON
+     * @param actual JSON
+     */
+    public static void assertJsonStringEqualsIgnoreNulls(String expected, String actual) {
+        if (expected == null || expected == JSONObject.NULL) {return;}
+
+        JSONObject expectedJSON = new JSONObject(expected);
+        JSONObject actualJSON = new JSONObject(actual);
+        Iterator<?> keys = expectedJSON.keys();
+
+        while( keys.hasNext() ) {
+            String key = (String)keys.next();
+            Object expectedValue = expectedJSON.get(key);
+            if (expectedValue == JSONObject.NULL){
+                continue;
+            }
+
+            Object actualValue = actualJSON.get(key);
+
+            if (expectedValue instanceof JSONObject) {
+                String expectedVal = expectedValue.toString();
+                String actualVal = actualValue.toString();
+                assertJsonStringEqualsIgnoreNulls(expectedVal, actualVal);
+            }
+            else if (expectedValue instanceof JSONArray) {
+                if (actualValue instanceof JSONArray) {
+                    JSONArray expectedJSONArray = (JSONArray)expectedValue;
+                    JSONArray actualJSONArray = (JSONArray)expectedValue;
+                    for (int i = 0; i < expectedJSONArray.length(); i++) {
+                        String expectedItem = expectedJSONArray.getJSONObject(i).toString();
+                        String actualItem = actualJSONArray.getJSONObject(i).toString();
+                        assertJsonStringEqualsIgnoreNulls(expectedItem, actualItem);
+                    }
+                }
+                else {
+                    fail("expected: " + expectedValue + " got:" + actualValue);
+                }
+            }
+            else {
+                Assert.assertEquals(expectedValue, actualValue);
+            }
+        }
+    }
+}
index 66ea075..55aed8f 100755 (executable)
@@ -40,7 +40,7 @@ import org.testng.annotations.Test;
 /**\r
  * The Class LogOutLeftPane.\r
  */\r
-@Test(enabled=true)\r
+@Test(enabled=false)\r
 public class LogOutLeftPane {\r
 \r
        /** The login button. */\r
index 64d72ab..2f5828b 100755 (executable)
@@ -38,7 +38,7 @@ import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;\r
 import org.springframework.web.context.WebApplicationContext;\r
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;\r
-\r
+import org.testng.annotations.Test;\r
 import org.openecomp.portalsdk.core.conf.AppConfig;\r
 import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;\r
 import org.openecomp.portalsdk.core.util.SystemProperties;\r
@@ -61,6 +61,7 @@ import org.openecomp.portalsdk.core.util.CacheManager;
 @WebAppConfiguration\r
 @ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {MockAppConfig.class})\r
 @ActiveProfiles(value="test")\r
+@Test(enabled=false)\r
 public class MockApplicationContextTestSuite {\r
                \r
            /** The wac. */\r
index ce3e6ba..85c550d 100755 (executable)
@@ -36,6 +36,7 @@ import org.openecomp.portalsdk.core.service.UserProfileService;
 /**\r
  * The Class ProfileServiceTest.\r
  */\r
+\r
 public class ProfileServiceTest extends MockApplicationContextTestSuite {\r
        \r
        /** The service. */\r
@@ -51,14 +52,13 @@ public class ProfileServiceTest extends MockApplicationContextTestSuite {
         */\r
        @Test\r
        public void testFindAll() {\r
-       \r
-               try {           \r
-                   List<Profile> profiles = service.findAll();\r
-                   Assert.assertTrue(profiles.size() > 0);\r
-               }\r
-               catch (Exception e) {\r
-                   //TODO: this is only to make maven to not complaint \r
-                   return;\r
+               \r
+               List<Profile> profiles;\r
+               try {\r
+                       profiles = service.findAll();\r
+                       Assert.assertTrue(profiles.size() > 0);\r
+               } catch (Exception e) {\r
+                       Assert.assertTrue(false);\r
                }\r
        }\r
 \r
diff --git a/vid-app-common/src/test/resources/asdc.properties b/vid-app-common/src/test/resources/asdc.properties
new file mode 100644 (file)
index 0000000..8352ff2
--- /dev/null
@@ -0,0 +1,6 @@
+asdc.client.type=REST
+
+asdc.client.rest.protocol=http
+asdc.client.rest.host=c2.vm1.sdc.simpledemo.openecomp.org
+asdc.client.rest.port=8080
+asdc.client.rest.auth=Basic dmlkOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
diff --git a/vid-app-common/src/test/resources/sampleTosca.csar b/vid-app-common/src/test/resources/sampleTosca.csar
new file mode 100644 (file)
index 0000000..d9c469a
Binary files /dev/null and b/vid-app-common/src/test/resources/sampleTosca.csar differ
diff --git a/vid-app-common/src/test/resources/vf-csar.JSON b/vid-app-common/src/test/resources/vf-csar.JSON
new file mode 100644 (file)
index 0000000..bd1a019
--- /dev/null
@@ -0,0 +1,153 @@
+{
+  "networks": {
+  },
+  "service": {
+    "category": "Mobility",
+    "description": "Bla bla",
+    "inputs": {
+      "greatdefect0_availability_zone_max_count": {
+        "constraints": [
+        ],
+        "default": 1,
+        "description": "",
+        "entry_schema": null,
+        "required": true,
+        "type": "integer"
+      },
+      "greatdefect0_itc_name_0": {
+        "constraints": [
+        ],
+        "default": "ab",
+        "description": "ixla itc instance name",
+        "entry_schema": null,
+        "required": true,
+        "type": "string"
+      },
+      "greatdefect0_vf_module_id": {
+        "constraints": [
+        ],
+        "default": "abc",
+        "description": "Unique ID for this VF Module instance",
+        "entry_schema": null,
+        "required": true,
+        "type": "string"
+      }
+    },
+    "invariantUuid": "bd9bf71a-df22-4c95-8638-89f15d875395",
+    "name": "Moriya_new_test",
+    "serviceEcompNaming": "true",
+    "toscaModelURL": null,
+    "uuid": "48a52540-8772-4368-9cdb-1f124ea5c931",
+    "version": "1.0"
+  },
+  "vfModules": {
+    "greatdefect0..Greatdefect..base_ixla..module-0": {
+      "commands": {
+      },
+      "customizationUuid": "316e323d-611d-4007-a647-b1d2ecdaee9e",
+      "description": null,
+      "invariantUuid": "80ff85fb-cb11-42cb-9737-e47095d42756",
+      "modelCustomizationName": "Greatdefect..base_ixla..module-0",
+      "name": "Greatdefect..base_ixla..module-0",
+      "uuid": "01166434-ef34-4969-aaf2-626203d72e48",
+      "version": "3",
+      "volumeGroupAllowed": false
+    },
+    "greatdefect0..Greatdefect..module_1_ixla..module-2": {
+      "commands": {
+      },
+      "customizationUuid": "1106fca3-235a-4f92-8d5a-960a7336b32f",
+      "description": null,
+      "invariantUuid": "e0297a51-c670-452e-b31c-c5b37c6ad40f",
+      "modelCustomizationName": "Greatdefect..module_1_ixla..module-2",
+      "name": "Greatdefect..module_1_ixla..module-2",
+      "uuid": "6f09e053-56a6-4fbb-8299-e1de616825cc",
+      "version": "3",
+      "volumeGroupAllowed": false
+    },
+    "greatdefect0..Greatdefect..module_2_ixla..module-1": {
+      "commands": {
+      },
+      "customizationUuid": "b52c1fda-fbbf-4de3-ad9b-190d4a14990c",
+      "description": null,
+      "invariantUuid": "23befc6e-aa97-4004-b215-4979c3f84913",
+      "modelCustomizationName": "Greatdefect..module_2_ixla..module-1",
+      "name": "Greatdefect..module_2_ixla..module-1",
+      "uuid": "dea8e41f-c996-4557-b521-263210d96baa",
+      "version": "3",
+      "volumeGroupAllowed": false
+    }
+  },
+  "vnfs": {
+    "greatdefect 0": {
+      "commands": {
+        "availability_zone_max_count": {
+          "command": "get_input",
+          "displayName": "availability_zone_max_count",
+          "inputName": "greatdefect0_availability_zone_max_count"
+        },
+        "itc_name_0": {
+          "command": "get_input",
+          "displayName": "itc_name_0",
+          "inputName": "greatdefect0_itc_name_0"
+        },
+        "vf_module_id": {
+          "command": "get_input",
+          "displayName": "vf_module_id",
+          "inputName": "greatdefect0_vf_module_id"
+        }
+      },
+      "customizationUuid": "9123ced3-fbcd-42f7-b103-5965c54bbd66",
+      "description": "checl-IdanWithSecondFix",
+      "inputs": {
+        "availability_zone_max_count": {
+          "constraints": [
+          ],
+          "default": 1,
+          "description": "",
+          "entry_schema": null,
+          "required": true,
+          "type": "integer"
+        },
+        "itc_name_0": {
+          "constraints": [
+          ],
+          "default": "ab",
+          "description": "ixla itc instance name",
+          "entry_schema": null,
+          "required": true,
+          "type": "string"
+        },
+        "vf_module_id": {
+          "constraints": [
+          ],
+          "default": "abc",
+          "description": "Unique ID for this VF Module instance",
+          "entry_schema": null,
+          "required": true,
+          "type": "string"
+        }
+      },
+      "invariantUuid": "d149c45a-b42f-419a-9fac-f9c359fc2034",
+      "modelCustomizationName": "greatdefect 0",
+      "name": "greatdefect",
+      "properties": {
+        "availability_zone_max_count": "get_input:greatdefect0_availability_zone_max_count",
+        "itc_flavor_name": "nv.c8r24d160",
+        "itc_image_name": "NIMBUS_IXLA-ITC_8.20_EA_KVM_210117.qcow2",
+        "itc_name_0": "get_input:greatdefect0_itc_name_0",
+        "itm_flavor_name": "nv.c2r4d50",
+        "itm_image_name": "NIMBUS_IXLA-ITM_8.20.EA_KVM.qcow2",
+        "vf_module_id": "get_input:greatdefect0_vf_module_id"
+      },
+      "uuid": "3b25707a-d345-4a80-8744-73adf8f2e67b",
+      "version": "3.0",
+      "vfModules": {
+      },
+      "volumeGroups": {
+      }
+    }
+  },
+  "volumeGroups": {
+  }
+}
diff --git a/vid-app-common/src/test/resources/vl-csar.JSON b/vid-app-common/src/test/resources/vl-csar.JSON
new file mode 100644 (file)
index 0000000..ce1f1b7
--- /dev/null
@@ -0,0 +1,109 @@
+{
+    "networks": {
+        "ExtVL 0": {
+            "commands": {
+                "exVL_naming#naming_policy": {
+                    "command": "get_input",
+                    "displayName": "exVL_naming#naming_policy",
+                    "inputName": "extvl0_exVL_naming_naming_policy"
+                },
+                "network_role": {
+                    "command": "get_input",
+                    "displayName": "network_role",
+                    "inputName": "extvl0_network_role"
+                },
+                "network_scope": {
+                    "command": "get_input",
+                    "displayName": "network_scope",
+                    "inputName": "extvl0_network_scope"
+                }
+            },
+            "customizationUuid": "664f8aa7-3989-46ac-81c0-dd72a8a63f26",
+            "description": "ECOMP generic virtual link (network) base type for all other service-level and global networks",
+            "inputs": {
+                "exVL_naming#naming_policy": {
+                    "constraints": [
+                    ],
+                    "default": null,
+                    "description": "Reference to naming policy that ECOMP will use when the name is auto-generated",
+                    "entry_schema": null,
+                    "required": true,
+                    "type": "string"
+                },
+                "network_role": {
+                    "constraints": [
+                    ],
+                    "default": null,
+                    "description": "Reference to naming policy that ECOMP will use when the name is auto-generated",
+                    "entry_schema": null,
+                    "required": true,
+                    "type": "string"
+                },
+                "network_scope": {
+                    "constraints": [
+                    ],
+                    "default": null,
+                    "description": "Reference to naming policy that ECOMP will use when the name is auto-generated",
+                    "entry_schema": null,
+                    "required": true,
+                    "type": "string"
+                }
+            },
+            "invariantUuid": "379f816b-a7aa-422f-be30-17114ff50b7c",
+            "modelCustomizationName": "ExtVL 0",
+            "name": "ExtVL",
+            "properties": {
+                "exVL_naming": "{naming_policy={get_input=extvl0_exVL_naming_naming_policy}}",
+                "network_role": "get_input:extvl0_network_role",
+                "network_scope": "get_input:extvl0_network_scope"
+            },
+            "uuid": "af584529-d7f0-420e-a6f3-c38b689c030f",
+            "version": "4.0"
+        }
+    },
+    "service": {
+        "category": "Network L1-3",
+        "description": "dsfg",
+        "inputs": {
+            "extvl0_exVL_naming_naming_policy": {
+                "constraints": [
+                ],
+                "default": null,
+                "description": "Reference to naming policy that ECOMP will use when the name is auto-generated",
+                "entry_schema": null,
+                "required": true,
+                "type": "string"
+            },
+            "extvl0_network_role": {
+                "constraints": [
+                ],
+                "default": null,
+                "description": "Unique label that defines the role that this network performs.   example: vce oam network, vnat sr-iov1 network\n",
+                "entry_schema": null,
+                "required": true,
+                "type": "string"
+            },
+            "extvl0_network_scope": {
+                "constraints": [
+                ],
+                "default": null,
+                "description": "Uniquely identifies the network scope. Valid values for the network scope   includes: VF - VF-level network. Intra-VF network which connects the VFCs (VMs) inside the VF. SERVICE - Service-level network. Intra-Service network which connects  the VFs within the service GLOBAL - Global network which can be shared by multiple services\n",
+                "entry_schema": null,
+                "required": true,
+                "type": "string"
+            }
+        },
+        "invariantUuid": "d752a44c-ac7b-4bda-8111-fb52312d101e",
+        "name": "Macro_flow_test",
+        "serviceEcompNaming": "true",
+        "toscaModelURL": null,
+        "uuid": "68101369-6f08-4e99-9a28-fa6327d344f3",
+        "version": "1.0"
+    },
+    "vfModules": {
+    },
+    "vnfs": {
+    },
+    "volumeGroups": {
+    }
+}