aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-08-15 21:40:16 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-08-15 21:43:44 -0400
commitfa36daa658a50d9ca2e57cae649d63c0e9e2882a (patch)
tree09bec4b384664e59c5e3671eec5f17f8c68e8a02 /mso-catalog-db/src/main
parente536a1035d0f224de32f76a1226c772b8f8d7c01 (diff)
Initial commit of validation framework to APIH
Move ListenerRunner to common location Adjust request params name, update junit tests Update validations to work properly Properly escape period for the string split Issue-ID: SO-2232 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia468cf7062cccf30e28afeb7a5cddc37ceb2e002
Diffstat (limited to 'mso-catalog-db/src/main')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java16
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java105
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Cvnfc.java136
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java13
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java19
6 files changed, 285 insertions, 6 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
index 36c9251d59..aec1c7fb22 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
@@ -23,9 +23,7 @@ package org.onap.so.db.catalog.beans;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -34,7 +32,6 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
@@ -124,6 +121,9 @@ public class VnfResourceCustomization implements Serializable {
@Column(name = "VNFCINSTANCEGROUP_ORDER")
private String vnfcInstanceGroupOrder;
+ @Column(name = "NF_DATA_VALID")
+ private Boolean nfDataValid;
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof VnfResourceCustomization)) {
@@ -336,4 +336,14 @@ public class VnfResourceCustomization implements Serializable {
public void setVnfcInstanceGroupOrder(String vnfcInstanceGroupOrder) {
this.vnfcInstanceGroupOrder = vnfcInstanceGroupOrder;
}
+
+ public Boolean getNfDataValid() {
+ return nfDataValid;
+ }
+
+ public void setNfDataValid(Boolean nfDataValid) {
+ this.nfDataValid = nfDataValid;
+ }
+
+
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index a959f2f5a1..23539b074d 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -27,7 +27,9 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.persistence.EntityNotFoundException;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
+import org.apache.http.HttpStatus;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
@@ -67,13 +69,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
+import com.google.common.base.Strings;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
@@ -888,6 +895,90 @@ public class CatalogDbClient {
"Unable to find CvnfcConfigurationCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid);
}
+ public org.onap.so.rest.catalog.beans.Service getServiceModelInformation(String serviceModelUUID, String depth) {
+ if (Strings.isNullOrEmpty(serviceModelUUID)) {
+ throw new EntityNotFoundException("Service Model UUID passed as Null or Empty String");
+ }
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate.exchange(
+ UriComponentsBuilder.fromUriString(endpoint + "/ecomp/mso/catalog/v1/services/" + serviceModelUUID)
+ .queryParam("depth", depth).build().encode().toString(),
+ HttpMethod.GET, entity, org.onap.so.rest.catalog.beans.Service.class).getBody();
+ } catch (HttpClientErrorException e) {
+ logger.warn("Entity Not found in DLP", e);
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException("Unable to find Service with ServiceModelUUID:" + serviceModelUUID);
+ }
+ throw e;
+ }
+ }
+
+ public List<org.onap.so.rest.catalog.beans.Service> getServices() {
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate
+ .exchange(
+ UriComponentsBuilder.fromUriString(endpoint + "/ecomp/mso/catalog/v1/services").build()
+ .encode().toString(),
+ HttpMethod.GET, entity,
+ new ParameterizedTypeReference<List<org.onap.so.rest.catalog.beans.Service>>() {})
+ .getBody();
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling catalog database", e);
+ throw e;
+ }
+ }
+
+ public org.onap.so.rest.catalog.beans.Vnf getVnfModelInformation(String serviceModelUUID,
+ String vnfCustomizationUUID, String depth) {
+ if (Strings.isNullOrEmpty(serviceModelUUID)) {
+ throw new EntityNotFoundException("Service Model UUID passed as Null or Empty String");
+ }
+ if (Strings.isNullOrEmpty(vnfCustomizationUUID)) {
+ throw new EntityNotFoundException("Vnf Customization UUID passed as Null or Empty String");
+ }
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate
+ .exchange(
+ UriComponentsBuilder
+ .fromUriString(endpoint + "/ecomp/mso/catalog/v1/services/" + serviceModelUUID
+ + "/vnfs/" + vnfCustomizationUUID)
+ .queryParam("depth", depth).build().encode().toString(),
+ HttpMethod.GET, entity, org.onap.so.rest.catalog.beans.Vnf.class)
+ .getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(
+ "Unable to find Vnf with Vnf Customization UUID:" + vnfCustomizationUUID);
+ }
+ throw e;
+ }
+ }
+
+ public void updateVnf(String serviceModelUUID, org.onap.so.rest.catalog.beans.Vnf vnf) {
+ if (vnf == null) {
+ throw new EntityNotFoundException("Vnf passed as null");
+ }
+ try {
+ HttpHeaders headers = getHttpHeaders();
+ HttpEntity<org.onap.so.rest.catalog.beans.Vnf> entity = new HttpEntity<>(vnf, headers);
+
+ restTemplate.exchange(
+ UriComponentsBuilder.fromUriString(endpoint + "/ecomp/mso/catalog/v1/services/" + serviceModelUUID
+ + "/vnfs/" + vnf.getModelCustomizationId()).build().encode().toString(),
+ HttpMethod.PUT, entity, org.onap.so.rest.catalog.beans.Vnf.class).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ throw new EntityNotFoundException(
+ "Unable to find Vnf with Vnf Customization UUID:" + vnf.getModelCustomizationId());
+ }
+ throw e;
+ }
+ }
+
+
public Workflow findWorkflowByArtifactUUID(String artifactUUID) {
return this.getSingleResource(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByArtifactUUID)
.queryParam(ARTIFACT_UUID, artifactUUID).build().toString()));
@@ -910,4 +1001,18 @@ public class CatalogDbClient {
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
+
+ private HttpHeaders getHttpHeaders() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, msoAdaptersAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ headers.set(LogConstants.TARGET_ENTITY_HEADER, TARGET_ENTITY);
+ return headers;
+ }
+
+ private HttpEntity<?> getHttpEntity() {
+ HttpHeaders headers = getHttpHeaders();
+ return new HttpEntity<>(headers);
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Cvnfc.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Cvnfc.java
new file mode 100644
index 0000000000..e22f366ddf
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Cvnfc.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.onap.so.rest.catalog.beans;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+@JsonInclude(Include.NON_DEFAULT)
+public class Cvnfc {
+
+ private String modelCustomizationId;
+ private String modelInstanceName;
+ private String modelVersionId;
+ private String modelInvariantId;
+ private String modelVersion;
+ private String modelName;
+ private String description;
+ private String nfcFunction;
+ private String nfcNamingCode;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
+ private Date created;
+
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
+ }
+
+ public String getModelInstanceName() {
+ return modelInstanceName;
+ }
+
+ public void setModelInstanceName(String modelInstanceName) {
+ this.modelInstanceName = modelInstanceName;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
+ }
+
+ public String getModelVersion() {
+ return modelVersion;
+ }
+
+ public void setModelVersion(String modelVersion) {
+ this.modelVersion = modelVersion;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getNfcFunction() {
+ return nfcFunction;
+ }
+
+ public void setNfcFunction(String nfcFunction) {
+ this.nfcFunction = nfcFunction;
+ }
+
+ public String getNfcNamingCode() {
+ return nfcNamingCode;
+ }
+
+ public void setNfcNamingCode(String nfcNamingCode) {
+ this.nfcNamingCode = nfcNamingCode;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("modelCustomizationId", modelCustomizationId)
+ .append("modelInstanceName", modelInstanceName).append("modelVersionId", modelVersionId)
+ .append("modelInvariantId", modelInvariantId).append("modelVersion", modelVersion)
+ .append("modelName", modelName).append("description", description).append("nfcFunction", nfcFunction)
+ .append("nfcNamingCode", nfcNamingCode).append("created", created).toString();
+ }
+
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java
index 1620058e1e..11089046fd 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Service.java
@@ -24,6 +24,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -40,6 +41,7 @@ public class Service implements Serializable {
private String modelInvariantId;
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private Date created;
private String modelVersion;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java
index 8e18f94faf..f2a2c77aca 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/VfModule.java
@@ -20,9 +20,11 @@
package org.onap.so.rest.catalog.beans;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.onap.so.db.catalog.beans.HeatEnvironment;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -37,6 +39,7 @@ public class VfModule {
private String description;
private Boolean isBase;
private HeatTemplate heatTemplate;
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private Date created;
private List<HeatFile> heatFile;
@@ -50,9 +53,7 @@ public class VfModule {
private HeatEnvironment heatEnv;
private Boolean isVolumeGroup;
-
- // Add in cvnfcCustomization
-
+ private List<Cvnfc> vnfc = new ArrayList<>();
public String getModelName() {
@@ -191,6 +192,12 @@ public class VfModule {
this.isVolumeGroup = isVolumeGroup;
}
+ public List<Cvnfc> getVnfc() {
+ return vnfc;
+ }
+ public void setVnfc(List<Cvnfc> vnfc) {
+ this.vnfc = vnfc;
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java
index 40d701c3c5..febf69baf1 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/rest/catalog/beans/Vnf.java
@@ -47,12 +47,14 @@ public class Vnf implements Serializable {
private String nfFunction;
private String nfRole;
private String nfNamingCode;
+ private String nfType;
private String multiStageDesign;
private String orchestrationMode;
private String cloudVersionMin;
private String cloudVersionMax;
private String category;
private String subCategory;
+ private Boolean nfDataValid;
private List<VfModule> vfModule = new ArrayList<>();
public List<VfModule> getVfModule() {
@@ -215,4 +217,21 @@ public class Vnf implements Serializable {
public void setMultiStageDesign(String multiStepDesign) {
this.multiStageDesign = multiStepDesign;
}
+
+ public String getNfType() {
+ return nfType;
+ }
+
+ public void setNfType(String nfType) {
+ this.nfType = nfType;
+ }
+
+ public Boolean getNfDataValid() {
+ return nfDataValid;
+ }
+
+ public void setNfDataValid(Boolean nfDataValid) {
+ this.nfDataValid = nfDataValid;
+ }
+
}