summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOfir Sonsino <os0695@att.com>2017-09-04 14:52:07 +0300
committerOfir Sonsino <os0695@att.com>2017-09-04 14:52:07 +0300
commitb35670742c728d7d85da2f9c856c51a5889449d6 (patch)
tree92e544b121b8a47230667f0e0078c188a47dd8eb
parent49a483a9b40cb429717ccec69fa99e4908aadbb6 (diff)
[VID-55] Upgrade Tosca Parser (merge)
Change-Id: I5389f1641ef22df3ed569a154b3c367117c04d04 Signed-off-by: Ofir Sonsino <os0695@att.com>
-rwxr-xr-xepsdk-app-onap/src/main/resources/portal_template.properties2
-rwxr-xr-xvid-app-common/pom.xml16
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java47
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java7
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java22
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java12
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java30
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java12
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java388
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java12
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParser.java15
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl.java225
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java226
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java854
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java1
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java285
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java106
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java61
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/Network.java2
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java56
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java209
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java252
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java259
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java123
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java17
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/VNF.java2
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java4
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java2
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java2
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java34
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java21
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java17
-rw-r--r--vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java79
-rw-r--r--vid-app-common/src/main/resources/catalog.json174
-rw-r--r--vid-app-common/src/main/resources/sdcservices.json29
-rw-r--r--vid-app-common/src/main/resources/service-vf-csar.zipbin0 -> 58693 bytes
-rw-r--r--vid-app-common/src/main/resources/service-vl-csar.zipbin0 -> 34490 bytes
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js11
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js1
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js2
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js137
-rw-r--r--vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java128
-rw-r--r--vid-app-common/src/test/java/org/opencomp/vid/testUtils/TestUtils.java65
-rwxr-xr-xvid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java2
-rwxr-xr-xvid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java3
-rwxr-xr-xvid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java16
-rw-r--r--vid-app-common/src/test/resources/asdc.properties6
-rw-r--r--vid-app-common/src/test/resources/sampleTosca.csarbin0 -> 6177 bytes
-rw-r--r--vid-app-common/src/test/resources/vf-csar.JSON153
-rw-r--r--vid-app-common/src/test/resources/vl-csar.JSON109
69 files changed, 3439 insertions, 1025 deletions
diff --git a/epsdk-app-onap/src/main/resources/portal_template.properties b/epsdk-app-onap/src/main/resources/portal_template.properties
index ed6940148..c26be5547 100755
--- a/epsdk-app-onap/src/main/resources/portal_template.properties
+++ b/epsdk-app-onap/src/main/resources/portal_template.properties
@@ -1,6 +1,6 @@
# Properties read by ECOMP Framework library, ecompFW.jar
-portal.api.impl.class = org.openecomp.portalapp.service.OnBoardingApiServiceImpl
+portal.api.impl.class = org.openecomp.portalsdk.core.onboarding.client.OnBoardingApiServiceImpl
portal.api.prefix = /api
max.idle.time = 5
user.attribute.name = user_attribute
diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml
index fbe74df58..fbc9d47f9 100755
--- a/vid-app-common/pom.xml
+++ b/vid-app-common/pom.xml
@@ -453,5 +453,21 @@
<artifactId>snakeyaml</artifactId>
<version>1.16</version>
</dependency>
+ <dependency>
+ <groupId>org.skyscreamer</groupId>
+ <artifactId>jsonassert</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.1.32-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>net.javacrumbs.json-unit</groupId>
+ <artifactId>json-unit</artifactId>
+ <version>1.23.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java
index ca710f6fc..9716ba827 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIProperties.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
index cd5095191..243410050 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
@@ -276,43 +276,22 @@ public class AAIRestInterface {
if (xml)
responseType = "application/xml";
- initRestClient();
-
- String clientCert = SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT);
-
- boolean useClientCert = false;
- if (clientCert != null &&
- SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {
- useClientCert = true;
- }
+ initRestClient();
url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL_BASE) + path;
- final Response cres;
- if (useClientCert == true) {
- cres = client.target(url)
- .request()
- .accept(responseType)
- .header("X-TransactionId", transId)
- .header("X-FromAppId", fromAppId)
- .header("Content-Type", "application/json")
- .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
- } else {
-
- String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);
- String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));
- String encodeThis = vidUsername + ":" + vidPassword;
-
- cres = client.target(url)
- .request()
- .accept(responseType)
- .header("X-TransactionId", transId)
- .header("X-FromAppId", fromAppId)
- .header("Content-Type", "application/json")
- .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))
- .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
- }
-
+ String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);
+ String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));
+ String encodeThis = vidUsername + ":" + vidPassword;
+
+ final Response cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", fromAppId)
+ .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+
if (cres.getStatus() == 200 && cres.getStatus() <= 299) {
logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java b/vid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java
index 2623d6b6f..1ed079219 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/CustomJacksonJaxBJsonProvider.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java b/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
index 8335d15b2..6a3665edb 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/HttpsAuthClient.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java b/vid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java
index e4c4bcef1..e31b0c1c7 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/JettyObfuscationConversionCommandLineUtil.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java
index aafb11cad..c80787205 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcCatalogException.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java
index c4a8b1c0c..314ea037d 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/AsdcClient.java
@@ -20,6 +20,8 @@
package org.openecomp.vid.asdc;
+import java.io.IOException;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
@@ -27,7 +29,6 @@ import java.util.UUID;
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;
/**
* The Interface AsdcClient.
@@ -77,7 +78,7 @@ public interface AsdcClient {
* @return the resource tosca model
* @throws AsdcCatalogException the sdc catalog exception
*/
- public ToscaCsar getResourceToscaModel(UUID uuid) throws AsdcCatalogException;
+ public Path getResourceToscaModel(UUID uuid) throws AsdcCatalogException;
/**
* Gets the service.
@@ -122,7 +123,7 @@ public interface AsdcClient {
* @return the service tosca model
* @throws AsdcCatalogException the asdc catalog exception
*/
- public ToscaCsar getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
+ public Path getServiceToscaModel(UUID uuid) throws AsdcCatalogException;
//TODO: Collect TOSCA information from CSAR
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java
index d24d1232a..4974d44a8 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Artifact.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java
index 3911c699a..000aae1a9 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Resource.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java
index fa898e56a..2a83cbe3a 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/Service.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java
index 6d7fb41b1..cd3ec7fee 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/SubResource.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java
index 21a50d3bb..0d3f17ae4 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Capability.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java
index b68b51a09..a91f38312 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Constraint.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.vid.asdc.beans.tosca;
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java
index 275db3c0d..4d31faab1 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Group.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java
index 33f317579..d64a58066 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Import.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java
index f98820716..e5eec0121 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Input.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,12 +14,14 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.vid.asdc.beans.tosca;
+import org.openecomp.sdc.toscaparser.api.elements.constraints.*;
+
import java.util.List;
import java.util.ArrayList;
@@ -42,7 +44,7 @@ public class Input {
private Input entry_schema;
/** The constraints */
- private List<Constraint> constraints;
+ private List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> constraints;
/** The required field. If not set, the default is true */
private boolean required = true;
@@ -51,7 +53,7 @@ public class Input {
* Instantiates a new input.
*/
public Input() {
- constraints = new ArrayList<Constraint>();
+ constraints = new ArrayList<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint>();
}
/**
@@ -144,7 +146,7 @@ public class Input {
*
* @param c the new constraints
*/
- public void setConstraints(List<Constraint> c) {
+ public void setConstraints(List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> c) {
this.constraints = c;
}
/**
@@ -152,7 +154,7 @@ public class Input {
*
* @return the constraints
*/
- public List<Constraint> getConstraints() {
+ public List<org.openecomp.sdc.toscaparser.api.elements.constraints.Constraint> getConstraints() {
return constraints;
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java
index 73eead93f..97740b3f5 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/NodeTemplate.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java
index c8f048ced..16b921e2a 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Property.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java
index fce41ec6e..acb250997 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Requirement.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java
index bd3a2f0a5..f77c1b4b5 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/Schema.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java
index 026f29bbe..f59f24674 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/SubstitutionMappings.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java
index ce7ce5755..25b2c2c38 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/TopologyTemplate.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java
index cca4ae7c2..9e9e1d00b 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaCsar.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java
index 41c7ca5ba..d42c1f150 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaMetadata.java
@@ -61,9 +61,6 @@ public class ToscaMetadata {
/** The resource vendor release. */
private String resourceVendorRelease;
- /** the resourceVendorModelNumber */
- private String resourceVendorModelNumber;
-
/** The service ecomp naming. */
private String serviceEcompNaming;
@@ -91,11 +88,6 @@ public class ToscaMetadata {
/** The vf module model version. */
private String vfModuleModelVersion;
-
- /** serviceType */
- private String serviceType;
- /** serviceRole */
- private String serviceRole;
/**
* Instantiates a new tosca metadata.
@@ -466,26 +458,4 @@ public class ToscaMetadata {
return vfModuleModelCustomizationUUID;
}
-
- /** serviceType */
- public String getServiceType() {
- return serviceType;
- }
- public void setServiceType(String serviceType) {
- this.serviceType= serviceType;
- }
- /** serviceRole */
- public String getServiceRole() {
- return serviceRole;
- }
- public void setServiceRole(String serviceRole) {
- this.serviceRole= serviceRole;
- }
- /** resourceVendorModelNumber */
- public String getResourceVendorModelNumber() {
- return resourceVendorModelNumber;
- }
- public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
- this.resourceVendorModelNumber= resourceVendorModelNumber;
- }
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java
index c9e42f291..77fbe9135 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/beans/tosca/ToscaModel.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
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
index 000000000..8538f6ba6
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/local/LocalAsdcClient.java
@@ -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);
+ }
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java
index c5134bfca..123cc5788 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/memory/InMemoryAsdcClient.java
@@ -7,7 +7,7 @@
* 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
@@ -168,7 +168,6 @@ public class InMemoryAsdcClient implements AsdcClient {
}
/* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResources()
*/
public Collection<Resource> getResources() throws AsdcCatalogException {
final Collection<Resource> resources = new LinkedList<Resource> ();
@@ -299,7 +298,7 @@ public class InMemoryAsdcClient implements AsdcClient {
/* (non-Javadoc)
* @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
*/
- public ToscaCsar getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+ public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
final String toscaModelURL = getCatalog().getJSONObject("resources")
.getJSONObject(resourceUuid.toString())
.getString("toscaModelURL");
@@ -309,13 +308,13 @@ public class InMemoryAsdcClient implements AsdcClient {
if (toscaModelStream == null) return null;
- return getToscaModel(toscaModelStream);
+ return null;//getToscaModel(toscaModelStream);
}
/* (non-Javadoc)
* @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
*/
- public ToscaCsar getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+ public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
final String toscaModelURL = getCatalog().getJSONObject("services")
.getJSONObject(serviceUuid.toString())
.getString("toscaModelURL");
@@ -324,7 +323,7 @@ public class InMemoryAsdcClient implements AsdcClient {
if (toscaModelStream == null) return null;
- return getToscaModel(toscaModelStream);
+ return null;//getToscaModel(toscaModelStream);
}
/**
@@ -369,4 +368,5 @@ public class InMemoryAsdcClient implements AsdcClient {
throw new AsdcCatalogException("Caught IOException while processing CSAR", e);
}
}
+
}
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
index 000000000..eb1669846
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParser.java
@@ -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
index 000000000..bea5da877
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl.java
@@ -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
index 000000000..4819cae8f
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/parser/ToscaParserImpl2.java
@@ -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
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java
index 9f7c3a57d..5b783f5cd 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/asdc/rest/RestfulAsdcClient.java
@@ -20,10 +20,28 @@
package org.openecomp.vid.asdc.rest;
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.openecomp.vid.asdc.AsdcCatalogException;
+import org.openecomp.vid.asdc.AsdcClient;
+import org.openecomp.vid.asdc.beans.Artifact;
+import org.openecomp.vid.asdc.beans.Resource;
+import org.openecomp.vid.asdc.beans.Service;
+import org.openecomp.vid.asdc.parser.ToscaParserImpl;
+import org.openecomp.vid.model.ModelConstants;
+import org.openecomp.vid.properties.VidProperties;
+
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
import java.io.IOException;
import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -35,441 +53,413 @@ import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
-import java.util.zip.ZipFile;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ResponseProcessingException;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.vid.asdc.AsdcCatalogException;
-import org.openecomp.vid.asdc.AsdcClient;
-import org.openecomp.vid.asdc.beans.Artifact;
-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.openecomp.vid.model.ModelConstants;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
-
-import org.openecomp.vid.properties.VidProperties;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
/**
* The Class RestfulAsdcClient.
*/
public class RestfulAsdcClient implements AsdcClient {
- /** The Constant LOG. */
- private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);
-
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /** The client. */
- private final Client client;
-
- /** The uri. */
- private final URI uri;
-
- /** The common headers. */
- private final MultivaluedHashMap<String, Object> commonHeaders;
-
- /** The auth. */
- private final String auth;
-
- /**
- * The Class Builder.
- */
- public static class Builder {
-
- /** The client. */
- private final Client client;
-
- /** The uri. */
- private final URI uri;
-
- /** The auth. */
- private String auth = null;
-
- /**
- * Instantiates a new builder.
- *
- * @param client the client
- * @param uri the uri
- */
- public Builder(Client client, URI uri) {
- this.client = client;
- this.client.register(JacksonJsonProvider.class);
- this.uri = uri;
- }
-
- /**
- * Auth.
- *
- * @param auth the auth
- * @return the builder
- */
- public Builder auth(String auth) {
- this.auth = auth;
- return this;
- }
-
- /**
- * Builds the.
- *
- * @return the restful asdc client
- */
- public RestfulAsdcClient build() {
- return new RestfulAsdcClient(this);
- }
- }
-
- /**
- * Instantiates a new restful asdc client.
- *
- * @param builder the builder
- */
- private RestfulAsdcClient(Builder builder) {
- client = builder.client;
- uri = builder.uri;
- auth = builder.auth;
-
- commonHeaders = new MultivaluedHashMap<String, Object> ();
- commonHeaders.put("X-ECOMP-InstanceID", Collections.singletonList((Object) "VID"));
- commonHeaders.put("Authorization", Collections.singletonList((Object) (auth)));
- }
-
- /**
- * Gets the client.
- *
- * @return the client
- */
- private Client getClient() { return client; }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)
- */
- public Resource getResource(UUID uuid) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path(path + "/" + uuid.toString() + "/metadata")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(Resource.class);
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResources()
- */
- public Collection<Resource> getResources() throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path(path)
- .request(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(new GenericType<Collection<Resource>> () {});
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)
- */
- public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
- WebTarget target = getClient()
- .target(uri)
- .path(path);
-
- for (Entry<String, String[]> filterEntry : filter.entrySet()) {
- target = target.queryParam(filterEntry.getKey(), (Object []) filterEntry.getValue());
- }
-
- try {
- return target.request()
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(new GenericType<Collection<Resource>> () {});
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (NotFoundException e) {
- throw e;
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
- */
- public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path(path + "/" + resourceUuid + "/artifacts/" + artifactUuid)
- .request(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(Artifact.class);
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)
- */
- public Service getService(UUID uuid) throws AsdcCatalogException {
-
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path( path + "/" + uuid.toString() + "/metadata")
- .request(MediaType.APPLICATION_JSON)
- .headers(commonHeaders)
- .get(Service.class);
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getServices()
- */
- public Collection<Service> getServices() throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path(path)
- .request()
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(new GenericType<Collection<Service>> () {});
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getServices(java.util.Map)
- */
- public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
-
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- WebTarget target = getClient()
- .target(uri)
- .path(path);
-
-
- for (Entry<String, String[]> filterEntry : filter.entrySet()) {
- target = target.queryParam(filterEntry.getKey(), (Object []) filterEntry.getValue());
- }
-
- try {
- return target.request()
- .accept(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(new GenericType<Collection<Service>> () {});
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (NotFoundException e) {
- throw e;
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
- */
- public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- try {
- return getClient()
- .target(uri)
- .path(path + "/" + serviceUuid + "/artifacts/" + artifactUuid)
- .request(MediaType.APPLICATION_JSON_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_JSON)
- .get(Artifact.class);
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
- */
- public ToscaCsar getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
- try (final InputStream csarInputStream = (InputStream) getClient()
- .target(uri)
- .path(path + "/" + resourceUuid + "/toscaModel")
- .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
- .get(InputStream.class)) {
-
- return getToscaModel(csarInputStream);
- } catch (IOException e) {
- throw new AsdcCatalogException("Failed to retrieve resource TOSCA model from ASDC", e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
- */
- public ToscaCsar getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
- String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- try {
- final InputStream csarInputStream = (InputStream) getClient()
- .target(uri)
- .path(path + "/" + serviceUuid + "/toscaModel")
- .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
- .headers(commonHeaders)
- .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
- .get(InputStream.class);
-
- return getToscaModel(csarInputStream);
- } catch (ResponseProcessingException e) {
- //Couldn't convert response to Java type
- throw new AsdcCatalogException("ASDC response could not be processed", e);
- } catch (ProcessingException e) {
- //IO problems during request
- throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
- } catch (WebApplicationException e) {
- //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
- throw new AsdcCatalogException(e);
- }
- }
-
- /**
- * 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);
- }
+ /**
+ * The Class Builder.
+ */
+ public static class Builder {
+
+ /**
+ * The client.
+ */
+ private final Client client;
+
+ /**
+ * The uri.
+ */
+ private final URI uri;
+
+ /**
+ * The auth.
+ */
+ private String auth = null;
+
+ /**
+ * Instantiates a new builder.
+ *
+ * @param client the client
+ * @param uri the uri
+ */
+ public Builder(Client client, URI uri) {
+ this.client = client;
+ this.client.register(JacksonJsonProvider.class);
+ this.uri = uri;
+ }
+
+ /**
+ * Auth.
+ *
+ * @param auth the auth
+ * @return the builder
+ */
+ public Builder auth(String auth) {
+ this.auth = auth;
+ return this;
+ }
+
+ /**
+ * Builds the.
+ *
+ * @return the restful asdc client
+ */
+ public RestfulAsdcClient build() {
+ return new RestfulAsdcClient(this);
+ }
+ }
+
+ /**
+ * The Constant LOG.
+ */
+ static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(RestfulAsdcClient.class);
+
+ /**
+ * The Constant dateFormat.
+ */
+ final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
+
+ /**
+ * The client.
+ */
+ private final Client client;
+
+ /**
+ * The uri.
+ */
+ private final URI uri;
+
+ /**
+ * The common headers.
+ */
+ private final MultivaluedHashMap<String, Object> commonHeaders;
+
+ /**
+ * The auth.
+ */
+ private final String auth;
+
+ ToscaParserImpl p = new ToscaParserImpl();
+
+ /**
+ * Instantiates a new restful asdc client.
+ *
+ * @param builder the builder
+ */
+ private RestfulAsdcClient(Builder builder) {
+ client = builder.client;
+ uri = builder.uri;
+ auth = builder.auth;
+
+ commonHeaders = new MultivaluedHashMap<String, Object>();
+ commonHeaders.put("X-ECOMP-InstanceID", Collections.singletonList((Object) "VID"));
+ commonHeaders.put("Authorization", Collections.singletonList((Object) (auth)));
+ }
+
+ private Path createTmpFile(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);
+ }
+ return csarFile;
+ }
+
+ /**
+ * Gets the client.
+ *
+ * @return the client
+ */
+ private Client getClient() {
+ return client;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResource(java.util.UUID)
+ */
+ public Resource getResource(UUID uuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + uuid.toString() + "/metadata")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(Resource.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getResourceArtifact(UUID resourceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + resourceUuid + "/artifacts/" + artifactUuid)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(Artifact.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResources()
+ */
+ public Collection<Resource> getResources() throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(new GenericType<Collection<Resource>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResources(java.util.Map)
+ */
+ public Collection<Resource> getResources(Map<String, String[]> filter) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ WebTarget target = getClient()
+ .target(uri)
+ .path(path);
+
+ for (Entry<String, String[]> filterEntry : filter.entrySet()) {
+ target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());
+ }
+
+ try {
+ return target.request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(new GenericType<Collection<Resource>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (NotFoundException e) {
+ throw e;
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getResourceToscaModel(java.util.UUID)
+ */
+ public Path getResourceToscaModel(UUID resourceUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_RESOURCE_API_PATH, ModelConstants.DEFAULT_ASDC_RESOURCE_API_PATH);
+ try (final InputStream csarInputStream = (InputStream) getClient()
+ .target(uri)
+ .path(path + "/" + resourceUuid + "/toscaModel")
+ .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
+ .get(InputStream.class)) {
+
+ return getToscaCsar(csarInputStream);
+ } catch (IOException e) {
+ throw new AsdcCatalogException("Failed to retrieve resource TOSCA model from ASDC", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getService(java.util.UUID)
+ */
+ public Service getService(UUID uuid) throws AsdcCatalogException {
+
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + uuid.toString() + "/metadata")
+ .request(MediaType.APPLICATION_JSON)
+ .headers(commonHeaders)
+ .get(Service.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceArtifact(java.util.UUID, java.util.UUID)
+ */
+ public Artifact getServiceArtifact(UUID serviceUuid, UUID artifactUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
- 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);
- }
- }
+ try {
+ return getClient()
+ .target(uri)
+ .path(path + "/" + serviceUuid + "/artifacts/" + artifactUuid)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(Artifact.class);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServices()
+ */
+ public Collection<Service> getServices() throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ return getClient()
+ .target(uri)
+ .path(path)
+ .request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(new GenericType<Collection<Service>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServices(java.util.Map)
+ */
+ public Collection<Service> getServices(Map<String, String[]> filter) throws AsdcCatalogException {
+
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ WebTarget target = getClient()
+ .target(uri)
+ .path(path);
+
+
+ for (Entry<String, String[]> filterEntry : filter.entrySet()) {
+ target = target.queryParam(filterEntry.getKey(), (Object[]) filterEntry.getValue());
+ }
+
+ try {
+ return target.request()
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .get(new GenericType<Collection<Service>>() {
+ });
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (NotFoundException e) {
+ throw e;
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.openecomp.vid.asdc.AsdcClient#getServiceToscaModel(java.util.UUID)
+ */
+ public Path getServiceToscaModel(UUID serviceUuid) throws AsdcCatalogException {
+ String path = VidProperties.getPropertyWithDefault(ModelConstants.ASDC_SVC_API_PATH, ModelConstants.DEFAULT_ASDC_SVC_API_PATH);
+ try {
+ final InputStream csarInputStream = (InputStream) getClient()
+ .target(uri)
+ .path(path + "/" + serviceUuid + "/toscaModel")
+ .request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
+ .headers(commonHeaders)
+ .header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
+ .get(InputStream.class);
+
+
+ return getToscaCsar(csarInputStream);
+ } catch (ResponseProcessingException e) {
+ //Couldn't convert response to Java type
+ throw new AsdcCatalogException("ASDC response could not be processed", e);
+ } catch (ProcessingException e) {
+ //IO problems during request
+ throw new AsdcCatalogException("Failed to get a response from ASDC service", e);
+ } catch (WebApplicationException e) {
+ //Web service returned data, but the response status wasn't a good one (i.e. non 2xx)
+ throw new AsdcCatalogException(e);
+ }
+ }
+
+
+ /**
+ * Gets the tosca model.
+ *
+ * @param csarInputStream the csar input stream
+ * @return the tosca model
+ * @throws AsdcCatalogException the asdc catalog exception
+ */
+ private Path getToscaCsar(InputStream csarInputStream) throws AsdcCatalogException {
+ return createTmpFile(csarInputStream);
+ }
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java
index 92b752859..861ddf8da 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/AaiController.java
@@ -302,7 +302,6 @@ public class AaiController extends RestrictedBaseController{
* @param namedQueryId the named query id
* @param globalCustomerId the global customer id
* @param serviceType the service type
- * @param serviceInstance the service instance
* @return ResponseEntity The response entity
*/
@RequestMapping(value="/aai_get_models_by_service_type/{namedQueryId}/{globalCustomerId}/{serviceType}", method = RequestMethod.GET)
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java b/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java
index f7bf3a54e..9972ae5d3 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/VidController.java
@@ -20,144 +20,39 @@
package org.openecomp.vid.controller;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.UUID;
-
-import javax.net.ssl.SSLContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Client;
-
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+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.exceptions.VidServiceUnavailableException;
-import org.openecomp.vid.model.ModelUtil;
-import org.openecomp.vid.model.ModelConstants;
-import org.openecomp.vid.model.Network;
import org.openecomp.vid.model.ServiceModel;
-import org.openecomp.vid.model.VNF;
-import org.openecomp.vid.model.VfModule;
-import org.openecomp.vid.model.VolumeGroup;
-//import org.openecomp.vid.model.Service;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
+import org.openecomp.vid.services.*;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.vid.asdc.AsdcCatalogException;
-import org.openecomp.vid.asdc.AsdcClient;
-import org.openecomp.vid.asdc.beans.Resource;
-import org.openecomp.vid.asdc.beans.Service;
-import org.openecomp.vid.asdc.beans.tosca.Group;
-import org.openecomp.vid.asdc.beans.tosca.NodeTemplate;
-import org.openecomp.vid.asdc.beans.tosca.ToscaCsar;
-import org.openecomp.vid.asdc.beans.tosca.ToscaModel;
-import org.openecomp.vid.asdc.memory.InMemoryAsdcClient;
-import org.openecomp.vid.asdc.rest.RestfulAsdcClient;
-import org.openecomp.vid.properties.AsdcClientConfiguration;
-import org.openecomp.vid.properties.AsdcClientConfiguration.AsdcClientType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.vid.properties.VidProperties;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Collection;
+import java.util.Map;
+
+//import org.openecomp.vid.model.Service;
-/**
- * The Class VidController.
- */
@RestController
public class VidController extends RestrictedBaseController {
- /** The Constant LOG. */
private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VidController.class);
-
- /** The Constant dateFormat. */
- final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
-
- /** The app context. */
- @Autowired
- private ApplicationContext appContext;
-
- /**
- * Gets the object mapper.
- *
- * @return the object mapper
- */
- @Bean
- public ObjectMapper getObjectMapper() {
- return new ObjectMapper();
- }
-
- /**
- * Gets the asdc client.
- *
- * @return the asdc client
- */
- @Bean
- public AsdcClient getAsdcClient() {
-
- final AsdcClientConfiguration asdcClientConfig = appContext.getBean(AsdcClientConfiguration.class);
- 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);
+ private final VidService service;
- return new InMemoryAsdcClient.Builder().catalog(catalog).build();
- case REST:
+ @Autowired
+ public VidController(VidService vidService) throws SdcToscaParserException{
- 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);
- }
-
- default:
- throw new RuntimeException(asdcClientConfig.getAsdcClientType() + " is invalid; must be one of " + Arrays.toString(AsdcClientType.values()));
- }
+ service = vidService;
}
-
+//
/**
* Gets the services.
*
@@ -168,7 +63,8 @@ public class VidController extends RestrictedBaseController {
@RequestMapping(value={"/rest/models/services"}, method = RequestMethod.GET)
public Collection<org.openecomp.vid.asdc.beans.Service> getServices(HttpServletRequest request) throws VidServiceUnavailableException {
try {
- return getAsdcClient().getServices(request.getParameterMap());
+ Map<String, String[]> requestParams = request.getParameterMap();
+ return service.getServices(requestParams);
} catch (AsdcCatalogException e) {
LOG.error("Failed to retrieve service definitions from SDC", e);
throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
@@ -188,159 +84,14 @@ public class VidController extends RestrictedBaseController {
*/
@RequestMapping(value={"/rest/models/services/{uuid}"}, method = RequestMethod.GET)
public ServiceModel getServices(@PathVariable("uuid") String uuid) throws VidServiceUnavailableException {
- String methodName = "getServices";
- LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start");
- boolean isNewFlow = false;
-
- String asdcModelNamespaces[] = VidProperties.getAsdcModelNamespace();
- String[] vnfTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VNF);
- String[] networkTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.NETWORK);
- String[] vfModuleTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VF_MODULE);
-
try {
- final ServiceModel serviceModel = new ServiceModel();
- final Map<String, VNF> vnfs = new HashMap<String, VNF> ();
- final Map<String, Network> networks = new HashMap<String, Network> ();
-
- final ToscaCsar serviceCsar = getAsdcClient().getServiceToscaModel(UUID.fromString(uuid));
- final Service asdcServiceMetadata = getAsdcClient().getService(UUID.fromString(uuid));
- final ToscaModel asdcServiceToscaModel = serviceCsar.getParent();
-
- serviceModel.setService(ServiceModel.extractService(asdcServiceToscaModel, asdcServiceMetadata));
-
- for (Entry<String, NodeTemplate> component: asdcServiceToscaModel.gettopology_template().getnode_templates().entrySet()) {
- 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();
-
- // is it a VNF?
- if ( ModelUtil.isType (type, vnfTags) ) {
- LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " found node template type: " + type);
-
- final UUID vnfUuid = UUID.fromString(nodeTemplate.getMetadata().getUUID());
- final VNF vnf = new VNF();
- vnf.extractVnf(modelCustomizationName, nodeTemplate);
-
- if (vnf.getVersion() == null) {
- // vnf version should always be populated. The call below may not return the correct metadata since
- // uuid is not unique
- final Resource vnfMetadata = getAsdcClient().getResource(UUID.fromString(nodeTemplate.getMetadata().getUUID()));
- vnf.setVersion(vnfMetadata.getVersion());
- }
-
- LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " VNF commands: " + vnf.getCommands());
- vnfs.put(modelCustomizationName, vnf);
- if ( (vnf.getCustomizationUuid() != null) && (vnf.getCustomizationUuid().length() > 0 ) ) {
- isNewFlow = true;
- }
- }
-
- // is it a Network?
- if ( ModelUtil.isType (type, networkTags) ) {
- LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " found node template type: " + type);
- final UUID networkUuid = UUID.fromString(nodeTemplate.getMetadata().getUUID());
- final Network network = new Network();
- network.extractNetwork(modelCustomizationName, nodeTemplate);
-
- if (network.getVersion() == null) {
- // network version should always be populated. The call below may not return the correct metadata since
- // uuid is not unique
- final Resource networkMetadata = getAsdcClient().getResource(UUID.fromString(nodeTemplate.getMetadata().getUUID()));
- network.setVersion(networkMetadata.getVersion());
- }
- if ( (network.getCustomizationUuid() != null) && (network.getCustomizationUuid().length() > 0 ) ) {
- isNewFlow = true;
- }
- networks.put(modelCustomizationName, network);
-
- }
- }
- serviceModel.setVnfs(vnfs);
- serviceModel.setNetworks(networks);
- // If we see customization uuid under vnf or network, follow 1702 flow
- if ( isNewFlow ) {
- return ( getCustomizedServices(asdcServiceToscaModel, serviceModel) );
- }
- VNF vnf = null;
- for (ToscaModel vnfModel : serviceCsar.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
- for ( Entry<String, VNF> vnfComp : vnfs.entrySet() ) {
- if ( ( ( vnfComp.getValue().getUuid() ).equalsIgnoreCase(vnfUuid) ) ) {
- // found the vnf
- vnf = vnfComp.getValue();
- }
- }
- final Map<String, VfModule> vfModules = new HashMap<String, VfModule> ();
- final Map<String, VolumeGroup> volumeGroups = new HashMap<String, VolumeGroup> ();
-
- if (vnf == null) {
- LOG.warn("Couldn't find VNF object " + vnfUuid + ". Problem with Tosca model?");
- continue;
- }
-
- vnf.setInputs(vnfModel.gettopology_template().getInputs());
-
- for (Entry<String, Group> component1 : vnfModel.gettopology_template().getGroups().entrySet()) {
- final Group group = component1.getValue();
- final String type = group.getType();
- final String modelCustomizationName = component1.getKey();
-
- // 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.
- // Keep using the VF Modules under VNFs but we need to get the customization uuid from the service level and put them
- // under each VF module at the VNF level
- if ( ModelUtil.isType (type, vfModuleTags) ) {
-
- VfModule vfMod = VfModule.extractVfModule(modelCustomizationName, group);
-
- // Add the vf module customization uuid from the service model
- // The key of the VF Module in the service level will be the VF instance name appended to the VF Module name:
- // <VF instance name>..<VF Module name>
- /* String normalizedVnfCustomizationName = VNF.normalizeName (vnf.getModelCustomizationName());
- org.openecomp.vid.model.Service.extractVfModuleCustomizationUUID (serviceModel.getService(), normalizedVnfCustomizationName, vfMod);*/
-
- vfModules.put(modelCustomizationName, vfMod);
-
- if ( vfMod.isVolumeGroupAllowed() ) {
- volumeGroups.put(modelCustomizationName, VolumeGroup.extractVolumeGroup(modelCustomizationName, group));
- }
-
- }
- }
-
- vnf.setVfModules(vfModules);
- vnf.setVolumeGroups(volumeGroups);
- }
-
- serviceModel.setVnfs(vnfs);
- serviceModel.setNetworks(networks);
-
- return serviceModel;
+ return service.getService(uuid);
} catch (AsdcCatalogException e) {
LOG.error("Failed to retrieve service definitions from SDC", e);
throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
}
- catch (Exception e) {
- LOG.error("Failed to retrieve service definitions from SDC", e);
- throw new VidServiceUnavailableException("Failed to retrieve service definitions from SDC", e);
- }
}
- public 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);
- // Now put the vf modules and volume groups under the VNF they belong too
- serviceModel.associateGroups();
- return (serviceModel);
- }
/**
* Gets the services view.
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
index 000000000..9a258a109
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/controller/WebConfig.java
@@ -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
index 4606aa021..000000000
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============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;
-
-/**
- * The Class ModelUtil.
- *
- */
-public class ModelUtil {
- /**
- * Gets the tags for the given element according to the configured namespace
- * @param namespaces the namespace list from the configuration
- * @param constantValue the constant portion of the tag name, i.e. resource.vf...
- * @return the tags
- */
- public static String[] getTags ( String[] namespaces, String constantValue ) {
- String[] tags;
- if ( namespaces == null || namespaces.length == 0 ) {
- return null;
- }
- int le = namespaces.length;
- tags = new String[le];
- for ( int i = 0; i < le; i++ ) {
- tags[i] = namespaces[i] + constantValue;
- }
- return (tags);
- }
- /**
- * Determine if a note template type matches a set of configurable tags
- * @param type the node template type
- * @param tags the model configurable namespaces
- * @return true if type starts with a tag in the array, false otherwise
- */
- public static boolean isType ( String type, String[] tags ) {
- if ( (tags != null) && (tags.length > 0) ) {
- for ( int i = 0; i < tags.length; i++ ) {
- if ( type.startsWith (tags[i]) ) {
- return (true);
- }
- }
- }
- return (false);
- }
-}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java b/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java
index 5ab55881b..e763496fc 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/Network.java
@@ -49,7 +49,7 @@ public class Network extends Node {
*
* @param modelCustomizationName the new model customization name
*/
- private void setModelCustomizationName(String modelCustomizationName) {
+ public void setModelCustomizationName(String modelCustomizationName) {
this.modelCustomizationName = modelCustomizationName;
}
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
index 000000000..48e3a55fd
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNetwork.java
@@ -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
index 000000000..681131fc9
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewNode.java
@@ -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
index 000000000..1dcf0224e
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewService.java
@@ -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
index 000000000..6fda979c1
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewServiceModel.java
@@ -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
index 000000000..e84f963c5
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/NewVNF.java
@@ -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);
+ }
+
+ }
+
+}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java
index 98e65316b..8742931c6 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/ServiceModel.java
@@ -30,11 +30,11 @@ 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.controller.VidController;
import org.openecomp.vid.properties.VidProperties;
/**
* The Class ServiceModel.
*/
+@SuppressWarnings("ALL")
public class ServiceModel {
/** The Constant LOG. */
@@ -176,21 +176,22 @@ public class ServiceModel {
return service;
}
- public void extractGroups (ToscaModel serviceToscaModel) {
+ public static void extractGroups (ToscaModel serviceToscaModel,ServiceModel 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 asdcModelNamespaces[] = VidProperties.getAsdcModelNamespace();
- String[] vfModuleTags = ModelUtil.getTags(asdcModelNamespaces, ModelConstants.VF_MODULE);
-
+
+ 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 ( ModelUtil.isType (type, vfModuleTags) ) {
+ if (type.startsWith(vfModuleTag)) {
VfModule vfMod = VfModule.extractVfModule(customizationName, group);
vfModules.put(customizationName, vfMod);
if ( vfMod.isVolumeGroupAllowed() ) {
@@ -200,8 +201,8 @@ public class ServiceModel {
}
}
// add this point vfModules and volume groups are disconnected from VNF
- this.setVfModules (vfModules);
- this.setVolumeGroups (volumeGroups);
+ serviceModel.setVfModules (vfModules);
+ serviceModel.setVolumeGroups (volumeGroups);
}
/**
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java
index be37c947b..62e101ef8 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VNF.java
@@ -130,7 +130,7 @@ public class VNF extends Node {
*
* @param modelCustomizationName the new model customization name
*/
- private void setModelCustomizationName(String modelCustomizationName) {
+ public void setModelCustomizationName(String modelCustomizationName) {
this.modelCustomizationName = modelCustomizationName;
}
/**
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java
index 4a031a6c6..3f6f1da22 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VfModule.java
@@ -207,7 +207,7 @@ public class VfModule {
*
* @param volumeGroupAllowed the new volume group allowed
*/
- private void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
+ public void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
this.volumeGroupAllowed = volumeGroupAllowed;
}
/**
@@ -223,7 +223,7 @@ public class VfModule {
*
* @param modelCustomizationName the new model customization name
*/
- private void setModelCustomizationName(String modelCustomizationName) {
+ public void setModelCustomizationName(String modelCustomizationName) {
this.modelCustomizationName = modelCustomizationName;
}
/**
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java b/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java
index ea8e151d6..d09ef9a33 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/model/VolumeGroup.java
@@ -170,7 +170,7 @@ public class VolumeGroup {
*
* @param u the new customization name
*/
- private void setModelCustomizationName(String u) {
+ public void setModelCustomizationName(String u) {
this.modelCustomizationName = u;
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java b/vid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java
index b0dc906be..1a6dbcccb 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/mso/MsoRestInterfaceIfc.java
@@ -70,7 +70,7 @@ public interface MsoRestInterfaceIfc {
*/
public <T> void Post(T t, RequestDetails r, String sourceID, String path, RestObject<T> restObject) throws Exception;
- /**
+ /***
* Log request.
*
* @param r the r
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java b/vid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java
index 6d5f9522c..232023b4e 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/properties/AsdcClientConfiguration.java
@@ -24,31 +24,36 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
/**
* The Class AsdcClientConfiguration.
*/
@Configuration
-@PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties")
+
+@PropertySources({
+ @PropertySource(value="asdc.properties", ignoreResourceNotFound = true),
+ @PropertySource(value="${container.classpath:}/WEB-INF/conf/asdc.properties", ignoreResourceNotFound = true)
+})
public class AsdcClientConfiguration {
-
- @Bean
- public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
- return new PropertySourcesPlaceholderConfigurer();
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
}
@Value("${asdc.client.type}")
private AsdcClientType asdcClientType;
-
+
/** The asdc client host. */
@Value("${asdc.client.rest.host}")
private String asdcClientHost;
-
+
/** The asdc client port. */
@Value("${asdc.client.rest.port}")
private int asdcClientPort;
-
+
/** The asdc client auth. */
@Value("${asdc.client.rest.auth}")
public String asdcClientAuth;
@@ -56,7 +61,7 @@ public class AsdcClientConfiguration {
/** The asdc client protocol. */
@Value("${asdc.client.rest.protocol}")
public String asdcClientProtocol;
-
+
/**
* Gets the asdc client type.
*
@@ -101,16 +106,19 @@ public class AsdcClientConfiguration {
public String getAsdcClientProtocol() {
return asdcClientProtocol;
}
-
+
/**
* The Enum AsdcClientType.
*/
public enum AsdcClientType {
-
+
/** The in memory. */
IN_MEMORY,
-
+
/** The rest. */
- REST
+ REST,
+
+ /** The local. */
+ LOCAL
}
}
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java b/vid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java
index 38062df40..141b9b27c 100755
--- a/vid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java
+++ b/vid-app-common/src/main/java/org/openecomp/vid/properties/VidProperties.java
@@ -53,27 +53,21 @@ public class VidProperties extends SystemProperties {
*
* @return the property value or a default value
*/
- public static String[] getAsdcModelNamespace() {
+ public static String getAsdcModelNamespace() {
String methodName = "getAsdcModelNamespace ";
- String[] asdcModelNamespaces = null;
- String value = null;
+ String asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
try {
- value = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
- if ( value == null || value.isEmpty()) {
- asdcModelNamespaces = new String[1];
- asdcModelNamespaces[0] = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ asdcModelNamespace = SystemProperties.getProperty(ModelConstants.ASDC_MODEL_NAMESPACE);
+ if ( asdcModelNamespace == null || asdcModelNamespace.isEmpty()) {
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
}
- else {
- asdcModelNamespaces = value.split(",");
- }
}
catch ( Exception e ) {
LOG.error (EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + "unable to find the value, using the default "
+ ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE);
- asdcModelNamespaces = new String[1];
- asdcModelNamespaces[0] = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
+ asdcModelNamespace = ModelConstants.DEFAULT_ASDC_MODEL_NAMESPACE;
}
- return (asdcModelNamespaces);
+ return (asdcModelNamespace);
}
/**
* Gets the specified property value. If the property is not defined, returns a default value.
@@ -96,5 +90,4 @@ public class VidProperties extends SystemProperties {
}
return (propValue);
}
-
}
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
index 000000000..4fb0ff160
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/services/VidService.java
@@ -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
index 000000000..9844842f8
--- /dev/null
+++ b/vid-app-common/src/main/java/org/openecomp/vid/services/VidServiceImpl.java
@@ -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
index 000000000..20c7d5769
--- /dev/null
+++ b/vid-app-common/src/main/resources/catalog.json
@@ -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
index 000000000..9ef37c303
--- /dev/null
+++ b/vid-app-common/src/main/resources/sdcservices.json
@@ -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
index 000000000..f66d08464
--- /dev/null
+++ b/vid-app-common/src/main/resources/service-vf-csar.zip
Binary files 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
index 000000000..121192ae1
--- /dev/null
+++ b/vid-app-common/src/main/resources/service-vl-csar.zip
Binary files differ
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
index cc5b680d0..e7cbc4867 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
@@ -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",
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js
index 23ff56b34..65e15f27a 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/fieldConstants.js
@@ -127,6 +127,7 @@ appDS2.factory("FIELD", [ "PARAMETER", function(PARAMETER) {
};
var KEY = {
+ LCP_REGION_TEXT : "AAIAIC25"
};
/*
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
index 496c06f1c..eac79ed57 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
@@ -41,7 +41,7 @@ appDS2.controller("aaiSubscriberController", [ "COMPONENT", "FIELD", "PARAMETER"
$scope.defaultBaseUrl = "";
$scope.responseTimeoutMsec = 60000;
- $scope.serviceTypes=[ FIELD.PROMPT.SELECT_SERVICE];
+ $scope.serviceTypes=[ FIELD.PROMPT.SELECT_SERVICE, COMPONENT.UCPE_VMS, COMPONENT.SDN_L3_BONDING, COMPONENT.SDN_ETHERNET_INTERNET];
$scope.defaultSubscriberName=[ FIELD.PROMPT.SELECT_SUB ];
var callbackFunction = function(response) {
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
index 2cf689e75..06cbf0585 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/subscriberSearch.js
@@ -238,7 +238,144 @@ appDS2.controller("aaiSubscriberSearchController", [ "$scope", "$timeout", "$log
});
}
+ /*
+ * Test data objects:
+ */
+ var subscriberInfo = {
+ globalSubscriberId : COMPONENT.GLOBAL_SUBSCRIBER_ID_1,
+ subscriberName : COMPONENT.SUBSCRIBER_NAME_GED12
+ };
+
+ var createServiceRequestDetails = {
+ modelInfo : {
+ modelType : COMPONENT.SERVICE,
+ modelId : COMPONENT.MODEL_ID_1,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,
+ modelName : COMPONENT.MODEL_NAME_WANBONDING,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ },
+ subscriberInfo : subscriberInfo,
+ requestParameters : {
+ vpnId : COMPONENT.VPN_ID_1,
+ productName : COMPONENT.PRODUCT_NAME_TRINITY,
+ customerId : COMPONENT.CUSTOMER_ID_1
+ }
+ };
+
+ var deleteServiceRequestDetails = {
+ modelInfo : {
+ modelType : COMPONENT.SERVICE,
+ modelId : COMPONENT.MODEL_ID_1,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_1,
+ modelName : COMPONENT.MODEL_NAME_WANBONDING,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ };
+
+ var createNetworkRequestDetails = {
+ modelInfo : {
+ modelType : COMPONENT.NETWORK,
+ modelId : COMPONENT.MODEL_ID_2,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,
+ modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ },
+ relatedModelList : [
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_1,
+ modelInfo : {
+ modelType : COMPONENT.SERVICE,
+ modelId : COMPONENT.MODEL_ID_3,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,
+ modelName : COMPONENT.MODEL_NAME_IISBC,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ },
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_2,
+ modelInfo : {
+ modelType : COMPONENT.VNF,
+ modelId : COMPONENT.MODEL_ID_4,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,
+ modelName : COMPONENT.MODEL_NAME_VISBC,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ },
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_3,
+ modelInfo : {
+ modelType : COMPONENT.VF_MODULE,
+ modelId : COMPONENT.MODEL_ID_5,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,
+ modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ } ],
+ subscriberInfo : subscriberInfo,
+ requestParameters : {
+ /*
+ * FYI: quotes around field names are needed due to embedded "-"
+ * characters
+ */
+ "cidr-mask" : COMPONENT.CIDR_MASK_1,
+ "gateway-address" : COMPONENT.GATEWAY_ADDRESS_1,
+ "dhcp-enabled" : COMPONENT.TRUE
+ }
+ };
+
+ var deleteNetworkRequestDetails = {
+ modelInfo : {
+ modelType : COMPONENT.NETWORK,
+ modelId : COMPONENT.MODEL_ID_2,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_2,
+ modelName : COMPONENT.MODEL_NAME_VISBCOAMNETWORK,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ },
+ relatedModelList : [
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_1,
+ modelInfo : {
+ modelType : COMPONENT.SERVICE,
+ modelId : COMPONENT.MODEL_ID_3,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_3,
+ modelName : COMPONENT.MODEL_NAME_IISBC,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ },
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_2,
+ modelInfo : {
+ modelType : COMPONENT.VNF,
+ modelId : COMPONENT.MODEL_ID_4,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_4,
+ modelName : COMPONENT.MODEL_NAME_VISBC,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ },
+ {
+ relatedModel : {
+ instanceId : COMPONENT.INSTANCE_ID_3,
+ modelInfo : {
+ modelType : COMPONENT.VF_MODULE,
+ modelId : COMPONENT.MODEL_ID_5,
+ modelNameVersionId : COMPONENT.MODEL_NAME_VERSION_ID_5,
+ modelName : COMPONENT.MODEL_NAME_VISBCRTPEXPANSIONMODULE,
+ modelVersion : COMPONENT.MODEL_VERSION_1
+ }
+ }
+ } ]
+ };
$scope.getSubscriberDet = function(selectedCustomer){
window.location.href = COMPONENT.SUBDETAILS_SELECTEDSUBSCRIBER + selectedCustomer;
};
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
index 000000000..05ca8c324
--- /dev/null
+++ b/vid-app-common/src/test/java/org/opencomp/vid/controller/VidControllerTest.java
@@ -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
index 000000000..29115e0aa
--- /dev/null
+++ b/vid-app-common/src/test/java/org/opencomp/vid/testUtils/TestUtils.java
@@ -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);
+ }
+ }
+ }
+}
diff --git a/vid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java b/vid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java
index 66ea075e2..55aed8fb1 100755
--- a/vid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java
+++ b/vid-app-common/src/test/java/org/openecomp/ecomp/vid/selenium/LogOutLeftPane.java
@@ -40,7 +40,7 @@ import org.testng.annotations.Test;
/**
* The Class LogOutLeftPane.
*/
-@Test(enabled=true)
+@Test(enabled=false)
public class LogOutLeftPane {
/** The login button. */
diff --git a/vid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java b/vid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java
index 64d72abef..2f5828b61 100755
--- a/vid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java
+++ b/vid-app-common/src/test/java/org/openecomp/fusion/core/MockApplicationContextTestSuite.java
@@ -38,7 +38,7 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-
+import org.testng.annotations.Test;
import org.openecomp.portalsdk.core.conf.AppConfig;
import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
import org.openecomp.portalsdk.core.util.SystemProperties;
@@ -61,6 +61,7 @@ import org.openecomp.portalsdk.core.util.CacheManager;
@WebAppConfiguration
@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {MockAppConfig.class})
@ActiveProfiles(value="test")
+@Test(enabled=false)
public class MockApplicationContextTestSuite {
/** The wac. */
diff --git a/vid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java b/vid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java
index ce3e6ba5f..85c550d4c 100755
--- a/vid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java
+++ b/vid-app-common/src/test/java/org/openecomp/fusionapp/service/ProfileServiceTest.java
@@ -36,6 +36,7 @@ import org.openecomp.portalsdk.core.service.UserProfileService;
/**
* The Class ProfileServiceTest.
*/
+
public class ProfileServiceTest extends MockApplicationContextTestSuite {
/** The service. */
@@ -51,14 +52,13 @@ public class ProfileServiceTest extends MockApplicationContextTestSuite {
*/
@Test
public void testFindAll() {
-
- try {
- List<Profile> profiles = service.findAll();
- Assert.assertTrue(profiles.size() > 0);
- }
- catch (Exception e) {
- //TODO: this is only to make maven to not complaint
- return;
+
+ List<Profile> profiles;
+ try {
+ profiles = service.findAll();
+ Assert.assertTrue(profiles.size() > 0);
+ } catch (Exception e) {
+ Assert.assertTrue(false);
}
}
diff --git a/vid-app-common/src/test/resources/asdc.properties b/vid-app-common/src/test/resources/asdc.properties
new file mode 100644
index 000000000..8352ff213
--- /dev/null
+++ b/vid-app-common/src/test/resources/asdc.properties
@@ -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
index 000000000..d9c469a15
--- /dev/null
+++ b/vid-app-common/src/test/resources/sampleTosca.csar
Binary files 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
index 000000000..bd1a01935
--- /dev/null
+++ b/vid-app-common/src/test/resources/vf-csar.JSON
@@ -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
index 000000000..ce1f1b79f
--- /dev/null
+++ b/vid-app-common/src/test/resources/vl-csar.JSON
@@ -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": {
+ }
+}