From 6ad41e3ccd398a2721f41ad61c80b7bb03f7d127 Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Mon, 31 Dec 2018 17:21:27 +0200 Subject: Merge from ECOMP's repository Main Features -------------- - Async-Instantiation jobs mechanism major update; still WIP (package `org.onap.vid.job`) - New features in View/Edit: Activate fabric configuration; show related networks; soft delete - Support AAI service-tree traversal (`AAIServiceTree`) - In-memory cache for SDC models and certain A&AI queries (`CacheProviderWithLoadingCache`) - Upgrade TOSCA Parser and add parsing options; fix malformed TOSCA models - Resolve Cloud-Owner values for MSO - Pass X-ONAP headers to MSO Infrastructure -------------- - Remove codehaus' jackson mapper; use soley fasterxml 2.9.7 - Surefire invokes both TestNG and JUnit tests - Support Kotlin source files - AaiController2 which handles errors in a "Spring manner" - Inline generated-sources and remove jsonschema2pojo Quality -------- - Cumulative bug fixes (A&AI API, UI timeouts, and many more) - Many Sonar issues cleaned-up - Some unused classes removed - Minor changes in vid-automation project, allowing some API verification to run Hard Merges ------------ - HTTP Clients (MSO, A&AI, WebConfig, OutgoingRequestHeadersTest) - Moved `package org.onap.vid.controllers` to `controller`, without plural -- just to keep semantic sync with ECOMP. Reference commit in ECOMP: 3d1141625 Issue-ID: VID-378 Change-Id: I9c8d1e74caa41815891d441fc0760bb5f29c5788 Signed-off-by: Ittay Stern --- .../src/main/java/org/onap/vid/model/Action.java | 15 ++ .../src/main/java/org/onap/vid/model/CR.java | 2 +- .../java/org/onap/vid/model/CommandProperty.java | 5 +- .../src/main/java/org/onap/vid/model/Group.java | 21 ++- .../java/org/onap/vid/model/GroupProperties.java | 9 + .../java/org/onap/vid/model/JobAuditStatus.java | 75 +++++++- .../main/java/org/onap/vid/model/MinimalNode.kt | 8 + .../java/org/onap/vid/model/ModelConstants.java | 12 +- .../main/java/org/onap/vid/model/NameCounter.java | 2 +- .../main/java/org/onap/vid/model/NewNetwork.java | 2 - .../src/main/java/org/onap/vid/model/NewNode.java | 18 +- .../java/org/onap/vid/model/NewServiceModel.java | 91 +++------- .../src/main/java/org/onap/vid/model/NewVNF.java | 41 +---- .../src/main/java/org/onap/vid/model/Node.java | 44 ++--- .../org/onap/vid/model/PortMirroringConfig.java | 10 -- .../onap/vid/model/RequestReferencesContainer.java | 4 +- .../src/main/java/org/onap/vid/model/Resource.java | 28 --- .../main/java/org/onap/vid/model/ResourceGroup.kt | 13 ++ .../src/main/java/org/onap/vid/model/Service.java | 14 +- .../main/java/org/onap/vid/model/ServiceInfo.java | 75 +++++++- .../main/java/org/onap/vid/model/ServiceModel.java | 41 +++-- .../main/java/org/onap/vid/model/ServiceProxy.java | 11 -- .../java/org/onap/vid/model/SoftDeleteRequest.java | 42 +++++ .../main/java/org/onap/vid/model/Subscriber.java | 2 +- .../java/org/onap/vid/model/SubscriberList.java | 2 - .../src/main/java/org/onap/vid/model/VNF.java | 29 +--- .../src/main/java/org/onap/vid/model/VfModule.java | 14 +- .../src/main/java/org/onap/vid/model/VidNotions.kt | 34 ++++ .../org/onap/vid/model/aaiTree/AAITreeNode.java | 178 +++++++++++++++++++ .../org/onap/vid/model/aaiTree/AbstractNode.java | 53 ++++++ .../onap/vid/model/aaiTree/FailureAAITreeNode.java | 31 ++++ .../java/org/onap/vid/model/aaiTree/Network.java | 20 +++ .../main/java/org/onap/vid/model/aaiTree/Node.java | 139 +++++++++++++++ .../org/onap/vid/model/aaiTree/RelatedVnf.java | 52 ++++++ .../onap/vid/model/aaiTree/ServiceInstance.java | 193 +++++++++++++++++++++ .../java/org/onap/vid/model/aaiTree/VfModule.java | 41 +++++ .../main/java/org/onap/vid/model/aaiTree/Vnf.java | 54 ++++++ .../java/org/onap/vid/model/aaiTree/VnfGroup.java | 52 ++++++ .../vid/model/probes/ExternalComponentStatus.java | 2 +- .../onap/vid/model/probes/HttpRequestMetadata.java | 61 ++++++- .../model/serviceInstantiation/BaseResource.java | 115 ++++++++++++ .../model/serviceInstantiation/InstanceGroup.java | 22 +++ .../vid/model/serviceInstantiation/Network.java | 74 ++++++++ .../serviceInstantiation/ServiceInstantiation.java | 90 +++++----- .../vid/model/serviceInstantiation/VfModule.java | 60 ++++--- .../onap/vid/model/serviceInstantiation/Vnf.java | 81 +++------ 46 files changed, 1572 insertions(+), 410 deletions(-) create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/Action.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/MinimalNode.kt delete mode 100644 vid-app-common/src/main/java/org/onap/vid/model/Resource.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/ResourceGroup.kt create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/SoftDeleteRequest.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/FailureAAITreeNode.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java create mode 100644 vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java (limited to 'vid-app-common/src/main/java/org/onap/vid/model') diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Action.java b/vid-app-common/src/main/java/org/onap/vid/model/Action.java new file mode 100644 index 000000000..32ee01fb4 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/Action.java @@ -0,0 +1,15 @@ +package org.onap.vid.model; + +public enum Action { + Create(ServiceInfo.ServiceAction.INSTANTIATE), + Delete(ServiceInfo.ServiceAction.DELETE), + None(ServiceInfo.ServiceAction.UPDATE); + + private final ServiceInfo.ServiceAction serviceAction; + Action(ServiceInfo.ServiceAction serviceAction){ + this.serviceAction = serviceAction; + } + public ServiceInfo.ServiceAction getServiceAction() { + return serviceAction; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CR.java b/vid-app-common/src/main/java/org/onap/vid/model/CR.java index f8c046e7f..d8ecd64be 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/CR.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/CR.java @@ -17,7 +17,7 @@ public class CR extends Node{ private String customizationUUID; - private Map networksCollection = new HashMap(); + private Map networksCollection = new HashMap<>(); diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java b/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java index 4f5ee173f..e398c5428 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/CommandProperty.java @@ -20,8 +20,6 @@ package org.onap.vid.model; -import java.util.Map; - /** * The Class Command Property. */ @@ -87,7 +85,6 @@ public class CommandProperty { } public String toString () { - String result = "displayName=" + displayName + " command=" + command + " inputName" + inputName; - return result; + return "displayName=" + displayName + " command=" + command + " inputName" + inputName; } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Group.java b/vid-app-common/src/main/java/org/onap/vid/model/Group.java index 5f98341df..3da15879c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/Group.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/Group.java @@ -1,11 +1,13 @@ package org.onap.vid.model; import org.onap.vid.asdc.beans.tosca.Input; -import org.onap.vid.asdc.parser.ToscaParserImpl2; +import org.onap.vid.asdc.parser.ToscaParserImpl2.Constants; import java.util.Map; -public class Group { +import static org.onap.vid.asdc.parser.ToscaParserImpl2.isModuleTypeIsBaseObjectSafe; + +public class Group implements MinimalNode { /** The uuid. */ @@ -182,7 +184,11 @@ public class Group { protected static GroupProperties extractPropertiesForGroup(org.onap.vid.asdc.beans.tosca.Group group){ - String [] propertyKeys = {ToscaParserImpl2.Constants.MIN_VF_MODULE_INSTANCES, ToscaParserImpl2.Constants.MAX_VF_MODULE_INSTANCES, ToscaParserImpl2.Constants.INITIAL_COUNT}; + String [] propertyKeys = { + Constants.MIN_VF_MODULE_INSTANCES, + Constants.MAX_VF_MODULE_INSTANCES, + Constants.INITIAL_COUNT, + }; GroupProperties groupProperties = new GroupProperties(); for(String propertyKey : propertyKeys){ @@ -191,18 +197,21 @@ public class Group { setInGroupProperties(groupProperties, propertyKey, (Integer) val); } } + + groupProperties.setBaseModule(isModuleTypeIsBaseObjectSafe(group.getProperties().get(Constants.VF_MODULE_TYPE))); + return groupProperties; } private static void setInGroupProperties(GroupProperties groupProperties, String propertyKey, Integer propertyValue){ switch (propertyKey) { - case ToscaParserImpl2.Constants.MIN_VF_MODULE_INSTANCES: + case Constants.MIN_VF_MODULE_INSTANCES: groupProperties.setMinCountInstances(propertyValue); break; - case ToscaParserImpl2.Constants.MAX_VF_MODULE_INSTANCES: + case Constants.MAX_VF_MODULE_INSTANCES: groupProperties.setMaxCountInstances(propertyValue); break; - case ToscaParserImpl2.Constants.INITIAL_COUNT: + case Constants.INITIAL_COUNT: groupProperties.setInitialCount(propertyValue); break; default: diff --git a/vid-app-common/src/main/java/org/onap/vid/model/GroupProperties.java b/vid-app-common/src/main/java/org/onap/vid/model/GroupProperties.java index c7ca60069..d8a57e464 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/GroupProperties.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/GroupProperties.java @@ -5,6 +5,7 @@ public class GroupProperties { private Integer maxCountInstances; private Integer initialCount; private String vfModuleLabel; + private boolean baseModule = false; public String getVfModuleLabel() { return vfModuleLabel; @@ -30,6 +31,14 @@ public class GroupProperties { this.maxCountInstances = maxCountInstances; } + public boolean getBaseModule() { + return baseModule; + } + + public void setBaseModule(boolean baseModule) { + this.baseModule = baseModule; + } + public Integer getInitialCount() { return initialCount; } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java index 614267990..3da41a419 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/JobAuditStatus.java @@ -1,20 +1,36 @@ package org.onap.vid.model; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.SelectBeforeUpdate; import org.hibernate.annotations.Type; -import org.onap.vid.job.Job.JobStatus; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.vid.job.Job.JobStatus; import javax.persistence.*; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; +import java.util.TimeZone; import java.util.UUID; +/* + The following 2 annotations let hibernate to update only fields that actually have been changed. + DynamicUpdate tell hibernate to update only dirty fields. + SelectBeforeUpdate is needed since during update the entity is detached (get and update are in different sessions) + */ +@DynamicUpdate() +@SelectBeforeUpdate() @Entity @Table(name = "vid_job_audit_status") public class JobAuditStatus extends VidBaseEntity { + public static final int MAX_ADDITIONAL_INFO_LENGTH = 2000; static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JobAuditStatus.class); + private static final String defaultFormat = "E, dd MMM yyyy HH:mm:ss z"; public JobAuditStatus(){} @@ -32,7 +48,7 @@ public class JobAuditStatus extends VidBaseEntity { public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo) { this(jobId, jobStatus, source); this.requestId = requestId; - this.additionalInfo = additionalInfo; + setAdditionalInfo(additionalInfo); } public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Date date){ @@ -40,6 +56,37 @@ public class JobAuditStatus extends VidBaseEntity { this.created = date; } + public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo) { + this.instanceName = instanceName; + this.jobStatus = jobStatus; + this.requestId = requestId; + this.additionalInfo = additionalInfo; + + } + + public JobAuditStatus(String instanceName, String jobStatus, UUID requestId, String additionalInfo, String date, String instanceType) { + this(instanceName, jobStatus, requestId, additionalInfo); + this.created = dateStringToDate(date); + this.instanceType = instanceType; + } + + + private Date dateStringToDate(String dateAsString){ + if (StringUtils.isEmpty(dateAsString)) { + return null; + } + + DateFormat format = new SimpleDateFormat(defaultFormat); + format.setTimeZone(TimeZone.getTimeZone("GMT")); + Date date = null ; + try { + date = format.parse(dateAsString); + } catch (ParseException e) { + logger.error("There was an error to parse the string "+ dateAsString +" to date ", e.getMessage()); + } + return date; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -74,6 +121,8 @@ public class JobAuditStatus extends VidBaseEntity { } private UUID jobId; + private String instanceName; + private String instanceType; private String jobStatus; private SourceStatus source; private UUID requestId; @@ -128,13 +177,31 @@ public class JobAuditStatus extends VidBaseEntity { this.requestId = requestId; } - @Column(name = "ADDITIONAL_INFO") + @Column(name = "ADDITIONAL_INFO", columnDefinition = "VARCHAR(2000)") public String getAdditionalInfo() { return additionalInfo; } public void setAdditionalInfo(String additionalInfo) { - this.additionalInfo = additionalInfo; + this.additionalInfo = StringUtils.substring(additionalInfo, 0, MAX_ADDITIONAL_INFO_LENGTH); + } + + @Transient + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + @Transient + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; } @Transient diff --git a/vid-app-common/src/main/java/org/onap/vid/model/MinimalNode.kt b/vid-app-common/src/main/java/org/onap/vid/model/MinimalNode.kt new file mode 100644 index 000000000..1b44e6523 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/MinimalNode.kt @@ -0,0 +1,8 @@ +package org.onap.vid.model + +interface MinimalNode { + val invariantUuid: String + val uuid: String + val version: String + val name: String +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java b/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java index 9ceeb807e..4ee473d1b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/ModelConstants.java @@ -25,20 +25,20 @@ package org.onap.vid.model; public class ModelConstants { /** The Constant GET_INPUT_TAG. */ - public final static String GET_INPUT_TAG = "get_input"; + public static final String GET_INPUT_TAG = "get_input"; public static final String ASDC_MODEL_NAMESPACE = "asdc.model.namespace"; public static final String ASDC_SVC_API_PATH = "sdc.svc.api.path"; public static final String ASDC_RESOURCE_API_PATH = "sdc.resource.api.path"; - public static final String DEFAULT_ASDC_MODEL_NAMESPACE = "org.onap."; + public static final String DEFAULT_ASDC_MODEL_NAMESPACE = "org.openecomp."; public static final String DEFAULT_ASDC_SVC_API_PATH = "sdc/v1/catalog/services"; public static final String DEFAULT_ASDC_RESOURCE_API_PATH = "sdc/v1/catalog/resources"; - public final static String VF_MODULE = "groups.VfModule"; - public final static String VNF = "resource.vf"; - public final static String NETWORK = "resource.vl"; + public static final String VF_MODULE = "groups.VfModule"; + public static final String VNF = "resource.vf"; + public static final String NETWORK = "resource.vl"; - public final static String ROLE_DELIMITER = "___"; + public static final String ROLE_DELIMITER = "___"; } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NameCounter.java b/vid-app-common/src/main/java/org/onap/vid/model/NameCounter.java index aae39e440..29f5e30a0 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/NameCounter.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/NameCounter.java @@ -18,7 +18,7 @@ public class NameCounter { public NameCounter(String name) { this.name = name; - this.counter = 1; + this.counter = 0; } @Id diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java b/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java index 9f1ffd356..8e130a58c 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/NewNetwork.java @@ -20,8 +20,6 @@ package org.onap.vid.model; -import org.onap.vid.asdc.beans.tosca.NodeTemplate; - /** * The Class Network. */ diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java b/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java index 394f7b96c..6a185555b 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/NewNode.java @@ -1,22 +1,12 @@ package org.onap.vid.model; -import java.text.DateFormat; -import java.text.SimpleDateFormat; +import org.onap.vid.asdc.beans.tosca.Input; + import java.util.HashMap; import java.util.Map; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.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; @@ -47,8 +37,8 @@ public class NewNode { * Instantiates a new node. */ public NewNode() { - this.commands = new HashMap(); - this.properties = new HashMap(); + this.commands = new HashMap<>(); + this.properties = new HashMap<>(); } /** diff --git a/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java index e55ba4a4e..1cc6a02f1 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/NewServiceModel.java @@ -20,27 +20,18 @@ package org.onap.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.onap.vid.asdc.beans.tosca.Group; import org.onap.vid.asdc.beans.tosca.ToscaModel; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.properties.VidProperties; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; /** * 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; @@ -63,12 +54,15 @@ public class NewServiceModel { private Map configurations; + private Map fabricConfigurations; + private Map serviceProxies; private Map pnfs; private Map collectionResource; + private Map vnfGroups; /** * Instantiates a new service model. @@ -189,6 +183,14 @@ public class NewServiceModel { this.collectionResource = collectionResource; } + public Map getFabricConfigurations() { + return fabricConfigurations; + } + + public void setFabricConfigurations(Map fabricConfigurations) { + this.fabricConfigurations = fabricConfigurations; + } + /** * Extract service. * @@ -211,15 +213,14 @@ public class NewServiceModel { //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 vfModules = new HashMap (); - final Map volumeGroups = new HashMap (); + final Map vfModules = new HashMap<> (); + final Map volumeGroups = new HashMap<> (); String asdcModelNamespace = VidProperties.getAsdcModelNamespace(); String vfModuleTag = asdcModelNamespace + ModelConstants.VF_MODULE; @@ -243,57 +244,15 @@ public class NewServiceModel { serviceModel.setVolumeGroups (volumeGroups); } + + public Map getVnfGroups() { + return vnfGroups; + } + + public void setVnfGroups(Map vnfGroups) { + this.vnfGroups = vnfGroups; + } /** * 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 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 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/onap/vid/model/NewVNF.java b/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java index dba6bdc5d..1b977a944 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/NewVNF.java @@ -1,33 +1,22 @@ package org.onap.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.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.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("[\\.\\-]+"); + static final Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+"); /** The model customization name. */ private String modelCustomizationName; /** The vf modules. */ - private Map vfModules = new HashMap(); + private Map vfModules = new HashMap<>(); /** The volume groups. */ - private Map volumeGroups = new HashMap(); + private Map volumeGroups = new HashMap<>(); /** * Instantiates a newvnf. @@ -96,28 +85,6 @@ public class NewVNF extends NewNode { * @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); - } - + return VNF.normalizeName(originalName); } - } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Node.java b/vid-app-common/src/main/java/org/onap/vid/model/Node.java index 3b7abd39b..64e4cc0b8 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/Node.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/Node.java @@ -20,51 +20,44 @@ package org.onap.vid.model; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.asdc.beans.tosca.Input; import org.onap.vid.asdc.beans.tosca.NodeTemplate; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; /** * The Class Node. */ -public class Node { +public class Node implements MinimalNode { /** 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 inputs = new HashMap<>(); - + /** The get_input or other constructs from node template properties. */ private Map commands; - + /** The get_input or other constructs from node template properties. */ private Map properties; @@ -74,8 +67,8 @@ public class Node { * Instantiates a new node. */ public Node() { - this.commands = new HashMap(); - this.properties = new HashMap(); + this.commands = new HashMap<>(); + this.properties = new HashMap<>(); } /** @@ -253,7 +246,6 @@ public class Node { /** * Extract node. * - * @param modelCustomizationName the model customization name * @param nodeTemplate the node template * @return the node */ @@ -272,14 +264,14 @@ public class Node { try { // nodeTemplate.getProperties() map of String->Object for (Entry entrySet : nodeTemplate.getProperties().entrySet()) { - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " node template property: " + entrySet.getKey()); + LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " node template property: " + entrySet.getKey()); if ( entrySet.getValue() != null ) { readStringAndCommandsProperties(entrySet); } } } catch ( Exception e ) { - LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse node properties: e=" + + LOG.error(EELFLoggerDelegate.errorLogger, methodName + " Unable to parse node properties: e=" + e.toString()); } } @@ -287,7 +279,7 @@ public class Node { private void readStringAndCommandsProperties(Entry entrySet) { String key = entrySet.getKey(); String methodName = "readStringAndCommandsProperties"; - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " property: " + + LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " property: " + key + "=" + entrySet.getValue()); Class c = entrySet.getValue().getClass(); if ( c.getName().equalsIgnoreCase(String.class.getName())) { diff --git a/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java b/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java index 393c34259..6dc11ec63 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/PortMirroringConfig.java @@ -1,22 +1,12 @@ package org.onap.vid.model; import com.fasterxml.jackson.annotation.JsonIgnore; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.RequirementAssignments; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.List; public class PortMirroringConfig extends Node { - /** The Constant LOG. */ - private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(PortMirroringConfig.class); - - /** The Constant dateFormat. */ - final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - /** The model customization name. */ private String modelCustomizationName; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java index 9c12a52a6..c40dffec8 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/RequestReferencesContainer.java @@ -2,7 +2,7 @@ package org.onap.vid.model; import com.fasterxml.jackson.annotation.*; import com.google.common.base.MoreObjects; -import org.onap.vid.domain.mso.RequestReferences; +import org.onap.vid.mso.model.RequestReferences; import java.util.HashMap; import java.util.Map; @@ -12,7 +12,7 @@ public class RequestReferencesContainer { private final RequestReferences requestReferences; @JsonIgnore - private Map additionalProperties = new HashMap(); + private Map additionalProperties = new HashMap<>(); @JsonAnyGetter public Map getAdditionalProperties() { diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Resource.java b/vid-app-common/src/main/java/org/onap/vid/model/Resource.java deleted file mode 100644 index 184f9ee6e..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/model/Resource.java +++ /dev/null @@ -1,28 +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.onap.vid.model; - -/** - * The Class Resource. - */ -public class Resource { - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ResourceGroup.kt b/vid-app-common/src/main/java/org/onap/vid/model/ResourceGroup.kt new file mode 100644 index 000000000..67a766e21 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/ResourceGroup.kt @@ -0,0 +1,13 @@ +package org.onap.vid.model + +data class ResourceGroup ( + + val type: String, + override val invariantUuid: String, + override val uuid: String, + override val version: String, + override val name: String, + val modelCustomizationName: String, + val properties: Map, + val members: Map +) : MinimalNode diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Service.java b/vid-app-common/src/main/java/org/onap/vid/model/Service.java index d00f58f04..27a52e6fb 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/Service.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/Service.java @@ -20,6 +20,7 @@ package org.onap.vid.model; +import com.fasterxml.jackson.annotation.JsonInclude; import org.onap.vid.asdc.beans.tosca.Input; import java.util.Map; @@ -65,7 +66,9 @@ public class Service { /** The inputs. */ private Map inputs; - + + private VidNotions vidNotions; + /** * Gets the uuid. * @@ -265,4 +268,13 @@ public class Service { public void setServiceRole(String serviceRole) { this.serviceRole = serviceRole; } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public VidNotions getVidNotions() { + return vidNotions; + } + + public void setVidNotions(VidNotions vidNotions) { + this.vidNotions = vidNotions; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java index 4f04adf51..7f10f8a14 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceInfo.java @@ -1,9 +1,12 @@ package org.onap.vid.model; + import com.fasterxml.jackson.annotation.JsonProperty; + import org.hibernate.annotations.DynamicUpdate; + import org.hibernate.annotations.SelectBeforeUpdate; import org.hibernate.annotations.Type; - import org.onap.vid.job.Job; import org.onap.portalsdk.core.domain.support.DomainVo; + import org.onap.vid.job.Job; import javax.persistence.*; import java.io.Serializable; @@ -12,10 +15,23 @@ import java.util.Set; import java.util.UUID; +/* + The following 2 annotations let hibernate to update only fields that actually have been changed. + DynamicUpdate tell hibernate to update only dirty fields. + SelectBeforeUpdate is needed since during update the entity is detached (get and update are in different sessions) +*/ +@DynamicUpdate() +@SelectBeforeUpdate() @Entity @Table(name = "vid_service_info") public class ServiceInfo extends DomainVo { + public enum ServiceAction { + INSTANTIATE, + DELETE, + UPDATE + } + public void setUserId(String userId) { this.userId = userId; } @@ -23,6 +39,8 @@ public class ServiceInfo extends DomainVo { private UUID jobId; private UUID templateId; private String userId; + private UUID msoRequestId; + private boolean aLaCarte; private Job.JobStatus jobStatus; private Date statusModifiedDate; private boolean hidden; @@ -39,19 +57,22 @@ public class ServiceInfo extends DomainVo { private String regionName; private String serviceType; private String subscriberName; + private String subscriberId; private String serviceInstanceId; private String serviceInstanceName; private String serviceModelId; private String serviceModelName; private String serviceModelVersion; private Date createdBulkDate; + private ServiceAction action; public ServiceInfo(){ } - public ServiceInfo(String userId, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate) { + public ServiceInfo(String userId, Boolean aLaCarte, Job.JobStatus jobStatus, boolean pause, UUID jobId, UUID templateId, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String subscriberId, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, Date createdBulkDate, ServiceAction action) { this.userId = userId; + this.aLaCarte = aLaCarte; this.jobStatus = jobStatus; this.jobId = jobId; this.templateId = templateId; @@ -67,12 +88,14 @@ public class ServiceInfo extends DomainVo { this.regionName = regionName; this.serviceType = serviceType; this.subscriberName = subscriberName; + this.subscriberId = subscriberId; this.serviceInstanceId = serviceInstanceId; this.serviceInstanceName = serviceInstanceName; this.serviceModelId = serviceModelId; this.serviceModelName = serviceModelName; this.serviceModelVersion = serviceModelVersion; this.createdBulkDate = createdBulkDate; + this.action = action; } @Column(name = "JOB_ID", columnDefinition = "CHAR(36)") @@ -92,6 +115,18 @@ public class ServiceInfo extends DomainVo { return userId; } + @Column(name = "MSO_REQUEST_ID", columnDefinition = "CHAR(36)") + @Type(type="org.hibernate.type.UUIDCharType") + public UUID getMsoRequestId() { + return msoRequestId; + } + + @Column(name="IS_A_LA_CARTE") + @JsonProperty("aLaCarte") + public boolean isALaCarte() { + return aLaCarte; + } + @Column(name="JOB_STATUS") @Enumerated(EnumType.STRING) public Job.JobStatus getJobStatus() { @@ -168,6 +203,11 @@ public class ServiceInfo extends DomainVo { return subscriberName; } + @Column(name="SUBSCRIBER_ID") + public String getSubscriberId() { + return subscriberId; + } + @Column(name="SERVICE_INSTANCE_ID") public String getServiceInstanceId() { return serviceInstanceId; @@ -203,6 +243,12 @@ public class ServiceInfo extends DomainVo { return deletedAt; } + @Column(name="ACTION") + @Enumerated(EnumType.STRING) + public ServiceAction getAction() { + return action; + } + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Override @@ -261,6 +307,14 @@ public class ServiceInfo extends DomainVo { this.templateId = templateId; } + public void setMsoRequestId(UUID requestId) { + this.msoRequestId = requestId; + } + + public void setALaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + } + public void setJobStatus(Job.JobStatus jobStatus) { this.jobStatus = jobStatus; } @@ -321,6 +375,10 @@ public class ServiceInfo extends DomainVo { this.subscriberName = subscriberName; } + public void setSubscriberId(String subscriberId) { + this.subscriberId = subscriberId; + } + public void setServiceInstanceId(String serviceInstanceId) { this.serviceInstanceId = serviceInstanceId; } @@ -349,6 +407,7 @@ public class ServiceInfo extends DomainVo { this.deletedAt = deletedAt; } + public void setAction(ServiceAction action) { this.action = action; } @Override public boolean equals(Object o) { @@ -357,10 +416,12 @@ public class ServiceInfo extends DomainVo { ServiceInfo that = (ServiceInfo) o; return isHidden() == that.isHidden() && isPause() == that.isPause() && + isALaCarte() == that.isALaCarte() && Objects.equals(getDeletedAt(), that.getDeletedAt()) && Objects.equals(getJobId(), that.getJobId()) && Objects.equals(getTemplateId(), that.getTemplateId()) && Objects.equals(getUserId(), that.getUserId()) && + Objects.equals(getMsoRequestId(), that.getMsoRequestId()) && getJobStatus() == that.getJobStatus() && Objects.equals(getStatusModifiedDate(), that.getStatusModifiedDate()) && Objects.equals(getOwningEntityId(), that.getOwningEntityId()) && @@ -374,22 +435,24 @@ public class ServiceInfo extends DomainVo { Objects.equals(getRegionName(), that.getRegionName()) && Objects.equals(getServiceType(), that.getServiceType()) && Objects.equals(getSubscriberName(), that.getSubscriberName()) && + Objects.equals(getSubscriberId(), that.getSubscriberId()) && Objects.equals(getServiceInstanceId(), that.getServiceInstanceId()) && Objects.equals(getServiceInstanceName(), that.getServiceInstanceName()) && Objects.equals(getServiceModelId(), that.getServiceModelId()) && Objects.equals(getServiceModelName(), that.getServiceModelName()) && Objects.equals(getServiceModelVersion(), that.getServiceModelVersion()) && - Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate()); + Objects.equals(getCreatedBulkDate(), that.getCreatedBulkDate()) && + Objects.equals(getAction(), that.getAction()); } @Override public int hashCode() { - return Objects.hash(getJobId(), getTemplateId(), getUserId(), getJobStatus(), getStatusModifiedDate(), + return Objects.hash(getJobId(), getTemplateId(), getUserId(), getMsoRequestId(), isALaCarte(), getJobStatus(), getStatusModifiedDate(), isHidden(), isPause(), getDeletedAt(), getOwningEntityId(), getOwningEntityName(), getProject(), getAicZoneId(), getAicZoneName(), getTenantId(), getTenantName(), getRegionId(), - getRegionName(), getServiceType(), getSubscriberName(), getServiceInstanceId(), + getRegionName(), getServiceType(), getSubscriberName(), getSubscriberId(), getServiceInstanceId(), getServiceInstanceName(), getServiceModelId(), getServiceModelName(), - getServiceModelVersion(), getCreatedBulkDate()); + getServiceModelVersion(), getCreatedBulkDate(), getAction()); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java index 53eb18c64..d82bd55aa 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java @@ -21,14 +21,11 @@ package org.onap.vid.model; import org.apache.commons.collections.MapUtils; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.asdc.beans.tosca.Group; import org.onap.vid.asdc.beans.tosca.ToscaModel; import org.onap.vid.properties.VidProperties; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -40,9 +37,7 @@ public class ServiceModel { /** The Constant LOG. */ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ServiceModel.class); - - /** The Constant dateFormat. */ - static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + /** The service. */ private Service service; @@ -54,10 +49,12 @@ public class ServiceModel { private Map collectionResource; - /** Port Mirroring Configuration node templates */ private Map configurations; + /** Fabric Configuration node templates */ + private Map fabricConfigurations; + /** Service Proxy Nodes */ private Map serviceProxies; @@ -74,6 +71,10 @@ public class ServiceModel { /** The pnfs. */ private Map pnfs; + + /** Resource groups of VF (VNF) type. */ + private Map vnfGroups; + /** * Instantiates a new service model. */ @@ -135,6 +136,10 @@ public class ServiceModel { return serviceProxies; } + public Map getVnfGroups() { + return vnfGroups; + } + /** * Sets the service. * @@ -221,6 +226,10 @@ public class ServiceModel { */ public void setPnfs(Map pnfs) {this.pnfs = pnfs;} + public void setVnfGroups(Map vnfGroups) { + this.vnfGroups = vnfGroups; + } + public Map getCollectionResource() { return collectionResource; } @@ -229,6 +238,14 @@ public class ServiceModel { this.collectionResource = collectionResource; } + public Map getFabricConfigurations() { + return fabricConfigurations; + } + + public void setFabricConfigurations(Map fabricConfigurations) { + this.fabricConfigurations = fabricConfigurations; + } + /** * Extract service. * @@ -288,7 +305,7 @@ public class ServiceModel { */ public void associateGroups() { String methodName = "associateGroups()"; - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " start"); + LOG.debug(EELFLoggerDelegate.debugLogger, 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; @@ -300,7 +317,7 @@ public class ServiceModel { vnfCustomizationName = vnfComponent.getValue().getModelCustomizationName(); normalizedVnfCustomizationName = VNF.normalizeName(vnfCustomizationName); - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + + LOG.debug(EELFLoggerDelegate.debugLogger, 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 @@ -309,7 +326,7 @@ public class ServiceModel { for (Entry vfModuleComponent : getVfModules().entrySet()) { vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName(); - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + + LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " VF Module customizationName=" + vfModuleCustomizationName ); if ( vfModuleCustomizationName.startsWith(normalizedVnfCustomizationName + ".." )) { handleCustomizationName(methodName, vnfCustomizationName, vfModuleCustomizationName, vnfComponent, vfModuleComponent); @@ -328,7 +345,7 @@ public class ServiceModel { tmpVnf = vnfComponent.getValue(); (tmpVnf.getVfModules()).put(vfModuleComponent.getKey(), vfModuleComponent.getValue()); - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + + LOG.debug(EELFLoggerDelegate.debugLogger, 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 diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java index 628f56020..362031b60 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceProxy.java @@ -1,18 +1,7 @@ package org.onap.vid.model; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; - public class ServiceProxy extends Node { - /** The Constant LOG. */ - private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(ServiceProxy.class); - - /** The Constant dateFormat. */ - final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); - private String sourceModelUuid; private String sourceModelInvariant; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SoftDeleteRequest.java b/vid-app-common/src/main/java/org/onap/vid/model/SoftDeleteRequest.java new file mode 100644 index 000000000..51c246be0 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/SoftDeleteRequest.java @@ -0,0 +1,42 @@ +package org.onap.vid.model; + +public class SoftDeleteRequest { + + private String tenantId; + + private String lcpCloudRegionId; + + private String userId; + + public SoftDeleteRequest() {} + + public SoftDeleteRequest(String tenantId, String lcpCloudRegionId, String userId) { + this.tenantId = tenantId; + this.lcpCloudRegionId = lcpCloudRegionId; + this.userId = userId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getLcpCloudRegionId() { + return lcpCloudRegionId; + } + + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java b/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java index 70711b804..f2a491639 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/Subscriber.java @@ -1,7 +1,7 @@ package org.onap.vid.model; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Created by Oren on 7/4/17. diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java b/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java index a08b585b5..8df9f81b3 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/SubscriberList.java @@ -1,7 +1,5 @@ package org.onap.vid.model; -import org.onap.portalsdk.core.web.support.UserUtils; - import java.util.List; /** diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VNF.java b/vid-app-common/src/main/java/org/onap/vid/model/VNF.java index 9da88870c..76e43d280 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/VNF.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/VNF.java @@ -20,42 +20,27 @@ package org.onap.vid.model; -import java.util.Map; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; +import org.onap.vid.asdc.beans.tosca.NodeTemplate; + import java.util.HashMap; -import java.util.Map.Entry; +import java.util.Map; import java.util.regex.Pattern; -import org.onap.vid.asdc.beans.tosca.NodeTemplate; -import org.onap.vid.controllers.VidController; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.vid.asdc.beans.tosca.Group; -import org.onap.vid.asdc.beans.tosca.Input; - /** * The Class VNF. */ public class VNF extends Node { - - /** 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("[\\.\\-]+"); + static final Pattern COMPONENT_INSTANCE_NAME_DELIMETER_PATTERN = Pattern.compile("[\\.\\-]+"); /** The model customization name. */ private String modelCustomizationName; /** The vf modules. */ - private Map vfModules = new HashMap(); + private Map vfModules = new HashMap<>(); /** The volume groups. */ - private Map volumeGroups = new HashMap(); + private Map volumeGroups = new HashMap<>(); private Map vfcInstanceGroups = new HashMap<>(); @@ -160,7 +145,7 @@ public class VNF extends Node { catch (Exception ex ) { return (normalizedName); } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if ( splitArr != null ) { for (String splitElement : splitArr) { sb.append(splitElement); diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java index ea30571a0..a0ea060f6 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/VfModule.java @@ -20,12 +20,8 @@ package org.onap.vid.model; -import org.onap.vid.asdc.beans.tosca.Group; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; +import org.onap.vid.asdc.beans.tosca.Group; /** * The Class VfModule. @@ -34,9 +30,7 @@ public class VfModule extends org.onap.vid.model.Group { /** The Constant LOG. */ private static final EELFLoggerDelegate LOG = EELFLoggerDelegate.getLogger(VfModule.class); - - /** The Constant dateFormat. */ - static final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS"); + public static final String VOLUME_GROUP = "volume_group"; /** The volume group allowed. */ @@ -88,7 +82,7 @@ public class VfModule extends org.onap.vid.model.Group { if (group.getProperties().get(VOLUME_GROUP) != null) { Class c = group.getProperties().get(VOLUME_GROUP).getClass(); - LOG.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + methodName + " class name=" + + LOG.debug(EELFLoggerDelegate.debugLogger, methodName + " class name=" + c.getName()); if ( c.getName().equalsIgnoreCase(Boolean.class.getName()) ) { @@ -101,7 +95,7 @@ public class VfModule extends org.onap.vid.model.Group { } } catch ( Exception e ) { - LOG.error(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + methodName + " Unable to parse VF Module from group: e=" + + LOG.error(EELFLoggerDelegate.errorLogger, methodName + " Unable to parse VF Module from group: e=" + e.toString()); } return vfModule; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt new file mode 100644 index 000000000..b49af085d --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/VidNotions.kt @@ -0,0 +1,34 @@ +package org.onap.vid.model + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonValue +import com.google.common.base.CaseFormat + +class VidNotions(@get:JsonInclude(JsonInclude.Include.NON_NULL) + val instantiationUI: InstantiationUI, val modelCategory: ModelCategory, val viewEditUI: InstantiationUI) { + enum class InstantiationUI { + NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS, + SERVICE_WITH_FABRIC_CONFIGURATION, + LEGACY, + SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de, + ANY_ALACARTE_NEW_UI, + MACRO_SERVICE, + SERVICE_WITH_VNF_GROUPING; + + @JsonValue + fun toLowerCamel(): String { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, this.name) + } + + } + + enum class ModelCategory { + @JsonProperty("5G Provider Network") + IS_5G_PROVIDER_NETWORK_MODEL, + @JsonProperty("5G Fabric Configuration") + IS_5G_FABRIC_CONFIGURATION_MODEL, + @JsonProperty("other") + OTHER + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java new file mode 100644 index 000000000..e6f822969 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java @@ -0,0 +1,178 @@ +package org.onap.vid.model.aaiTree; + +import org.apache.commons.lang3.StringUtils; + +import java.util.*; + +public class AAITreeNode { + + private String type; + private int uniqueNumber; + private String orchestrationStatus; + private String provStatus; + private Boolean inMaint = null; + private String modelVersionId; + private String modelCustomizationId; + private String modelInvariantId; + private String id; + private String name; + private String modelVersion; + private String modelName; + private String modelCustomizationName; + private final List children = Collections.synchronizedList(new LinkedList<>()); + private Map additionalProperties = new HashMap<>(); + private String keyInModel; + private AAITreeNode parent; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getUniqueNumber() { + return uniqueNumber; + } + + public void setUniqueNumber(int uniqueNumber) { + this.uniqueNumber = uniqueNumber; + } + + public String getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(String orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public String getProvStatus() { + return provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public Boolean getInMaint() { + return inMaint; + } + + public void setInMaint(Boolean inMaint) { + this.inMaint = inMaint; + } + + public String getModelVersionId() { + return modelVersionId; + } + + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + + public String getModelInvariantId() { + return modelInvariantId; + } + + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + 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 getModelCustomizationName() { + return modelCustomizationName; + } + + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + + public List getChildren() { + return children; + } + + public Map getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + public String getNodeKey() { + if (this.keyInModel != null) { + return this.keyInModel; + } + + return StringUtils.defaultIfEmpty(this.modelVersionId, "not provided"); + } + + public String getUniqueNodeKey() { + return getNodeKey() + ":" + String.format("%03d", this.uniqueNumber); + } + + public void setKeyInModel(String keyInModel) { + this.keyInModel = keyInModel; + } + + public String getKeyInModel() { + return keyInModel; + } + + public AAITreeNode getParent() { + return parent; + } + + public void setParent(AAITreeNode parent) { + this.parent = parent; + } + + public void addChildren(List children) { + for (AAITreeNode child : children) { + child.setParent(this); + } + + this.getChildren().addAll(children); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java new file mode 100644 index 000000000..86669e92f --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java @@ -0,0 +1,53 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.model.Action; +import org.onap.vid.mso.model.ModelInfo; + +public abstract class AbstractNode { + + protected final Action action; + protected String instanceName; + protected String instanceId; + protected String orchStatus; + protected String productFamilyId; + protected String lcpCloudRegionId; + protected String tenantId; + protected ModelInfo modelInfo; + + public AbstractNode() { + this.action = Action.None; + } + + public final Action getAction() { + return action; + } + + public final String getInstanceName() { + return instanceName; + } + + public final String getInstanceId() { + return instanceId; + } + + public final String getOrchStatus() { + return orchStatus; + } + + public final String getProductFamilyId() { + return productFamilyId; + } + + public final String getLcpCloudRegionId() { + return lcpCloudRegionId; + } + + public final String getTenantId() { + return tenantId; + } + + public final ModelInfo getModelInfo() { + return modelInfo; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/FailureAAITreeNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/FailureAAITreeNode.java new file mode 100644 index 000000000..e6234fca2 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/FailureAAITreeNode.java @@ -0,0 +1,31 @@ +package org.onap.vid.model.aaiTree; + +import org.apache.commons.proxy.Invoker; +import org.apache.commons.proxy.factory.javassist.JavassistProxyFactory; +import org.jetbrains.annotations.NotNull; +import org.onap.vid.exceptions.GenericUncheckedException; + +public class FailureAAITreeNode extends AAITreeNode { + + private static final Class[] classes = {AAITreeNode.class}; + private static final JavassistProxyFactory proxyFactory = new JavassistProxyFactory(); // can proxy a class without an interface + + private FailureAAITreeNode() { + // don't instantiate this class + } + + /* + Returns a new AAITreeNode instance that throws an exception when + invoking any of its methods + */ + public static AAITreeNode of(Exception failureException) { + return (AAITreeNode) proxyFactory.createInvokerProxy(exceptionThrower(failureException), classes); + } + + @NotNull + private static Invoker exceptionThrower(Exception exception) { + return (self, thisMethod, args) -> { + throw new GenericUncheckedException("AAI node fetching failed.", exception); + }; + } +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java new file mode 100644 index 000000000..959f741cd --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java @@ -0,0 +1,20 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; + +import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_TYPE; + +public class Network extends Node { + + public Network(AAITreeNode node) { + super(node, AAITreeConverter.ModelType.network); + } + + public static Network from(AAITreeNode node) { + Network network = new Network(node); + if (node.getAdditionalProperties().get(NETWORK_TYPE) != null) { + network.setInstanceType(node.getAdditionalProperties().get(NETWORK_TYPE).toString()); + } + return network; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java new file mode 100644 index 000000000..6f0a4a05b --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java @@ -0,0 +1,139 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; +import org.onap.vid.mso.model.ModelInfo; + +public class Node extends AbstractNode { + private String instanceType; + + private String provStatus; + private Boolean inMaint; + + private String uuid; + private String originalName; + + private String legacyRegion; + private String lineOfBusiness; + private String platformName; + + private final String trackById; + + public Node(AAITreeNode aaiNode, AAITreeConverter.ModelType modelType) { + super(); + this.instanceId = aaiNode.getId(); + this.instanceName = aaiNode.getName(); + this.orchStatus = aaiNode.getOrchestrationStatus(); + this.provStatus = aaiNode.getProvStatus(); + this.inMaint = aaiNode.getInMaint(); + this.uuid = aaiNode.getModelVersionId(); + this.originalName = aaiNode.getModelCustomizationName(); + this.trackById = aaiNode.getUniqueNodeKey(); + + ModelInfo nodeModelInfo = new ModelInfo(); + nodeModelInfo.setModelType(modelType.name()); + nodeModelInfo.setModelName(aaiNode.getModelName()); + nodeModelInfo.setModelVersion(aaiNode.getModelVersion()); + nodeModelInfo.setModelVersionId(aaiNode.getModelVersionId()); + nodeModelInfo.setModelInvariantId(aaiNode.getModelInvariantId()); + nodeModelInfo.setModelCustomizationId(aaiNode.getModelCustomizationId()); + nodeModelInfo.setModelCustomizationName(aaiNode.getModelCustomizationName()); + + this.modelInfo = nodeModelInfo; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public void setOrchStatus(String orchStatus) { + this.orchStatus = orchStatus; + } + + public String getProvStatus() { + return provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public Boolean getInMaint() { + return inMaint; + } + + public void setInMaint(Boolean inMaint) { + this.inMaint = inMaint; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getOriginalName() { + return originalName; + } + + public void setOriginalName(String originalName) { + this.originalName = originalName; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + + public String getLegacyRegion() { + return legacyRegion; + } + + public void setLegacyRegion(String legacyRegion) { + this.legacyRegion = legacyRegion; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getLineOfBusiness() { + return lineOfBusiness; + } + + public void setLineOfBusiness(String lineOfBusiness) { + this.lineOfBusiness = lineOfBusiness; + } + + public String getPlatformName() { + return platformName; + } + + public void setPlatformName(String platformName) { + this.platformName = platformName; + } + + public String getTrackById() { + return trackById; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java new file mode 100644 index 000000000..043d2ccd9 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java @@ -0,0 +1,52 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; + +import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE; + +public class RelatedVnf extends Node { + + private String serviceInstanceId; + private String serviceInstanceName; + private String tenantName; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public RelatedVnf(AAITreeNode node) { + super(node, AAITreeConverter.ModelType.vnf); + } + + public static RelatedVnf from(AAITreeNode node) { + RelatedVnf vnf = new RelatedVnf(node); + vnf.setServiceInstanceId(node.getParent().getId()); + vnf.setServiceInstanceName(node.getParent().getName()); + + if (node.getAdditionalProperties().get(VNF_TYPE) != null) { + vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString()); + } + + return vnf; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java new file mode 100644 index 000000000..6c6600774 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java @@ -0,0 +1,193 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.mso.model.ModelInfo; + +import java.util.HashMap; +import java.util.Map; + +public class ServiceInstance extends AbstractNode { + + private String globalSubscriberId; + private String subscriptionServiceType; + + private String owningEntityId; + + private String owningEntityName; + private String tenantName; + private String aicZoneId; + private String aicZoneName; + private String projectName; + + private String rollbackOnFailure; + private boolean isALaCarte; + + private Map vnfs = new HashMap<>(); + private Map networks = new HashMap<>(); + + private Map vnfGroups = new HashMap<>(); + + private int validationCounter; + private Map existingVNFCounterMap; + private Map existingNetworksCounterMap; + private Map existingVnfGroupCounterMap; + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public void setOrchStatus(String orchStatus) { + this.orchStatus = orchStatus; + } + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public String getOwningEntityId() { + return owningEntityId; + } + + public void setOwningEntityId(String owningEntityId) { + this.owningEntityId = owningEntityId; + } + + public String getOwningEntityName() { + return owningEntityName; + } + + public void setOwningEntityName(String owningEntityName) { + this.owningEntityName = owningEntityName; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public String getAicZoneId() { + return aicZoneId; + } + + public void setAicZoneId(String aicZoneId) { + this.aicZoneId = aicZoneId; + } + + public String getAicZoneName() { + return aicZoneName; + } + + public void setAicZoneName(String aicZoneName) { + this.aicZoneName = aicZoneName; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getRollbackOnFailure() { + return rollbackOnFailure; + } + + public void setRollbackOnFailure(String rollbackOnFailure) { + this.rollbackOnFailure = rollbackOnFailure; + } + + public boolean getIsALaCarte() { + return isALaCarte; + } + + public void setIsALaCarte(boolean isALaCarte) { + this.isALaCarte = isALaCarte; + } + + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public Map getVnfs() { + return vnfs; + } + + public void setVnfs(Map vnfs) { + this.vnfs = vnfs; + } + + public Map getNetworks() { + return networks; + } + + public void setNetworks(Map networks) { + this.networks = networks; + } + + public Map getVnfGroups() { return vnfGroups; } + + public void setVnfGroups(Map vnfGroups) { this.vnfGroups = vnfGroups; } + + public int getValidationCounter() { + return validationCounter; + } + + public void setValidationCounter(int validationCounter) { + this.validationCounter = validationCounter; + } + + public Map getExistingVNFCounterMap() { + return existingVNFCounterMap; + } + + public void setExistingVNFCounterMap(Map existingVNFCounterMap) { + this.existingVNFCounterMap = existingVNFCounterMap; + } + + public Map getExistingNetworksCounterMap() { + return existingNetworksCounterMap; + } + + public void setExistingNetworksCounterMap(Map existingNetworksCounterMap) { + this.existingNetworksCounterMap = existingNetworksCounterMap; + } + + public Map getExistingVnfGroupCounterMap() { + return existingVnfGroupCounterMap; + } + + public void setExistingVnfGroupCounterMap(Map existingVnfGroupCounterMap) { + this.existingVnfGroupCounterMap = existingVnfGroupCounterMap; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java new file mode 100644 index 000000000..14a43e797 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java @@ -0,0 +1,41 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; + +import static org.onap.vid.aai.util.AAITreeConverter.IS_BASE_VF_MODULE; + +public class VfModule extends Node { + + private boolean isBase; + private String volumeGroupName; + + public VfModule(AAITreeNode node) { + super(node, AAITreeConverter.ModelType.vfModule); + } + + public boolean getIsBase() { + return isBase; + } + + public void setIsBase(boolean isBase) { + this.isBase = isBase; + } + + public String getVolumeGroupName() { + return volumeGroupName; + } + + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + + public static VfModule from(AAITreeNode node) { + VfModule vfModule = new VfModule(node); + + if (node.getAdditionalProperties().get(IS_BASE_VF_MODULE) != null) { + vfModule.setIsBase(Boolean.valueOf(node.getAdditionalProperties().get(IS_BASE_VF_MODULE).toString())); + } + + return vfModule; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java new file mode 100644 index 000000000..a3280f4e3 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java @@ -0,0 +1,54 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; +import org.onap.vid.services.AAITreeNodeBuilder; + +import java.util.HashMap; +import java.util.Map; + +import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE; + +public class Vnf extends Node { + + private Map> vfModules = new HashMap<>(); + private Map networks = new HashMap<>(); + + public Vnf(AAITreeNode node) { + super(node, AAITreeConverter.ModelType.vnf); + } + + public Map> getVfModules() { + return vfModules; + } + + public void setVfModules(Map> vfModules) { + this.vfModules = vfModules; + } + + public Map getNetworks() { + return networks; + } + + public void setNetworks(Map networks) { + this.networks = networks; + } + + public static Vnf from(AAITreeNode node) { + Vnf vnf = new Vnf(node); + if (node.getAdditionalProperties().get(VNF_TYPE) != null) { + vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString()); + } + + node.getChildren().forEach(child -> { + if (child.getType().equals(AAITreeNodeBuilder.VF_MODULE)) { + vnf.getVfModules().putIfAbsent(child.getNodeKey(), new HashMap<>()); + vnf.getVfModules().get(child.getNodeKey()) + .put(child.getUniqueNodeKey(), VfModule.from(child)); + } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) { + vnf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child)); + } + }); + + return vnf; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java new file mode 100644 index 000000000..00e7ed8da --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java @@ -0,0 +1,52 @@ +package org.onap.vid.model.aaiTree; + +import org.onap.vid.aai.util.AAITreeConverter; + + +public class VnfGroup extends Node { + + public static final String INSTANCE_GROUP_TYPE = "instance-group-type"; + public static final String INSTANCE_GROUP_ROLE = "instance-group-role"; + public static final String INSTANCE_GROUP_FUNCTION = "instance-group-function"; + + private String instanceGroupRole; + private String instanceGroupFunction; + + + public VnfGroup(AAITreeNode node) { + super(node, AAITreeConverter.ModelType.instanceGroup); + } + + public static VnfGroup from(AAITreeNode node) { + VnfGroup vnfGroup = new VnfGroup(node); + if (node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE) != null) { + vnfGroup.setInstanceType(node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE).toString()); + } + if (node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION) != null) { + vnfGroup.setInstanceGroupFunction(node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION).toString()); + } + if (node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE) != null) { + vnfGroup.setInstanceGroupRole(node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE).toString()); + } + + return vnfGroup; + } + + public String getInstanceGroupRole() { + return instanceGroupRole; + } + + public void setInstanceGroupRole(String instanceGroupRole) { + this.instanceGroupRole = instanceGroupRole; + } + + public String getInstanceGroupFunction() { + return instanceGroupFunction; + } + + public void setInstanceGroupFunction(String instanceGroupFunction) { + this.instanceGroupFunction = instanceGroupFunction; + } + + +} \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/ExternalComponentStatus.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/ExternalComponentStatus.java index da8c912e3..5f5a0def0 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/probes/ExternalComponentStatus.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/ExternalComponentStatus.java @@ -1,7 +1,7 @@ package org.onap.vid.model.probes; public class ExternalComponentStatus { - public enum Component {AAI, MSO} + public enum Component {AAI, MSO, SDC, SCHEDULER} private final Component component; private final boolean available; private final StatusMetadata metadata; diff --git a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java index e80d563bf..08bed397e 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/probes/HttpRequestMetadata.java @@ -1,12 +1,20 @@ package org.onap.vid.model.probes; +import com.google.common.base.MoreObjects; +import org.apache.commons.lang3.StringUtils; +import org.onap.vid.aai.ExceptionWithRequestInfo; +import org.onap.vid.aai.ResponseWithRequestInfo; +import org.onap.vid.mso.RestObjectWithRequestInfo; +import org.onap.vid.utils.Logging; import org.springframework.http.HttpMethod; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; + public class HttpRequestMetadata extends StatusMetadata { private final HttpMethod httpMethod; private final int httpCode; private final String url; - private final String rawData; + private String rawData = ""; public HttpRequestMetadata(HttpMethod httpMethod, int httpCode, String url, String rawData, String description, long duration) { super(description, duration); @@ -16,6 +24,43 @@ public class HttpRequestMetadata extends StatusMetadata { this.rawData = rawData; } + public HttpRequestMetadata(ResponseWithRequestInfo response, String description, long duration) { + this(response, description, duration, true); + } + + public HttpRequestMetadata(RestObjectWithRequestInfo response, String description, long duration) { + super(description, duration); + this.httpMethod = response.getHttpMethod(); + this.url = response.getRequestedUrl(); + this.httpCode = response.getHttpCode(); + this.rawData = response.getRawData(); + } + + public HttpRequestMetadata(ResponseWithRequestInfo response, String description, long duration, boolean readRawData) { + super(description, duration); + this.httpMethod = response.getRequestHttpMethod(); + this.url = response.getRequestUrl(); + this.httpCode = response.getResponse().getStatus(); + if (readRawData) { + try { + this.rawData = response.getResponse().readEntity(String.class); + } catch (Exception e) { + //Nothing to do here + } + } + } + + public HttpRequestMetadata(ExceptionWithRequestInfo exception, long duration) { + this(exception.getHttpMethod(), + defaultIfNull(exception.getHttpCode(), 0), + exception.getRequestedUrl(), + exception.getRawData(), + Logging.exceptionToDescription(exception.getCause()), + duration); + } + + + public HttpMethod getHttpMethod() { return httpMethod; } @@ -29,6 +74,18 @@ public class HttpRequestMetadata extends StatusMetadata { } public String getRawData() { - return rawData; + return StringUtils.substring(rawData, 0, 500); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("httpMethod", httpMethod) + .add("httpCode", httpCode) + .add("url", url) + .add("duration", duration) + .add("description", description) + .add("rawData", rawData) + .toString(); } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java new file mode 100644 index 000000000..653c73477 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/BaseResource.java @@ -0,0 +1,115 @@ +/*- + * ============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.onap.vid.model.serviceInstantiation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.collect.ImmutableMap; +import org.apache.commons.lang3.StringUtils; +import org.onap.vid.job.JobAdapter; +import org.onap.vid.model.Action; +import org.onap.vid.mso.model.ModelInfo; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public abstract class BaseResource implements JobAdapter.AsyncJobRequest { + + protected final String instanceId; + protected ModelInfo modelInfo; + + protected String instanceName; + + protected final Action action; + + protected String lcpCloudRegionId; + + protected String tenantId; + + protected List> instanceParams; + + protected boolean rollbackOnFailure; + + private static final Map actionStingToEnumMap = ImmutableMap.of( + "Delete", Action.Delete, + "Create", Action.Create, + "None", Action.None, + "Update_Delete", Action.Delete, + "None_Delete", Action.Delete + ); + + + protected BaseResource(@JsonProperty("modelInfo") ModelInfo modelInfo, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List> instanceParams, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId) { + this.modelInfo = modelInfo; + this.modelInfo.setModelType(getModelType()); + this.rollbackOnFailure = rollbackOnFailure; + this.instanceName = StringUtils.defaultString(instanceName, "");; + this.action = actionStringToEnum(action); + this.lcpCloudRegionId = StringUtils.isNotEmpty(legacyRegion) ? legacyRegion : lcpCloudRegionId; + this.tenantId = tenantId; + this.instanceParams = instanceParams; + this.instanceId = instanceId; + } + + private Action actionStringToEnum(String actionAsString) { + return actionStingToEnumMap.get(actionAsString); + } + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public String getInstanceName() { + return instanceName; + } + + public Action getAction() { + return action; + } + + public String getLcpCloudRegionId() { + return lcpCloudRegionId; + } + + public String getTenantId() { + return tenantId; + } + + public List> getInstanceParams() { + return instanceParams == null ? Collections.emptyList() : instanceParams; + } + + public boolean isRollbackOnFailure() { return rollbackOnFailure; } + + public String getInstanceId() { + return instanceId; + } + + protected abstract String getModelType(); +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java new file mode 100644 index 000000000..6155480c7 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/InstanceGroup.java @@ -0,0 +1,22 @@ +package org.onap.vid.model.serviceInstantiation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.onap.vid.job.JobAdapter; +import org.onap.vid.mso.model.ModelInfo; + +public class InstanceGroup extends BaseResource implements JobAdapter.AsyncJobRequest { + + public InstanceGroup(@JsonProperty("modelInfo") ModelInfo modelInfo, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId) { + + super(modelInfo, instanceName, action, null, null, null, null, rollbackOnFailure, instanceId); + } + + @Override + protected String getModelType() { + return "instanceGroup"; + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java new file mode 100644 index 000000000..0e0c7e139 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Network.java @@ -0,0 +1,74 @@ +/*- + * ============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.onap.vid.model.serviceInstantiation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.onap.vid.job.JobAdapter; +import org.onap.vid.mso.model.ModelInfo; + +import java.util.List; +import java.util.Map; + +public class Network extends BaseResource implements JobAdapter.AsyncJobRequest { + + private final String productFamilyId; + + private final String platformName; + + private final String lineOfBusiness; + + public Network(@JsonProperty("modelInfo") ModelInfo modelInfo, + @JsonProperty("productFamilyId") String productFamilyId, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("platformName") String platformName, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List> instanceParams, + @JsonProperty("lineOfBusinessName") String lineOfBusiness, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId) { + + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId); + this.productFamilyId = productFamilyId; + this.platformName = platformName; + this.lineOfBusiness = lineOfBusiness; + } + + public String getProductFamilyId() { + return productFamilyId; + } + + public String getPlatformName() { + return platformName; + } + + public String getLineOfBusiness() { + return lineOfBusiness; + } + + @Override + protected String getModelType() { + return "network"; + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java index 1d2e69d54..3cb1e9492 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/ServiceInstantiation.java @@ -1,16 +1,14 @@ package org.onap.vid.model.serviceInstantiation; import com.fasterxml.jackson.annotation.JsonProperty; -import org.onap.vid.domain.mso.ModelInfo; import org.onap.vid.job.JobAdapter; +import org.onap.vid.mso.model.ModelInfo; import java.util.Collections; import java.util.List; import java.util.Map; -public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { - - private final ModelInfo modelInfo; +public class ServiceInstantiation extends BaseResource implements JobAdapter.AsyncJobRequest { private final String owningEntityId; @@ -24,16 +22,8 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { private final String productFamilyId; - private final String instanceName; - - private final Boolean isUserProvidedNaming; - private final String subscriptionServiceType; - private final String lcpCloudRegionId; - - private final String tenantId; - private final String tenantName; private final String aicZoneId; @@ -42,13 +32,17 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { private final Map vnfs; - private final List> instanceParams; + private final Map networks; + + private final Map vnfGroups; private final boolean isPause; private final int bulkSize; - private final boolean rollbackOnFailure; + private final String testApi; + + private final boolean isALaCarte; public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo, @JsonProperty("owningEntityId") String owningEntityId, @@ -58,45 +52,43 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { @JsonProperty("subscriberName") String subscriberName, @JsonProperty("productFamilyId") String productFamilyId, @JsonProperty("instanceName") String instanceName, - @JsonProperty("isUserProvidedNaming") Boolean isUserProvidedNaming, @JsonProperty("subscriptionServiceType") String subscriptionServiceType, @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, @JsonProperty("tenantId") String tenantId, @JsonProperty("tenantName") String tenantName, @JsonProperty("aicZoneId") String aicZoneId, @JsonProperty("aicZoneName") String aicZoneName, @JsonProperty("vnfs") Map vnfs, + @JsonProperty("networks") Map networks, + @JsonProperty("vnfGroups") Map vnfGroups, @JsonProperty("instanceParams") List> instanceParams, @JsonProperty("pause") boolean isPause, @JsonProperty("bulkSize") int bulkSize, - @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("isALaCarte") boolean isALaCarte, + @JsonProperty("testApi") String testApi, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("action") String action ) { - - this.modelInfo = modelInfo; - this.modelInfo.setModelType("service"); + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId); this.owningEntityId = owningEntityId; this.owningEntityName = owningEntityName; this.projectName = projectName; this.globalSubscriberId = globalSubscriberId; this.subscriberName = subscriberName; this.productFamilyId = productFamilyId; - this.instanceName = instanceName; - this.isUserProvidedNaming = isUserProvidedNaming; this.subscriptionServiceType = subscriptionServiceType; - this.lcpCloudRegionId = lcpCloudRegionId; - this.tenantId = tenantId; this.tenantName = tenantName; this.aicZoneId = aicZoneId; this.aicZoneName = aicZoneName; this.vnfs = vnfs; - this.instanceParams = instanceParams; + this.networks = networks; + this.vnfGroups = vnfGroups; this.isPause = isPause; this.bulkSize = bulkSize; - this.rollbackOnFailure = rollbackOnFailure; - } - - public ModelInfo getModelInfo() { - return modelInfo; + this.isALaCarte = isALaCarte; + this.testApi = isALaCarte ? testApi : null; } public String getOwningEntityId() { @@ -123,25 +115,10 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { return productFamilyId; } - public String getInstanceName() { - return instanceName; - } - - @JsonProperty("isUserProvidedNaming") - public Boolean isUserProvidedNaming() { return isUserProvidedNaming; } - public String getSubscriptionServiceType() { return subscriptionServiceType; } - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - public String getTenantId() { - return tenantId; - } - public String getTenantName() { return tenantName; } @@ -155,11 +132,15 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { } public Map getVnfs() { - return vnfs; + return vnfs == null ? Collections.emptyMap() : vnfs; + } + + public Map getNetworks() { + return networks == null ? Collections.emptyMap() : networks; } - public List> getInstanceParams() { - return instanceParams == null ? Collections.emptyList() : instanceParams; + public Map getVnfGroups() { + return vnfGroups == null ? Collections.emptyMap() : vnfGroups; } public boolean isPause() { @@ -168,7 +149,18 @@ public class ServiceInstantiation implements JobAdapter.AsyncJobRequest { public int getBulkSize() { return bulkSize; } - public boolean isRollbackOnFailure() { - return rollbackOnFailure; + @Override + protected String getModelType() { + return "service"; + } + + @JsonProperty("isALaCarte") + public boolean isALaCarte() { + return isALaCarte; } + + public String getTestApi() { + return this.testApi; + } + } \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java index f63fb3365..b930ba4db 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/VfModule.java @@ -22,10 +22,9 @@ package org.onap.vid.model.serviceInstantiation; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; -import org.onap.vid.domain.mso.ModelInfo; +import org.onap.vid.job.JobAdapter; +import org.onap.vid.mso.model.ModelInfo; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -34,42 +33,47 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; /** * The Class VfModule. */ -public class VfModule { +@JsonInclude(NON_NULL) +public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest { - - - private final ModelInfo modelInfo; - - @JsonInclude(NON_NULL) private final String instanceName; - - private final List> instanceParams; @JsonInclude(NON_NULL) private final String volumeGroupInstanceName; - - public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("instanceName") String instanceName, - @JsonProperty(value = "volumeGroupName") String volumeGroupInstanceName, - @JsonProperty("instanceParams") List> instanceParams) { - this.modelInfo = modelInfo; - this.modelInfo.setModelType("vfModule"); - this.instanceName = instanceName; - this.instanceParams = instanceParams; + private boolean usePreload; + private Map supplementaryParams; + + public VfModule( @JsonProperty("modelInfo") ModelInfo modelInfo, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("volumeGroupName") String volumeGroupInstanceName, + @JsonProperty("action") String action, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List> instanceParams, + @JsonProperty("supplementaryFileContent") Map supplementaryParams, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("sdncPreLoad") boolean usePreload, + @JsonProperty("instanceId") String instanceId) { + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId); this.volumeGroupInstanceName = volumeGroupInstanceName; + this.usePreload = usePreload; + this.supplementaryParams = supplementaryParams; } - public ModelInfo getModelInfo() { - return modelInfo; + public String getVolumeGroupInstanceName() { + return volumeGroupInstanceName; } - public String getInstanceName() { - return instanceName; + public boolean isUsePreload() { + return usePreload; } - public String getVolumeGroupInstanceName() { - return volumeGroupInstanceName; + public Map getSupplementaryParams() { + return supplementaryParams; } - public List> getInstanceParams() { - return instanceParams == null ? Collections.emptyList() : instanceParams; + @Override + protected String getModelType() { + return "vfModule"; } + } \ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java index 621754d17..3856e8894 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/serviceInstantiation/Vnf.java @@ -22,99 +22,64 @@ package org.onap.vid.model.serviceInstantiation; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; -import org.onap.vid.domain.mso.ModelInfo; +import org.onap.vid.job.JobAdapter; +import org.onap.vid.mso.model.ModelInfo; -import java.util.Collections; import java.util.List; import java.util.Map; /** * The Class VNF. */ -public class Vnf { - private final ModelInfo modelInfo; +public class Vnf extends BaseResource implements JobAdapter.AsyncJobRequest { private final String productFamilyId; - private final String instanceName; - private final String platformName; - private final String lcpCloudRegionId; - - private final String tenantId; - - private final Boolean isUserProvidedNaming; - - private final List> instanceParams; - private final String lineOfBusiness; - private final Map> vfModules; public Vnf(@JsonProperty("modelInfo") ModelInfo modelInfo, - @JsonProperty("productFamilyId") String productFamilyId, - @JsonProperty("instanceName") String instanceName, - @JsonProperty("isUserProvidedNaming") Boolean isUserProvidedNaming, - @JsonProperty("platformName") String platformName, - @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, - @JsonProperty("tenantId") String tenantId, - @JsonProperty("instanceParams") List> instanceParams, - @JsonProperty("lineOfBusinessName") String lineOfBusiness, - @JsonProperty("vfModules") Map> vfModules) { - this.modelInfo = modelInfo; - this.modelInfo.setModelType("vnf"); + @JsonProperty("productFamilyId") String productFamilyId, + @JsonProperty("instanceName") String instanceName, + @JsonProperty("action") String action, + @JsonProperty("platformName") String platformName, + @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId, + @JsonProperty("legacyRegion") String legacyRegion, + @JsonProperty("tenantId") String tenantId, + @JsonProperty("instanceParams") List> instanceParams, + @JsonProperty("lineOfBusinessName") String lineOfBusiness, + @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure, + @JsonProperty("instanceId") String instanceId, + @JsonProperty("vfModules") Map> vfModules) { + + super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId); this.productFamilyId = productFamilyId; - this.instanceName = instanceName; - this.isUserProvidedNaming = isUserProvidedNaming; this.platformName = platformName; - this.lcpCloudRegionId = lcpCloudRegionId; - this.tenantId = tenantId; - this.instanceParams = instanceParams; - this.vfModules = vfModules; this.lineOfBusiness = lineOfBusiness; - } - - public ModelInfo getModelInfo() { - return modelInfo; + this.vfModules = vfModules; } public String getProductFamilyId() { return productFamilyId; } - public String getInstanceName() { - return instanceName; - } - - @JsonProperty("isUserProvidedNaming") - public Boolean isUserProvidedNaming() { - return isUserProvidedNaming; - } - public String getPlatformName() { return platformName; } - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - public String getTenantId() { - return tenantId; - } - - public List> getInstanceParams() { - return instanceParams == null ? Collections.emptyList() : instanceParams; + public String getLineOfBusiness() { + return lineOfBusiness; } public Map> getVfModules() { return vfModules; } - public String getLineOfBusiness() { - return lineOfBusiness; + @Override + protected String getModelType() { + return "vnf"; } } -- cgit 1.2.3-korg