From d407638086b08c3de199cbef5e717fb16556077c Mon Sep 17 00:00:00 2001 From: Pooja03 Date: Fri, 23 Mar 2018 17:49:26 +0530 Subject: [PATCH] Added UniversalVesAdapter in the Mapper Adding full UniversalVesAdapter Module in Mapper Change-Id: I7edece763546b91700983554ffcf38f8ab945ae2 Issue-ID: DCAEGEN2-335 Signed-off-by: Pooja03 --- .gitignore | 4 + LICENSE.txt | 19 + UniversalVesAdapter/.gitignore | 1 + .../SampleofMappingFile/snmpTrapToVes.xml | 54 ++ UniversalVesAdapter/pom.xml | 94 +++ .../onap/dcaegen2/ves/domain/AdditionalField.java | 77 +++ .../ves/domain/AlarmAdditionalInformation.java | 100 +++ .../onap/dcaegen2/ves/domain/ArrayOfField_.java | 100 +++ .../dcaegen2/ves/domain/CommonEventHeader.java | 282 +++++++++ .../java/org/onap/dcaegen2/ves/domain/Event.java | 102 ++++ .../org/onap/dcaegen2/ves/domain/FaultFields.java | 192 ++++++ .../onap/dcaegen2/ves/domain/HeartbeatFields.java | 114 ++++ .../dcaegen2/ves/domain/InternalHeaderFields.java | 74 +++ .../org/onap/dcaegen2/ves/domain/VesEvent.java | 65 ++ .../org/onap/universalvesadapter/Application.java | 31 + .../adapter/GenericAdapter.java | 51 ++ .../adapter/UniversalEventAdapter.java | 136 +++++ .../universalvesadapter/configs/Configuration.java | 24 + .../configs/DMaapMrUrlConfiguration.java | 56 ++ .../configs/DiskRepoConfiguration.java | 42 ++ .../configs/UniversalEventConfiguration.java | 73 +++ .../controller/MockDmaapController.java | 37 ++ .../controller/VesController.java | 64 ++ .../universalvesadapter/domain/ConfigFileData.java | 57 ++ .../onap/universalvesadapter/domain/Domains.java | 55 ++ .../universalvesadapter/domain/Priorities.java | 35 ++ .../onap/universalvesadapter/domain/Severity.java | 36 ++ .../org/onap/universalvesadapter/domain/State.java | 33 + .../universalvesadapter/domain/SysLogSeverity.java | 50 ++ .../universalvesadapter/domain/TcaAlertAction.java | 33 + .../universalvesadapter/domain/TcaAlertType.java | 34 ++ .../domain/TcaCounterCriticality.java | 33 + .../domain/TcaEventSeverity.java | 36 ++ .../onap/universalvesadapter/domain/VnfStatus.java | 37 ++ .../exception/ConfigFileReadException.java | 38 ++ .../ConfigFileSmooksConversionException.java | 40 ++ .../exception/DMaapException.java | 41 ++ .../exception/MapperConfigException.java | 45 ++ .../exception/VesException.java | 40 ++ .../universalvesadapter/mappingconfig/Entry.java | 114 ++++ .../mappingconfig/Evaluation.java | 208 +++++++ .../mappingconfig/MapperConfig.java | 88 +++ .../service/AdapterService.java | 57 ++ .../service/ConfigFileService.java | 41 ++ .../universalvesadapter/service/DMaapService.java | 155 +++++ .../service/DiskRepoConfigFileService.java | 73 +++ .../service/MongoDbConfigFileService.java | 46 ++ .../universalvesadapter/service/VesService.java | 128 ++++ .../utils/MapperConfigUtils.java | 322 ++++++++++ .../universalvesadapter/utils/ParallelTasks.java | 87 +++ .../universalvesadapter/utils/SmooksUtils.java | 76 +++ .../src/main/resources/MapperConfig.json | 16 + .../src/main/resources/MapperConfigFullFormat.json | 56 ++ .../src/main/resources/application.properties | 10 + .../src/main/resources/dme2/consumer.properties | 61 ++ .../main/resources/dme2/preferredRoute.properties | 5 + .../src/main/resources/dme2/producer.properties | 59 ++ pom.xml | 675 +++++++++++++++++++++ 58 files changed, 4712 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 UniversalVesAdapter/.gitignore create mode 100644 UniversalVesAdapter/SampleofMappingFile/snmpTrapToVes.xml create mode 100644 UniversalVesAdapter/pom.xml create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AdditionalField.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AlarmAdditionalInformation.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/ArrayOfField_.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/CommonEventHeader.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/Event.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/FaultFields.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/HeartbeatFields.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/InternalHeaderFields.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/VesEvent.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/Application.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/GenericAdapter.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/UniversalEventAdapter.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/Configuration.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfiguration.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DiskRepoConfiguration.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/UniversalEventConfiguration.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/MockDmaapController.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/ConfigFileData.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Domains.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Priorities.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Severity.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/State.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/SysLogSeverity.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertAction.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertType.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaCounterCriticality.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaEventSeverity.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/VnfStatus.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileReadException.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionException.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/DMaapException.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/MapperConfigException.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/VesException.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Entry.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Evaluation.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/MapperConfig.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/AdapterService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/ConfigFileService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DMaapService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DiskRepoConfigFileService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/MongoDbConfigFileService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VesService.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/ParallelTasks.java create mode 100644 UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/SmooksUtils.java create mode 100644 UniversalVesAdapter/src/main/resources/MapperConfig.json create mode 100644 UniversalVesAdapter/src/main/resources/MapperConfigFullFormat.json create mode 100644 UniversalVesAdapter/src/main/resources/application.properties create mode 100644 UniversalVesAdapter/src/main/resources/dme2/consumer.properties create mode 100644 UniversalVesAdapter/src/main/resources/dme2/preferredRoute.properties create mode 100644 UniversalVesAdapter/src/main/resources/dme2/producer.properties create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19499ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# Package Files # +*.jar +.mvn/* +.settings/* \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..f12b304 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,19 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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========================================================= +*/ \ No newline at end of file diff --git a/UniversalVesAdapter/.gitignore b/UniversalVesAdapter/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/UniversalVesAdapter/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/UniversalVesAdapter/SampleofMappingFile/snmpTrapToVes.xml b/UniversalVesAdapter/SampleofMappingFile/snmpTrapToVes.xml new file mode 100644 index 0000000..5fad2c9 --- /dev/null +++ b/UniversalVesAdapter/SampleofMappingFile/snmpTrapToVes.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UniversalVesAdapter/pom.xml b/UniversalVesAdapter/pom.xml new file mode 100644 index 0000000..d66b090 --- /dev/null +++ b/UniversalVesAdapter/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + org.onap.dcaegen2.services.mapper.vesadapter + UniversalVesAdapter + 0.0.1 + + + + org.onap.dcaegen2.services.mapper + mapper + 0.0.1-SNAPSHOT + + + + + org.milyn + milyn-smooks-all + 1.7.0 + + + javax.servlet + servlet-api + + + + + org.onap.dmaap.messagerouter.dmaapclient + dmaapClient + 1.1.3 + + + + + org.springframework.boot + spring-boot-starter-web + 2.0.0.RELEASE + + + org.springframework.boot + spring-boot-starter-test + 2.0.0.RELEASE + test + + + com.jayway.jsonpath + json-path + 2.4.0 + test + + + org.springframework.data + spring-data-commons + 2.0.5.RELEASE + + + com.fasterxml.jackson.core + jackson-databind + 2.9.4 + + + + + + 1.8 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-releases + https://repo.spring.io/libs-release + + + + + spring-releases + https://repo.spring.io/libs-release + + + diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AdditionalField.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AdditionalField.java new file mode 100644 index 0000000..850b39b --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AdditionalField.java @@ -0,0 +1,77 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "value" +}) +public class AdditionalField { + + @JsonProperty("name") + private String name; + @JsonProperty("value") + private String value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AlarmAdditionalInformation.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AlarmAdditionalInformation.java new file mode 100644 index 0000000..fe60761 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/AlarmAdditionalInformation.java @@ -0,0 +1,100 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "value" +}) +public class AlarmAdditionalInformation { + + @JsonProperty("name") + private String name; + @JsonProperty("value") + private String value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("name", name).append("value", value).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(additionalProperties).append(name).append(value).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof AlarmAdditionalInformation) == false) { + return false; + } + AlarmAdditionalInformation rhs = ((AlarmAdditionalInformation) other); + return new EqualsBuilder().append(additionalProperties, rhs.additionalProperties).append(name, rhs.name).append(value, rhs.value).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/ArrayOfField_.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/ArrayOfField_.java new file mode 100644 index 0000000..4e28be7 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/ArrayOfField_.java @@ -0,0 +1,100 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "value" +}) +public class ArrayOfField_ { + + @JsonProperty("name") + private String name; + @JsonProperty("value") + private String value; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("name", name).append("value", value).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(additionalProperties).append(name).append(value).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof ArrayOfField_) == false) { + return false; + } + ArrayOfField_ rhs = ((ArrayOfField_) other); + return new EqualsBuilder().append(additionalProperties, rhs.additionalProperties).append(name, rhs.name).append(value, rhs.value).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/CommonEventHeader.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/CommonEventHeader.java new file mode 100644 index 0000000..f5d56a4 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/CommonEventHeader.java @@ -0,0 +1,282 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "domain", + "eventId", + "eventName", + "lastEpochMicrosec", + "priority", + "reportingEntityName", + "sequence", + "sourceName", + "startEpochMicrosec", + "version", + "eventType", + "internalHeaderFields", + "nfcNamingCode", + "nfNamingCode", + "reportingEntityId", + "sourceId" +}) +public class CommonEventHeader { + + @JsonProperty("domain") + private String domain; + @JsonProperty("eventId") + private String eventId; + @JsonProperty("eventName") + private String eventName; + @JsonProperty("lastEpochMicrosec") + private Double lastEpochMicrosec; + @JsonProperty("priority") + private String priority; + @JsonProperty("reportingEntityName") + private String reportingEntityName; + @JsonProperty("sequence") + private Long sequence; + @JsonProperty("sourceName") + private String sourceName; + @JsonProperty("startEpochMicrosec") + private Double startEpochMicrosec; + @JsonProperty("version") + private Double version; + @JsonProperty("eventType") + private String eventType; + @JsonProperty("internalHeaderFields") + private InternalHeaderFields internalHeaderFields; + @JsonProperty("nfcNamingCode") + private String nfcNamingCode; + @JsonProperty("nfNamingCode") + private String nfNamingCode; + @JsonProperty("reportingEntityId") + private String reportingEntityId; + @JsonProperty("sourceId") + private String sourceId; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("domain") + public String getDomain() { + return domain; + } + + @JsonProperty("domain") + public void setDomain(String domain) { + this.domain = domain; + } + + @JsonProperty("eventId") + public String getEventId() { + return eventId; + } + + @JsonProperty("eventId") + public void setEventId(String eventId) { + this.eventId = eventId; + } + + @JsonProperty("eventName") + public String getEventName() { + return eventName; + } + + @JsonProperty("eventName") + public void setEventName(String eventName) { + this.eventName = eventName; + } + + @JsonProperty("lastEpochMicrosec") + public Double getLastEpochMicrosec() { + return lastEpochMicrosec; + } + + @JsonProperty("lastEpochMicrosec") + public void setLastEpochMicrosec(Double lastEpochMicrosec) { + this.lastEpochMicrosec = lastEpochMicrosec; + } + + @JsonProperty("priority") + public String getPriority() { + return priority; + } + + @JsonProperty("priority") + public void setPriority(String priority) { + this.priority = priority; + } + + @JsonProperty("reportingEntityName") + public String getReportingEntityName() { + return reportingEntityName; + } + + @JsonProperty("reportingEntityName") + public void setReportingEntityName(String reportingEntityName) { + this.reportingEntityName = reportingEntityName; + } + + @JsonProperty("sequence") + public Long getSequence() { + return sequence; + } + + @JsonProperty("sequence") + public void setSequence(Long sequence) { + this.sequence = sequence; + } + + @JsonProperty("sourceName") + public String getSourceName() { + return sourceName; + } + + @JsonProperty("sourceName") + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + @JsonProperty("startEpochMicrosec") + public Double getStartEpochMicrosec() { + return startEpochMicrosec; + } + + @JsonProperty("startEpochMicrosec") + public void setStartEpochMicrosec(Double startEpochMicrosec) { + this.startEpochMicrosec = startEpochMicrosec; + } + + @JsonProperty("version") + public Double getVersion() { + return version; + } + + @JsonProperty("version") + public void setVersion(Double version) { + this.version = version; + } + + @JsonProperty("eventType") + public String getEventType() { + return eventType; + } + + @JsonProperty("eventType") + public void setEventType(String eventType) { + this.eventType = eventType; + } + + @JsonProperty("internalHeaderFields") + public InternalHeaderFields getInternalHeaderFields() { + return internalHeaderFields; + } + + @JsonProperty("internalHeaderFields") + public void setInternalHeaderFields(InternalHeaderFields internalHeaderFields) { + this.internalHeaderFields = internalHeaderFields; + } + + @JsonProperty("nfcNamingCode") + public String getNfcNamingCode() { + return nfcNamingCode; + } + + @JsonProperty("nfcNamingCode") + public void setNfcNamingCode(String nfcNamingCode) { + this.nfcNamingCode = nfcNamingCode; + } + + @JsonProperty("nfNamingCode") + public String getNfNamingCode() { + return nfNamingCode; + } + + @JsonProperty("nfNamingCode") + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + @JsonProperty("reportingEntityId") + public String getReportingEntityId() { + return reportingEntityId; + } + + @JsonProperty("reportingEntityId") + public void setReportingEntityId(String reportingEntityId) { + this.reportingEntityId = reportingEntityId; + } + + @JsonProperty("sourceId") + public String getSourceId() { + return sourceId; + } + + @JsonProperty("sourceId") + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("domain", domain).append("eventId", eventId).append("eventName", eventName).append("lastEpochMicrosec", lastEpochMicrosec).append("priority", priority).append("reportingEntityName", reportingEntityName).append("sequence", sequence).append("sourceName", sourceName).append("startEpochMicrosec", startEpochMicrosec).append("version", version).append("eventType", eventType).append("internalHeaderFields", internalHeaderFields).append("nfcNamingCode", nfcNamingCode).append("nfNamingCode", nfNamingCode).append("reportingEntityId", reportingEntityId).append("sourceId", sourceId).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(nfNamingCode).append(eventType).append(sourceId).append(version).append(reportingEntityName).append(startEpochMicrosec).append(lastEpochMicrosec).append(eventId).append(nfcNamingCode).append(additionalProperties).append(sourceName).append(sequence).append(priority).append(domain).append(internalHeaderFields).append(eventName).append(reportingEntityId).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof CommonEventHeader) == false) { + return false; + } + CommonEventHeader rhs = ((CommonEventHeader) other); + return new EqualsBuilder().append(nfNamingCode, rhs.nfNamingCode).append(eventType, rhs.eventType).append(sourceId, rhs.sourceId).append(version, rhs.version).append(reportingEntityName, rhs.reportingEntityName).append(startEpochMicrosec, rhs.startEpochMicrosec).append(lastEpochMicrosec, rhs.lastEpochMicrosec).append(eventId, rhs.eventId).append(nfcNamingCode, rhs.nfcNamingCode).append(additionalProperties, rhs.additionalProperties).append(sourceName, rhs.sourceName).append(sequence, rhs.sequence).append(priority, rhs.priority).append(domain, rhs.domain).append(internalHeaderFields, rhs.internalHeaderFields).append(eventName, rhs.eventName).append(reportingEntityId, rhs.reportingEntityId).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/Event.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/Event.java new file mode 100644 index 0000000..b83cf93 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/Event.java @@ -0,0 +1,102 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "commonEventHeader", + "faultFields", + "heartbeatFields" +}) +public class Event { + + @JsonProperty("commonEventHeader") + private CommonEventHeader commonEventHeader; + @JsonProperty("faultFields") + private FaultFields faultFields; + @JsonProperty("heartbeatFields") + private HeartbeatFields heartbeatFields; + + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("commonEventHeader") + public CommonEventHeader getCommonEventHeader() { + return commonEventHeader; + } + + @JsonProperty("commonEventHeader") + public void setCommonEventHeader(CommonEventHeader commonEventHeader) { + this.commonEventHeader = commonEventHeader; + } + + @JsonProperty("faultFields") + public FaultFields getFaultFields() { + return faultFields; + } + + @JsonProperty("faultFields") + public void setFaultFields(FaultFields faultFields) { + this.faultFields = faultFields; + } + + @JsonProperty("heartbeatFields") + public HeartbeatFields getHeartbeatFields() { + return heartbeatFields; + } + + @JsonProperty("heartbeatFields") + public void setHeartbeatFields(HeartbeatFields heartbeatFields) { + this.heartbeatFields = heartbeatFields; + } + + + @Override + public String toString() { + return new ToStringBuilder(this).append("commonEventHeader", commonEventHeader).append("faultFields", faultFields).append("heartbeatFields", heartbeatFields).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(heartbeatFields).append(commonEventHeader).append(additionalProperties).append(faultFields).toHashCode(); } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof Event) == false) { + return false; + } + Event rhs = ((Event) other); + return new EqualsBuilder().append(heartbeatFields, rhs.heartbeatFields).append(commonEventHeader, rhs.commonEventHeader).append(additionalProperties, rhs.additionalProperties).append(faultFields, rhs.faultFields).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/FaultFields.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/FaultFields.java new file mode 100644 index 0000000..d9d014c --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/FaultFields.java @@ -0,0 +1,192 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "alarmCondition", + "eventSeverity", + "eventSourceType", + "faultFieldsVersion", + "specificProblem", + "vfStatus", + "alarmAdditionalInformation", + "alarmInterfaceA", + "eventCategory" +}) +public class FaultFields { + + @JsonProperty("alarmCondition") + private String alarmCondition; + @JsonProperty("eventSeverity") + private String eventSeverity; + @JsonProperty("eventSourceType") + private String eventSourceType; + @JsonProperty("faultFieldsVersion") + private Double faultFieldsVersion; + @JsonProperty("specificProblem") + private String specificProblem; + @JsonProperty("vfStatus") + private String vfStatus; + @JsonProperty("alarmAdditionalInformation") + private List alarmAdditionalInformation = null; + @JsonProperty("alarmInterfaceA") + private String alarmInterfaceA; + @JsonProperty("eventCategory") + private String eventCategory; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("alarmCondition") + public String getAlarmCondition() { + return alarmCondition; + } + + @JsonProperty("alarmCondition") + public void setAlarmCondition(String alarmCondition) { + this.alarmCondition = alarmCondition; + } + + @JsonProperty("eventSeverity") + public String getEventSeverity() { + return eventSeverity; + } + + @JsonProperty("eventSeverity") + public void setEventSeverity(String eventSeverity) { + this.eventSeverity = eventSeverity; + } + + @JsonProperty("eventSourceType") + public String getEventSourceType() { + return eventSourceType; + } + + @JsonProperty("eventSourceType") + public void setEventSourceType(String eventSourceType) { + this.eventSourceType = eventSourceType; + } + + @JsonProperty("faultFieldsVersion") + public Double getFaultFieldsVersion() { + return faultFieldsVersion; + } + + @JsonProperty("faultFieldsVersion") + public void setFaultFieldsVersion(Double faultFieldsVersion) { + this.faultFieldsVersion = faultFieldsVersion; + } + + @JsonProperty("specificProblem") + public String getSpecificProblem() { + return specificProblem; + } + + @JsonProperty("specificProblem") + public void setSpecificProblem(String specificProblem) { + this.specificProblem = specificProblem; + } + + @JsonProperty("vfStatus") + public String getVfStatus() { + return vfStatus; + } + + @JsonProperty("vfStatus") + public void setVfStatus(String vfStatus) { + this.vfStatus = vfStatus; + } + + @JsonProperty("alarmAdditionalInformation") + public List getAlarmAdditionalInformation() { + return alarmAdditionalInformation; + } + + @JsonProperty("alarmAdditionalInformation") + public void setAlarmAdditionalInformation(List alarmAdditionalInformation) { + this.alarmAdditionalInformation = alarmAdditionalInformation; + } + + @JsonProperty("alarmInterfaceA") + public String getAlarmInterfaceA() { + return alarmInterfaceA; + } + + @JsonProperty("alarmInterfaceA") + public void setAlarmInterfaceA(String alarmInterfaceA) { + this.alarmInterfaceA = alarmInterfaceA; + } + + @JsonProperty("eventCategory") + public String getEventCategory() { + return eventCategory; + } + + @JsonProperty("eventCategory") + public void setEventCategory(String eventCategory) { + this.eventCategory = eventCategory; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("alarmCondition", alarmCondition).append("eventSeverity", eventSeverity).append("eventSourceType", eventSourceType).append("faultFieldsVersion", faultFieldsVersion).append("specificProblem", specificProblem).append("vfStatus", vfStatus).append("alarmAdditionalInformation", alarmAdditionalInformation).append("alarmInterfaceA", alarmInterfaceA).append("eventCategory", eventCategory).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(eventSourceType).append(alarmAdditionalInformation).append(specificProblem).append(additionalProperties).append(alarmInterfaceA).append(alarmCondition).append(eventSeverity).append(faultFieldsVersion).append(eventCategory).append(vfStatus).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof FaultFields) == false) { + return false; + } + FaultFields rhs = ((FaultFields) other); + return new EqualsBuilder().append(eventSourceType, rhs.eventSourceType).append(alarmAdditionalInformation, rhs.alarmAdditionalInformation).append(specificProblem, rhs.specificProblem).append(additionalProperties, rhs.additionalProperties).append(alarmInterfaceA, rhs.alarmInterfaceA).append(alarmCondition, rhs.alarmCondition).append(eventSeverity, rhs.eventSeverity).append(faultFieldsVersion, rhs.faultFieldsVersion).append(eventCategory, rhs.eventCategory).append(vfStatus, rhs.vfStatus).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/HeartbeatFields.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/HeartbeatFields.java new file mode 100644 index 0000000..a73da4e --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/HeartbeatFields.java @@ -0,0 +1,114 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "heartbeatFieldsVersion", + "heartbeatInterval", + "additionalFields" +}) +public class HeartbeatFields { + + @JsonProperty("heartbeatFieldsVersion") + private Double heartbeatFieldsVersion; + @JsonProperty("heartbeatInterval") + private Long heartbeatInterval; + @JsonProperty("additionalFields") + private List additionalFields = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("heartbeatFieldsVersion") + public Double getHeartbeatFieldsVersion() { + return heartbeatFieldsVersion; + } + + @JsonProperty("heartbeatFieldsVersion") + public void setHeartbeatFieldsVersion(Double heartbeatFieldsVersion) { + this.heartbeatFieldsVersion = heartbeatFieldsVersion; + } + + @JsonProperty("heartbeatInterval") + public Long getHeartbeatInterval() { + return heartbeatInterval; + } + + @JsonProperty("heartbeatInterval") + public void setHeartbeatInterval(Long heartbeatInterval) { + this.heartbeatInterval = heartbeatInterval; + } + + @JsonProperty("additionalFields") + public List getAdditionalFields() { + return additionalFields; + } + + @JsonProperty("additionalFields") + public void setAdditionalFields(List additionalFields) { + this.additionalFields = additionalFields; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("heartbeatFieldsVersion", heartbeatFieldsVersion).append("heartbeatInterval", heartbeatInterval).append("additionalFields", additionalFields).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(heartbeatInterval).append(additionalProperties).append(heartbeatFieldsVersion).append(additionalFields).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof HeartbeatFields) == false) { + return false; + } + HeartbeatFields rhs = ((HeartbeatFields) other); + return new EqualsBuilder().append(heartbeatInterval, rhs.heartbeatInterval).append(additionalProperties, rhs.additionalProperties).append(heartbeatFieldsVersion, rhs.heartbeatFieldsVersion).append(additionalFields, rhs.additionalFields).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/InternalHeaderFields.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/InternalHeaderFields.java new file mode 100644 index 0000000..e504011 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/InternalHeaderFields.java @@ -0,0 +1,74 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + +}) +public class InternalHeaderFields { + + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(additionalProperties).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof InternalHeaderFields) == false) { + return false; + } + InternalHeaderFields rhs = ((InternalHeaderFields) other); + return new EqualsBuilder().append(additionalProperties, rhs.additionalProperties).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/VesEvent.java b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/VesEvent.java new file mode 100644 index 0000000..4106943 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/dcaegen2/ves/domain/VesEvent.java @@ -0,0 +1,65 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.dcaegen2.ves.domain; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "event" +}) +public class VesEvent { + + @JsonProperty("event") + private Event event; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("event") + public Event getEvent() { + return event; + } + + @JsonProperty("event") + public void setEvent(Event event) { + this.event = event; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/Application.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/Application.java new file mode 100644 index 0000000..4db5e28 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/Application.java @@ -0,0 +1,31 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/GenericAdapter.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/GenericAdapter.java new file mode 100644 index 0000000..fa3b89c --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/GenericAdapter.java @@ -0,0 +1,51 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.adapter; + +import org.onap.universalvesadapter.exception.ConfigFileReadException; +import org.onap.universalvesadapter.exception.ConfigFileSmooksConversionException; +import org.onap.universalvesadapter.exception.VesException; + +/** + * This interface defines contract for adapter to convert an incoming json + * to VES format + * + * @author kmalbari + * + */ +public interface GenericAdapter { + +// String transform(String incomingJsonString) throws ConfigFileReadException; + + /** + * It will take in an incoming json and identify the json type for different + * events. Based on the event type it will retrieve the corresponding config + * file and convert the json to VES format using mappings in the config file. + * + * @param incomingJsonString json that is received on DMaap topic + * @param eventType type identified from incoming json + * @return VES format json + * @throws ConfigFileReadException if unable to read the configuration file + * @throws ConfigFileSmooksConversionException if unable to convert config file data to smooks object + * @throws VesException if unable to convert into ves json + */ + String transform(String incomingJsonString, String eventType) throws ConfigFileReadException, ConfigFileSmooksConversionException, VesException; + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/UniversalEventAdapter.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/UniversalEventAdapter.java new file mode 100644 index 0000000..318c8cd --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/adapter/UniversalEventAdapter.java @@ -0,0 +1,136 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.adapter; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.annotation.PreDestroy; +import javax.annotation.Resource; + +import org.milyn.Smooks; +import org.onap.dcaegen2.ves.domain.VesEvent; +import org.onap.universalvesadapter.configs.UniversalEventConfiguration; +import org.onap.universalvesadapter.exception.ConfigFileReadException; +import org.onap.universalvesadapter.exception.ConfigFileSmooksConversionException; +import org.onap.universalvesadapter.exception.VesException; +import org.onap.universalvesadapter.service.ConfigFileService; +import org.onap.universalvesadapter.utils.SmooksUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.xml.sax.SAXException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Default implementation of the Generic Adapter + * + * @author kmalbari + * + */ +@Component +public class UniversalEventAdapter implements GenericAdapter{ + + private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private UniversalEventConfiguration configuration; + + @Resource(name="diskRepoConfigFileService") + private ConfigFileService configFileService; + +// private Smooks smooks; + + private Map eventToSmooksMapping = new ConcurrentHashMap<>(); + + /*public String transform(String incomingJsonString) throws ConfigFileReadException { + String result = ""; + try { + //reading config file.. for now, looking at it as just one time operation + if(null == smooks){ + String configFileData = configFileService.readConfigFile(configuration.getConfigFile()); + smooks = new Smooks(new ByteArrayInputStream(configFileData.getBytes(StandardCharsets.UTF_8))); + } + + VesEvent vesEvent = SmooksUtils.getTransformedObjectForInput(smooks, incomingJsonString); + ObjectMapper objectMapper = new ObjectMapper(); + result = objectMapper.writeValueAsString(vesEvent); + } catch (IOException | SAXException e) { + e.printStackTrace(); + } + + return result; + }*/ + + + + @Override + public String transform(String incomingJsonString, String eventType) throws ConfigFileReadException, + ConfigFileSmooksConversionException, VesException { + String result = ""; + try { + if(null == eventToSmooksMapping.get(eventType)){ + LOGGER.debug("No smooks mapping for this event type " + eventType + ".. reading config file"); + String configFileData = configFileService.readConfigFile(configuration.getConfigForEvent(eventType)); + LOGGER.debug("Read config file " + configFileData); + Smooks smooksTemp = new Smooks(new ByteArrayInputStream(configFileData.getBytes(StandardCharsets.UTF_8))); + eventToSmooksMapping.put(eventType, smooksTemp); + LOGGER.debug("Added smooks mapping for event type" + eventType); + } + + + LOGGER.debug("Read smooks mapping for event type" + eventType); + LOGGER.debug("Transforming incoming json now"); + VesEvent vesEvent = SmooksUtils.getTransformedObjectForInput(eventToSmooksMapping.get(eventType), incomingJsonString); + LOGGER.debug("Incoming json transformed to VES format successfully"); + ObjectMapper objectMapper = new ObjectMapper(); + result = objectMapper.writeValueAsString(vesEvent); + LOGGER.debug("Serialized VES json"); + } catch (JsonProcessingException exception) { + throw new VesException("Unable to convert pojo to VES format" + "\n Reason :" + exception.getMessage()); + } catch (SAXException | IOException exception) { + throw new ConfigFileSmooksConversionException("Unable to convert config file into smooks for event type " + eventType + + "\n Reason :" + exception.getMessage()); + } + return result; + } + + + /** + * Closes all open smooks' instances before bean is destroyed + */ + @PreDestroy + public void destroy(){ +// if(null != smooks) +// smooks.close(); + + for(Smooks smooks : eventToSmooksMapping.values()) + smooks.close(); + + LOGGER.debug("All Smooks objects closed"); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/Configuration.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/Configuration.java new file mode 100644 index 0000000..e47af70 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/Configuration.java @@ -0,0 +1,24 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.configs; + +public abstract class Configuration { + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfiguration.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfiguration.java new file mode 100644 index 0000000..2b9a820 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfiguration.java @@ -0,0 +1,56 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.configs; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Configuration for Dmaap MR Service + * + * @author kmalbari + * + */ +@Component +public class DMaapMrUrlConfiguration extends Configuration { + + @Value("${dmaap.url}") + private String url; + + @Value("${dmaap.consumer_props}") + private String consumerProperties; + + @Value("${dmaap.publisher_props}") + private String publisherProperties; + + public String getPublisherProperties() { + return publisherProperties; + } + + public String getConsumerProperties() { + return consumerProperties; + } + + public String getUrl() { + return url; + } + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DiskRepoConfiguration.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DiskRepoConfiguration.java new file mode 100644 index 0000000..b1daf0d --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/DiskRepoConfiguration.java @@ -0,0 +1,42 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.configs; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * + * Configuration for disk repository service + * + * @author kmalbari + * + */ +@Component +public class DiskRepoConfiguration extends Configuration { + + @Value("${fileService.url}") + private String fileRepositoryUrl; + + public String getFileRepositoryUrl() { + return fileRepositoryUrl; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/UniversalEventConfiguration.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/UniversalEventConfiguration.java new file mode 100644 index 0000000..3edca56 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/configs/UniversalEventConfiguration.java @@ -0,0 +1,73 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.configs; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Configuration for universal adapter service + * + * @author kmalbari + * + */ +@Component +public class UniversalEventConfiguration extends Configuration { + + private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); + + @Value("${snmpTrap.configFile}") + private String configFile; + + @Value("${universal.configFiles}") + private String configFiles; + + private Map eventToConfigFileMap = new ConcurrentHashMap<>(); + + + /** + * Returns config file for a particular event from the mapping. + * If mapping is empty, populates its + * + * @param eventType + * + * @return config file name + */ + public String getConfigForEvent(String eventType){ + LOGGER.debug("Getting config file name for event:" + eventType); + if(null != configFiles && eventToConfigFileMap.isEmpty()){ + for(String entry : configFiles.split(",")){ + eventToConfigFileMap.put(entry.split(":")[0], entry.split(":")[1]); + } + LOGGER.debug("Populated mappings for event type to config files"); + } + + return (null == eventToConfigFileMap.get(eventType)) ? "default" : eventToConfigFileMap.get(eventType) ; + + } + + + //think about adding mapping files on runtime as well + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/MockDmaapController.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/MockDmaapController.java new file mode 100644 index 0000000..e844270 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/MockDmaapController.java @@ -0,0 +1,37 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class MockDmaapController { + + @RequestMapping("/greeting") + public String greeting(@RequestParam(value="name", defaultValue="World") String name) { +// return new Greeting(counter.incrementAndGet(), +// String.format(template, name)); + return "{ \"protocol version\": \"v2c\", \"notify OID\": \".1.3.6.1.4.1.74.2.46.12.1.1\", \"cambria.partition\": \"dcae-snmp.client.research.att.com\" , \"trap category\": \"UCSNMP-HEARTBEAT\", \"epoch_serno\": 15161177410000, \"community\" : \"public\", \"time received\": 1516117741, \"agent name\": \"localhost\", \"agent address\": \"127.0.0.1\", \"community len\": 6, \"notify OID len\": 12, \"varbinds\": [ { \"varbind_type\": \"octet\", \"varbind_oid\": \".1.3.6.1.4.1.74.2.46.12.1.1.1\", \"varbind_value\": \"ucsnmp heartbeat - ignore\" }, { \"varbind_type\": \"octet\", \"varbind_oid\": \".1.3.6.1.4.1.74.2.46.12.1.1.2\", \"varbind_value\": \"Tue Jan 16 10:49:01 EST 2018\" } ] }"; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java new file mode 100644 index 0000000..588c912 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/controller/VesController.java @@ -0,0 +1,64 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.controller; + +import org.onap.universalvesadapter.service.VesService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * This controller will be starting point for this micro service. On triggering, it will listen to Dmaap topic for events. + * + * @author kmalbari + */ +@RestController +public class VesController { + + private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private VesService vesService; + + /** + * @return message that application is started + */ + @RequestMapping("/start") + public String start() { + + LOGGER.debug("UniversalVesAdapter Application starting..."); + vesService.start(); + return "Application started"; + } + + /** + * @return message that application stop process is triggered + */ + @RequestMapping("/stop") + public String stop() { + + vesService.stop(); + LOGGER.debug("UniversalVesAdapter Application is stopping..."); + return "Application will be stopped soon"; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/ConfigFileData.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/ConfigFileData.java new file mode 100644 index 0000000..796fe70 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/ConfigFileData.java @@ -0,0 +1,57 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +import org.springframework.data.annotation.Id; + +/** + * A domain wrapper class for saving the config file in Mongo DB + * + * @author kmalbari + * + */ +public class ConfigFileData { + + + @Id private String id; + + private String xmlFileName; + + private String xmlContent; + + public String getXmlFileName() { + return xmlFileName; + } + + public void setXmlFileName(String xmlFileName) { + this.xmlFileName = xmlFileName; + } + + public String getXmlContent() { + return xmlContent; + } + + public void setXmlContent(String xmlContent) { + this.xmlContent = xmlContent; + } + + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Domains.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Domains.java new file mode 100644 index 0000000..55812c4 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Domains.java @@ -0,0 +1,55 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum Domains { + + DOMAIN_FAULT("fault"), + /** A Fault event. */ + DOMAIN_HEARTBEAT("heartbeat"), + /** A Heartbeat event (event header only). */ + DOMAIN_MEASUREMENT_FOR_VFSCALLING("measurementsForVfScaling"), + /** A Measurement for VF Scaling event. */ + DOMAIN_MOBILE_FLOW("mobileFlow"), + /** A Mobile Flow event. */ + DOMAIN_OTHER("other"), + /** Another event. */ + DOMAIN_SIPSIGNALING("sipSignaling"), + /** A Signaling event. */ + DOMAIN_STATE_CHANGE("stateChange"), + /** A State Change event. */ + DOMAIN_SYSLOG("syslog"), + /** A Syslog event. */ + DOMAIN_THRESHOLD_CROSSING_ALERT("thresholdCrossingAlert"), + /** A Threshold crossing alert Event */ + DOMAIN_VOICE_QUALITY("voiceQuality"); + /** A Voice Quality Event */ + + private final String value; + + private Domains(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Priorities.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Priorities.java new file mode 100644 index 0000000..6b3ddfd --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Priorities.java @@ -0,0 +1,35 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum Priorities { + HIGH("High"), MEDIUM("Medium"), NORMAL("Normal"), LOW("Low"); + + private final String value; + + private Priorities(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Severity.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Severity.java new file mode 100644 index 0000000..1e200f5 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/Severity.java @@ -0,0 +1,36 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum Severity { + SEVERITY_CRITICAL("CRITICAL"), + SEVERITY_MAJOR("MAJOR"), + SEVERITY_MINOR("MINOR"), + SEVERITY_WARNING("WARNING"), + SEVERITY_NORMAL("NORMAL"); + + private final String value; + + private Severity(final String value) { + this.value = value; + } + + public String getValue() { return value; } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/State.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/State.java new file mode 100644 index 0000000..b6b8851 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/State.java @@ -0,0 +1,33 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum State { + STATE_IN_SERVICE("inService"), STATE_MAINTENANCE("maintenance"), STATE_OUT_OF_SERVICE("outOfService"); + private final String value; + + private State(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/SysLogSeverity.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/SysLogSeverity.java new file mode 100644 index 0000000..5cee6ad --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/SysLogSeverity.java @@ -0,0 +1,50 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum SysLogSeverity { + + SEVERITY_EMERGENCY("Emergency"), + /** system is unusable */ + SEVERITY_ALERT("Alert"), + /** action must be taken immediately */ + SEVERITY_CRITICAL("Critical"), + /** critical conditions */ + SEVERITY_ERROR("Error"), + /** error conditions */ + SEVERITY_WARNING("Warning"), + /** warning conditions */ + SEVERITY_NOTICE("Notice"), + /** normal but significant condition */ + SEVERITY_INFO("Info"), + /** Informational: informational messages */ + SEVERITY_DEBUG("Debug"); + /** debug-level messages */ + + private final String value; + + private SysLogSeverity(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertAction.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertAction.java new file mode 100644 index 0000000..928698f --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertAction.java @@ -0,0 +1,33 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum TcaAlertAction { + SET("SET"), CONTINUE("CONT"), CLEAR("CLEAR"); + private final String value; + + private TcaAlertAction(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertType.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertType.java new file mode 100644 index 0000000..5130378 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaAlertType.java @@ -0,0 +1,34 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum TcaAlertType { + CARD_ANOMALY("CARD-ANOMALY"), INTERFACE_ANOMALY("INTERFACE_ANOMALY"), ELEMENT_ANOMALY( + "ELEMENT-ANOMALY"), SERVICE_ANOMALY("SERVICE-ANOMALY"); + private final String value; + + private TcaAlertType(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaCounterCriticality.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaCounterCriticality.java new file mode 100644 index 0000000..9f8e126 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaCounterCriticality.java @@ -0,0 +1,33 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum TcaCounterCriticality { + CRITICAL("CRIT"), MAJOR("MAJ"); + private final String value; + + private TcaCounterCriticality(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaEventSeverity.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaEventSeverity.java new file mode 100644 index 0000000..6e73fa2 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/TcaEventSeverity.java @@ -0,0 +1,36 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum TcaEventSeverity { + SEVERITY_CRITICAL("CRITICAL"), SEVERITY_MAJOR("MAJOR"), SEVERITY_MINOR("MINOR"), SEVERITY_WARNING( + "WARNING"), SEVERITY_NORMAL("NORMAL"); + + private final String value; + + private TcaEventSeverity(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/VnfStatus.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/VnfStatus.java new file mode 100644 index 0000000..828c71e --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/domain/VnfStatus.java @@ -0,0 +1,37 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.domain; + +public enum VnfStatus { + + VFSTATUS_ACTIVE("Active"), + VFSTATUS_IDLE("Idle"), + VFSTATUS_PREP_TERMINATE("Preparing to terminate"), + VFSTATUS_READY_TERMINATE("Ready to terminate"), + VFSTATUS_REQ_TERMINATE("Requesting Termination"); + + private final String value; + + private VnfStatus(final String value) { + this.value = value; + } + + public String getValue() { return value; } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileReadException.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileReadException.java new file mode 100644 index 0000000..3a64247 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileReadException.java @@ -0,0 +1,38 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.exception; + +/** + * Exception when unable to connect to Config file Disk repository + * + * @author kmalbari + * + */ +public class ConfigFileReadException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 414953072485703000L; + + public ConfigFileReadException(String exceptionMessage) { + super(exceptionMessage); + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionException.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionException.java new file mode 100644 index 0000000..1daa939 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionException.java @@ -0,0 +1,40 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.exception; + +/** + * + * Exception thrown when config file data is unable to be parsed correctly in Smooks configuration + * + * @author kmalbari + * + */ +public class ConfigFileSmooksConversionException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 7128340575013771888L; + + public ConfigFileSmooksConversionException(String string) { + super(string); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/DMaapException.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/DMaapException.java new file mode 100644 index 0000000..5af0205 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/DMaapException.java @@ -0,0 +1,41 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.exception; + +/** + * Exception generated when dealing with communication to DMaap MR API + * + * @author kmalbari + * + */ +public class DMaapException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 7045766597511192878L; + + public DMaapException(String string) { + super(string); + } + + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/MapperConfigException.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/MapperConfigException.java new file mode 100644 index 0000000..a8414d8 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/MapperConfigException.java @@ -0,0 +1,45 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.exception; + +import java.io.IOException; + +/** + * Exception thrown during mapping config operations + * + * @author kmalbari + * + */ +public class MapperConfigException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -7876042513908918292L; + + public MapperConfigException(String string) { + // TODO Auto-generated constructor stub + } + + public MapperConfigException(String string, IOException exception) { + // TODO Auto-generated constructor stub + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/VesException.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/VesException.java new file mode 100644 index 0000000..31134c8 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/exception/VesException.java @@ -0,0 +1,40 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.exception; + +/** + * + * Exception thrown when VES Event was not generated correctly + * + * @author kmalbari + * + */ +public class VesException extends Exception { + + + /** + * + */ + private static final long serialVersionUID = -8549819066568432382L; + + public VesException(String string) { + super(string); + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Entry.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Entry.java new file mode 100644 index 0000000..54a77a0 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Entry.java @@ -0,0 +1,114 @@ + +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.mappingconfig; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "priority", + "evaluation", + "result" +}) +public class Entry { + + @JsonProperty("priority") + private Integer priority; + @JsonProperty("evaluation") + private Evaluation evaluation; + @JsonProperty("result") + private String result; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("priority") + public Integer getPriority() { + return priority; + } + + @JsonProperty("priority") + public void setPriority(Integer priority) { + this.priority = priority; + } + + @JsonProperty("evaluation") + public Evaluation getEvaluation() { + return evaluation; + } + + @JsonProperty("evaluation") + public void setEvaluation(Evaluation evaluation) { + this.evaluation = evaluation; + } + + @JsonProperty("result") + public String getResult() { + return result; + } + + @JsonProperty("result") + public void setResult(String result) { + this.result = result; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("priority", priority).append("evaluation", evaluation).append("result", result).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(result).append(additionalProperties).append(priority).append(evaluation).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof Entry) == false) { + return false; + } + Entry rhs = ((Entry) other); + return new EqualsBuilder().append(result, rhs.result).append(additionalProperties, rhs.additionalProperties).append(priority, rhs.priority).append(evaluation, rhs.evaluation).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Evaluation.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Evaluation.java new file mode 100644 index 0000000..e34b98a --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/Evaluation.java @@ -0,0 +1,208 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.mappingconfig; + +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.lang.builder.ToStringBuilder; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "operand", + "field", + "value", + "datatype", + "lhs", + "rhs" +}) +public class Evaluation { + + + @JsonProperty("operand") + private String operand; + @JsonProperty("field") + private String field; + @JsonProperty("value") + private String value; + @JsonProperty("datatype") + private String datatype; + @JsonProperty("lhs") + private Evaluation lhs; + @JsonProperty("rhs") + private Evaluation rhs; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("operand") + public String getOperand() { + return operand; + } + + @JsonProperty("operand") + public void setOperand(String operand) { + this.operand = operand; + } + + @JsonProperty("field") + public String getField() { + return field; + } + + @JsonProperty("field") + public void setField(String field) { + this.field = field; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @JsonProperty("datatype") + public String getDatatype() { + return datatype; + } + + @JsonProperty("datatype") + public void setDatatype(String datatype) { + this.datatype = datatype; + } + + @JsonProperty("lhs") + public Evaluation getLhs() { + return lhs; + } + + @JsonProperty("lhs") + public void setLhs(Evaluation lhs) { + this.lhs = lhs; + } + + @JsonProperty("rhs") + public Evaluation getRhs() { + return rhs; + } + + @JsonProperty("rhs") + public void setRhs(Evaluation rhs) { + this.rhs = rhs; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("operand", operand).append("field", field).append("value", value).append("datatype", datatype).append("lhs", lhs).append("rhs", rhs).append("additionalProperties", additionalProperties).toString(); + } + /* + @Override + public int hashCode() { + return new HashCodeBuilder().append(field).append(additionalProperties).append(value).append(rhs).append(datatype).append(operand).append(lhs).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof Evaluation) == false) { + return false; + } + Evaluation rhs = ((Evaluation) other); + return new EqualsBuilder().append(field, rhs.field).append(additionalProperties, rhs.additionalProperties).append(value, rhs.value).append(rhs, rhs.rhs).append(datatype, rhs.datatype).append(operand, rhs.operand).append(lhs, rhs.lhs).isEquals(); + } +*/ + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((datatype == null) ? 0 : datatype.hashCode()); + result = prime * result + ((field == null) ? 0 : field.hashCode()); + result = prime * result + ((lhs == null) ? 0 : lhs.hashCode()); + result = prime * result + ((operand == null) ? 0 : operand.hashCode()); + result = prime * result + ((rhs == null) ? 0 : rhs.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Evaluation other = (Evaluation) obj; + if (datatype == null) { + if (other.datatype != null) + return false; + } else if (!datatype.equals(other.datatype)) + return false; + if (field == null) { + if (other.field != null) + return false; + } else if (!field.equals(other.field)) + return false; + if (lhs == null) { + if (other.lhs != null) + return false; + } else if (!lhs.equals(other.lhs)) + return false; + if (operand == null) { + if (other.operand != null) + return false; + } else if (!operand.equals(other.operand)) + return false; + if (rhs == null) { + if (other.rhs != null) + return false; + } else if (!rhs.equals(other.rhs)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/MapperConfig.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/MapperConfig.java new file mode 100644 index 0000000..6055e86 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/mappingconfig/MapperConfig.java @@ -0,0 +1,88 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.mappingconfig; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "entries" +}) +public class MapperConfig { + + @JsonProperty("entries") + private Set entries = null; + @JsonIgnore + private Map additionalProperties = new HashMap(); + + @JsonProperty("entries") + public Set getEntries() { + return entries; + } + + @JsonProperty("entries") + public void setEntries(Set entries) { + this.entries = entries; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("entries", entries).append("additionalProperties", additionalProperties).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(additionalProperties).append(entries).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if ((other instanceof MapperConfig) == false) { + return false; + } + MapperConfig rhs = ((MapperConfig) other); + return new EqualsBuilder().append(additionalProperties, rhs.additionalProperties).append(entries, rhs.entries).isEquals(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/AdapterService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/AdapterService.java new file mode 100644 index 0000000..14c5a83 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/AdapterService.java @@ -0,0 +1,57 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +//import org.onap.universalvesadapter.adapter.GenericAdapter; +//import org.onap.universalvesadapter.adapter.UniversalEventAdapter; +//import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This service is written to identify the different type of events + * + * @author kmalbari + * + */ +@Component +public class AdapterService { + + /*@Autowired + private UniversalEventAdapter snmpTrapEventAdapter; + public GenericAdapter identifyIncomingJsonFormatAndReturnAdapter() { + return snmpTrapEventAdapter; + }*/ + + + /** + * Identifies eventype by parsing the incoming json file. + * + * @param incomingJsonString + * + * @return the event type + */ + public String identifyEventTypeFromIncomingJson(String incomingJsonString) { + + //TODO A proper logic to identify diffeent events is needed here + return "snmp"; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/ConfigFileService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/ConfigFileService.java new file mode 100644 index 0000000..09e2592 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/ConfigFileService.java @@ -0,0 +1,41 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +import org.onap.universalvesadapter.exception.ConfigFileReadException; + +/** + * A contract defined for services that will handle the operations of config file + * + * @author kmalbari + * + */ +public interface ConfigFileService { + + /** + * Returns the config file data + * + * @param fileName + * @return config file content + * @throws ConfigFileReadException if unable to read config file + */ + String readConfigFile(String fileName) throws ConfigFileReadException; + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DMaapService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DMaapService.java new file mode 100644 index 0000000..0b318eb --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DMaapService.java @@ -0,0 +1,155 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; +import org.onap.universalvesadapter.configs.DMaapMrUrlConfiguration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +//import com.att.nsa.mr.client.MRBatchingPublisher; +//import com.att.nsa.mr.client.MRClientFactory; +//import com.att.nsa.mr.client.MRConsumer; + +/** + * + * This service will handle all the communication with the DMaap MR API + * + * + * @author kmalbari + * + */ +@Component +public class DMaapService { + + @Autowired + private DMaapMrUrlConfiguration dmaapMrUrlObject; + +// private MRConsumer cc; +// +// private MRBatchingPublisher pub; + + /** + * reads the messages on DMaap MR Topic + * + * @return iterable of messages that will be received on DMaap MR Topic + * + * @throws DMaapException + */ + /*public Iterable consumeFromDMaap() throws DMaapException{ + if(null == cc){ + try { + cc = MRClientFactory.createConsumer (dmaapMrUrlObject.getConsumerProperties()); + } catch (IOException exception) { + throw new DMaapException("Problem creating consumer \nReason : " + exception.getMessage()); + } + + try { + return cc.fetch(); + } catch (Exception exception) { + throw new DMaapException("Problem while fetching messaged from consumer \nReason : " + exception.getMessage()); + } + } + return () -> Collections.emptyIterator(); + + }*/ + + + /** + * sends the messages to DMaap MR Topic + * + * + * @throws DMaapException + */ + /*public void publishToDMaap() throws DMaapException{ + if(null == cc){ + try { + pub = MRClientFactory.createBatchingPublisher (dmaapMrUrlObject.getPublisherProperties()); + } catch (IOException exception) { + throw new DMaapException("Problem creating consumer \nReason : " + exception.getMessage()); + } + + } + + }*/ + + + + + /** + * @return + */ + public String consume(){ + URL url; + StringBuffer incomingJson = null; + incomingJson = new StringBuffer(); + try { + url = new URL(dmaapMrUrlObject.getUrl()); + + //open the connection to the above URL. + URLConnection urlcon = url.openConnection(); + + Map> header = urlcon.getHeaderFields(); + + //print all the fields along with their value. + for (Map.Entry> mp : header.entrySet()) + { + System.out.print(mp.getKey() + " : "); + System.out.println(mp.getValue().toString()); + } + System.out.println(); + System.out.println("Complete source code of the URL is-"); + System.out.println("---------------------------------"); + + //get the inputstream of the open connection. + BufferedReader br = new BufferedReader(new InputStreamReader + (urlcon.getInputStream())); + String tempString; + //print the source code line by line. + while ((tempString = br.readLine()) != null) + { + System.out.println(tempString); + incomingJson.append(tempString); + } + + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return incomingJson.toString(); + } + + + + + + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DiskRepoConfigFileService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DiskRepoConfigFileService.java new file mode 100644 index 0000000..c2a30f0 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/DiskRepoConfigFileService.java @@ -0,0 +1,73 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.onap.universalvesadapter.configs.DiskRepoConfiguration; +import org.onap.universalvesadapter.exception.ConfigFileReadException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +/** + * Implementation of {@code ConfigFileService} using disk repository + * + * @author kmalbari + * + */ +@Component +public class DiskRepoConfigFileService implements ConfigFileService { + + private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private DiskRepoConfiguration diskRepoConfiguration; + + private RestTemplate restTemplate = new RestTemplate(); + + private URI uri = null; + + /* (non-Javadoc) + * @see org.onap.universalvesadapter.service.ConfigFileService#readConfigFile(java.lang.String) + */ + @Override + public String readConfigFile(String fileName) throws ConfigFileReadException { + LOGGER.debug("Reading config file for " + fileName); + if(null == uri){ + try { + uri = new URI(diskRepoConfiguration.getFileRepositoryUrl()+fileName); + LOGGER.debug("Read URI for " + fileName); + } catch (URISyntaxException exception) { + throw new ConfigFileReadException("Unable to read config file for file " + + fileName + "\n Reason : " + exception.getMessage()); + } + } + LOGGER.debug("Calling file repo service for URI" + uri); + ResponseEntity fileDataEntity = restTemplate.getForEntity(uri, String.class); + LOGGER.debug("Call completed successfully"); + return fileDataEntity.getBody(); + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/MongoDbConfigFileService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/MongoDbConfigFileService.java new file mode 100644 index 0000000..bab304a --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/MongoDbConfigFileService.java @@ -0,0 +1,46 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +import org.onap.universalvesadapter.domain.ConfigFileData; +import org.springframework.stereotype.Component; + +/** + * Service to use mongo db as config file repository + * + * @author kmalbari + * + */ +@Component +public class MongoDbConfigFileService implements ConfigFileService { + + /* (non-Javadoc) + * @see org.onap.universalvesadapter.service.ConfigFileService#readConfigFile(java.lang.String) + */ + public String readConfigFile(String configFileName){ + //HERE CONFIG FILE DATA WOULD COME FROM MONGO DB + ConfigFileData configFileData = new ConfigFileData(); + configFileData.setXmlFileName(""); + configFileData.setXmlContent(" "); + return configFileData.getXmlContent(); + } + + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VesService.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VesService.java new file mode 100644 index 0000000..81cb4b8 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/service/VesService.java @@ -0,0 +1,128 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.service; + +import javax.annotation.Resource; +import org.onap.universalvesadapter.adapter.GenericAdapter; +import org.onap.universalvesadapter.exception.ConfigFileReadException; +import org.onap.universalvesadapter.exception.ConfigFileSmooksConversionException; +import org.onap.universalvesadapter.exception.VesException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Service that starts the universal ves adapter module to listen for events + * + * @author kmalbari + * + */ +@Component +public class VesService { + + private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); + + private boolean isRunning = true; + + @Autowired + private DMaapService dmaapService; + + @Autowired + private AdapterService adapterService; + + @Resource(name="universalEventAdapter") + private GenericAdapter eventAdapter; + + @Value("${messagesInBatch}") + private int messagesInBatch; + + /*public void start(){ + + String incomingJsonString = dmaapService.consume(); + if(!"".equals(incomingJsonString)){ + GenericAdapter eventAdapter = adapterService.identifyIncomingJsonFormatAndReturnAdapter(); + String outgoingJsonString = eventAdapter.transform(incomingJsonString); + System.out.println(outgoingJsonString); + } + }*/ + + + /** + * method triggers universal ves adapter module + */ + public void start() { + /*ParallelTasks parallelTasks = new ParallelTasks(); + int processingNumberOfMessage = 0; + while (isRunning) { + try { + for(String incomingJsonString : dmaapService.consumeFromDMaap()){ + parallelTasks.add(() -> processReceivedJson(incomingJsonString)); + processingNumberOfMessage++; + if(processingNumberOfMessage == messagesInBatch){ + parallelTasks.startParallelTasks(); + processingNumberOfMessage=0; + parallelTasks = new ParallelTasks(); + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + } + } + } + } catch (DMaapException e) { + } + }*/ + String incomingJsonString = dmaapService.consume(); + processReceivedJson(incomingJsonString); + } + + /** + * It finds mapping file for received json, transforms json to VES format + * and publishes it to outgoing DMaap MR Topic + * + * @param incomingJsonString + */ + private void processReceivedJson(String incomingJsonString) { + try { + LOGGER.debug("Received incoming message" + incomingJsonString); + if (!"".equals(incomingJsonString)) { + String eventType = adapterService.identifyEventTypeFromIncomingJson(incomingJsonString); + LOGGER.debug("Event identified as " + eventType); + String outgoingJsonString; + outgoingJsonString = eventAdapter.transform(incomingJsonString, eventType); + LOGGER.debug("Output VES json to be sent " + outgoingJsonString); + } + } catch (ConfigFileReadException | ConfigFileSmooksConversionException | VesException exception) { + LOGGER.error(exception.getMessage()); + } + } + + /** + * method stops universal ves adapter module + */ + public void stop() { + + isRunning = false; + } +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java new file mode 100644 index 0000000..e94cdf5 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/MapperConfigUtils.java @@ -0,0 +1,322 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.utils; + +import com.att.aft.dme2.internal.apache.commons.lang3.EnumUtils; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.Set; +import java.util.TreeSet; +import org.onap.universalvesadapter.exception.MapperConfigException; +import org.onap.universalvesadapter.mappingconfig.Entry; +import org.onap.universalvesadapter.mappingconfig.Evaluation; +import org.onap.universalvesadapter.mappingconfig.MapperConfig; + +/** + * This class will be utility class to read the mapper config file and parse the + * config to prepare the grammar to detect the incoming json's event type. + * + * @author kmalbari + * + */ +public class MapperConfigUtils { + + private static Set entries = new TreeSet<>((o1, o2) -> o1.getPriority().compareTo(o2.getPriority())); + + private enum JoinOperator { + AND("AND"), OR("OR"); + + private final String value; + + private JoinOperator(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + private enum ExpressionOperator { + EQUALS("EQUALS"), STARTSWITH("STARTSWITH"), ENDSWITH("ENDSWITH"), CONTAINS("CONTAINS"); + + private final String value; + + private ExpressionOperator(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + private enum DataType { + STRING("STRING"), DOUBLE("DOUBLE"); + + private final String value; + + private DataType(final String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + /** + * main method. + * + * @param args + * arguments + */ + public static void main(String[] args) { + + String mappingFile = " { " + " \"entries\": [{ " + " \"priority\": 4, " + " \"evaluation\": { " + + " \"operand\": \"AND\", " + " \"field\": null, " + " \"value\": null, " + + " \"datatype\": null, " + " \"lhs\": { " + " \"operand\": \"OR\", " + + " \"field\": null, " + " \"value\": null, " + + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"domain\", " + + " \"value\": \"snmp-heartbeat\", " + " \"datatype\": \"string\", " + + " \"lhs\": null, " + " \"rhs\": null " + " }, " + + " \"rhs\": { " + " \"operand\": \"EQUALS\", " + + " \"field\": \"domain\", " + " \"value\": \"snmp-fault\", " + + " \"datatype\": \"string\", " + " \"lhs\": null, " + + " \"rhs\": null " + " } " + " }, " + " \"rhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"trap version\", " + + " \"value\": \"1.2\", " + " \"datatype\": \"float\", " + + " \"lhs\": null, " + " \"rhs\": null " + " } " + " }, " + + " \"result\": \"smooks.config\" " + " }, { " + " \"priority\": 1, " + + " \"evaluation\": { " + " \"operand\": \"AND\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"OR\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"domain\", " + + " \"value\": \"snmp-heartbeat\", " + " \"datatype\": \"string\", " + + " \"lhs\": null, " + " \"rhs\": null " + " }, " + + " \"rhs\": { " + " \"operand\": \"EQUALS\", " + + " \"field\": \"domain\", " + " \"value\": \"snmp-fault\", " + + " \"datatype\": \"string\", " + " \"lhs\": null, " + + " \"rhs\": null " + " } " + " }, " + " \"rhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"trap version\", " + + " \"value\": \"1.2\", " + " \"datatype\": \"float\", " + + " \"lhs\": null, " + " \"rhs\": null " + " } " + " }, " + + " \"result\": \"smooks.config\" " + " }, { " + " \"priority\": 3, " + + " \"evaluation\": { " + " \"operand\": \"AND\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"OR\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"domain\", " + + " \"value\": \"snmp-heartbeat\", " + " \"datatype\": \"string\", " + + " \"lhs\": null, " + " \"rhs\": null " + " }, " + + " \"rhs\": { " + " \"operand\": \"EQUALS\", " + + " \"field\": \"domain\", " + " \"value\": \"snmp-fault\", " + + " \"datatype\": \"string\", " + " \"lhs\": null, " + + " \"rhs\": null " + " } " + " }, " + " \"rhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"trap version\", " + + " \"value\": \"1.2\", " + " \"datatype\": \"float\", " + + " \"lhs\": null, " + " \"rhs\": null " + " } " + " }, " + + " \"result\": \"smooks.config\" " + " }, { " + " \"priority\": 2, " + + " \"evaluation\": { " + " \"operand\": \"AND\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"OR\", " + " \"field\": null, " + + " \"value\": null, " + " \"datatype\": null, " + " \"lhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"domain\", " + + " \"value\": \"snmp-heartbeat\", " + " \"datatype\": \"string\", " + + " \"lhs\": null, " + " \"rhs\": null " + " }, " + + " \"rhs\": { " + " \"operand\": \"EQUALS\", " + + " \"field\": \"domain\", " + " \"value\": \"snmp-fault\", " + + " \"datatype\": \"string\", " + " \"lhs\": null, " + + " \"rhs\": null " + " } " + " }, " + " \"rhs\": { " + + " \"operand\": \"EQUALS\", " + " \"field\": \"trap version\", " + + " \"value\": \"1.2\", " + " \"datatype\": \"float\", " + + " \"lhs\": null, " + " \"rhs\": null " + " } " + " }, " + + " \"result\": \"smooks.config\" " + " }] " + "}"; + String incomingJsonString = "{\"domain\":\"snmp-heartbeat\",\"trap version\":1.2}"; + + try { + readMapperConfigFile(mappingFile); + checkIncomingJsonForMatchingDomain(incomingJsonString); + } catch (MapperConfigException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * Checks incoming json to see which of the domain it mathces as per mapper + * config entries. If nothing matches, a default mapping will be used. + * + * @param incomingJsonString + * incoming json + * @throws MapperConfigException + * if error occurs in operation + */ + public static String checkIncomingJsonForMatchingDomain(String incomingJsonString) throws MapperConfigException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode actualObj = null; + try { + actualObj = mapper.readTree(incomingJsonString); + } catch (IOException exception) { + throw new MapperConfigException("Unable to read incoming json in a tree " + exception.getMessage(), + exception); + } + for (Entry entry : entries) { + + boolean result = false; + result = evaluateEntryMatch(entry.getEvaluation(), actualObj); + if (result) { + return entry.getResult(); + } + } + return "default"; + } + + /** + * Reads the mapper config file. + * + * @param mappingFileData + * string json for mapper config + * @throws MapperConfigException + * if error in mapper config + */ + public static void readMapperConfigFile(String mappingFileData) throws MapperConfigException { + + ObjectMapper name = new ObjectMapper(); + MapperConfig config = null; + try { + config = name.readValue(mappingFileData, MapperConfig.class); + } catch (IOException exception) { + throw new MapperConfigException("Unable to read config file for reason...\n " + exception.getMessage(), + exception); + } + System.out.println("Read config file content into :" + config); + if (null != config) { + entries.addAll(config.getEntries()); + } else { + throw new MapperConfigException("Unable to generate configuration for different domains."); + } + } + + /** + * Evaluates the passed in {@code Evaluation} instance and return boolean + * result. + * + * @param evaluation + * evaluation instance + * @param actualObj + * Json node with values to compare with + * @return true if matches evaluation else false + * @throws MapperConfigException + * error in evaluation + */ + public static boolean evaluateEntryMatch(Evaluation evaluation, JsonNode actualObj) throws MapperConfigException { + if (null == evaluation) { + throw new MapperConfigException("Cannot have null evaluation"); + } + if (null != evaluation.getOperand()) { + + if (EnumUtils.isValidEnum(JoinOperator.class, evaluation.getOperand())) { + // if(JOIN_OPERATOR.contains(evaluation.getOperand())){ + switch (JoinOperator.valueOf(evaluation.getOperand())) { + case AND: + return evaluateEntryMatch(evaluation.getLhs(), actualObj) + && evaluateEntryMatch(evaluation.getRhs(), actualObj); + case OR: + return evaluateEntryMatch(evaluation.getLhs(), actualObj) + || evaluateEntryMatch(evaluation.getRhs(), actualObj); + default: + break; + } + } + + if (EnumUtils.isValidEnum(ExpressionOperator.class, evaluation.getOperand())) { + // if(EXPR_OPERATOR.contains(evaluation.getOperand())){ + + // currently it is assumed field being compared is first level + // child of incoming JSON structure. + // If needed, can write a JsonPath implementation later + String field = evaluation.getField(); + if (null != field && null != evaluation.getDatatype() && actualObj.has(field)) { + switch (ExpressionOperator.valueOf(evaluation.getOperand())) { + case EQUALS: + if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) { + switch (DataType.valueOf(evaluation.getDatatype())) { + case STRING: + if (null != actualObj.get(field)) + return actualObj.get(field).asText().equals(evaluation.getValue()); + case DOUBLE: + if (null != actualObj.get(field)) + return actualObj.get(field).asDouble() == Double + .valueOf(evaluation.getValue()); + default: + return false; + } + } else + return false; + case STARTSWITH: + if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) { + switch (DataType.valueOf(evaluation.getDatatype())) { + case STRING: + if (null != actualObj.get(field)) + return actualObj.get(field).asText().startsWith(evaluation.getValue()); + default: + return false; + } + } else + return false; + case ENDSWITH: + if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) { + switch (DataType.valueOf(evaluation.getDatatype())) { + case STRING: + if (null != actualObj.get(field)) + return actualObj.get(field).asText().endsWith(evaluation.getValue()); + default: + return false; + } + } else + return false; + case CONTAINS: + if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) { + switch (DataType.valueOf(evaluation.getDatatype())) { + case STRING: + if (null != actualObj.get(field)) + return actualObj.get(field).asText().contains(evaluation.getValue()); + default: + return false; + } + } else + return false; + default: + return false; + } + } + } + } else + throw new MapperConfigException("Not an expected operand as per config for " + evaluation.getField()); + + return false; + } + +} diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/ParallelTasks.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/ParallelTasks.java new file mode 100644 index 0000000..45fdf96 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/ParallelTasks.java @@ -0,0 +1,87 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * + * Utility class to execute parallel tasks + * + * @author kmalbari + * + */ +public class ParallelTasks +{ + private final Collection tasks = new ArrayList(); + + public ParallelTasks() + { + } + + /** + * + * Add task to be executed in parallel + * + * @param task + */ + public void add(final Runnable task) + { + tasks.add(task); + } + + /** + * starts all the added tasks in parallel + * + * @throws InterruptedException + */ + public void startParallelTasks() throws InterruptedException + { + final ExecutorService threads = Executors.newFixedThreadPool(Runtime.getRuntime() + .availableProcessors()); + try + { + final CountDownLatch latch = new CountDownLatch(tasks.size()); + for (final Runnable task : tasks) + threads.execute(new Runnable() { + public void run() + { + try + { + task.run(); + } + finally + { + latch.countDown(); + } + } + }); + latch.await(); + } + finally + { + threads.shutdown(); + } + } +} \ No newline at end of file diff --git a/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/SmooksUtils.java b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/SmooksUtils.java new file mode 100644 index 0000000..df36da6 --- /dev/null +++ b/UniversalVesAdapter/src/main/java/org/onap/universalvesadapter/utils/SmooksUtils.java @@ -0,0 +1,76 @@ +/* +* ============LICENSE_START======================================================= +* ONAP : DCAE +* ================================================================================ +* Copyright 2018 TechMahindra +*================================================================================= +* 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.universalvesadapter.utils; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Locale; +import javax.xml.transform.stream.StreamSource; +import org.milyn.Smooks; +import org.milyn.container.ExecutionContext; +import org.milyn.payload.StringResult; +import org.onap.dcaegen2.ves.domain.VesEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Utility methods for smooks module + * + * @author kmalbari + * + */ +public class SmooksUtils { + + + private final static Logger LOGGER = LoggerFactory.getLogger(SmooksUtils.class); + + /** + * converts the incoming json using passed smooks instance and return the pojo representation of VES event + * + * @param smooks smooks object for the event type + * @param incomingJsonString + * @return VES json's pojo representation + * @throws IOException + */ + public static VesEvent getTransformedObjectForInput(Smooks smooks, String incomingJsonString) { + + LOGGER.debug("Transforming json " + incomingJsonString); + ExecutionContext executionContext = smooks.createExecutionContext(); + LOGGER.debug("Context created"); + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(new Locale("en", "IE")); + + StringResult result = new StringResult(); + + // Configure the execution context to generate a report... +// executionContext.setEventListener(new HtmlReportGenerator("target/report/report.html")); + + // Filter the input message to the outputWriter, using the execution context... + smooks.filterSource(executionContext, new StreamSource(new ByteArrayInputStream(incomingJsonString.getBytes(StandardCharsets.UTF_8))), result); + LOGGER.debug("Transformed incoming json now"); + Locale.setDefault(defaultLocale); + VesEvent vesEvent = (VesEvent) executionContext.getBeanContext().getBean("vesEvent"); + LOGGER.debug("Converted vesEvent from incoming json"); + return vesEvent; + } + +} diff --git a/UniversalVesAdapter/src/main/resources/MapperConfig.json b/UniversalVesAdapter/src/main/resources/MapperConfig.json new file mode 100644 index 0000000..e39c822 --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/MapperConfig.json @@ -0,0 +1,16 @@ +{ + "entries" : [ + { + "priority" : 1, + "evaluation" : { + "operand" : "EQUALS", + "field" : "notify OID", + "value" : ".1.3.6.1.4.1.74.2.46.12.1.1", + "datatype" : "string", + "lhs" : null, + "rhs" : null + }, + "result" : "snmp" + } + ] +} \ No newline at end of file diff --git a/UniversalVesAdapter/src/main/resources/MapperConfigFullFormat.json b/UniversalVesAdapter/src/main/resources/MapperConfigFullFormat.json new file mode 100644 index 0000000..059dc2e --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/MapperConfigFullFormat.json @@ -0,0 +1,56 @@ +{ + "entries" : [ + { + "priority" : 1, + "evaluation" : { + "operand" : "EQUALS", + "field" : "notify OID", + "value" : ".1.3.6.1.4.1.74.2.46.12.1.1", + "datatype" : "string", + "lhs" : null, + "rhs" : null + }, + "result" : "snmpTrapToVes.xml" + }, + { + "priority" : 2, + "evaluation" : { + "operand" : "AND", + "field" : null, + "value" : null, + "datatype" : null, + "lhs" : { + "operand" : "OR", + "field" : null, + "value" : null, + "datatype" : null, + "lhs" : { + "operand" : "EQUALS", + "field" : "domain", + "value" : "snmp-heartbeat", + "datatype" : "string", + "lhs" : null, + "rhs" : null + }, + "rhs" : { + "operand" : "EQUALS", + "field" : "domain", + "value" : "snmp-fault", + "datatype" : "string", + "lhs" : null, + "rhs" : null + } + }, + "rhs" : { + "operand" : "EQUALS", + "field" : "trap version", + "value" : "1.2", + "datatype" : "float", + "lhs" : null, + "rhs" : null + } + }, + "result" : "smooks.config" + } + ] +} \ No newline at end of file diff --git a/UniversalVesAdapter/src/main/resources/application.properties b/UniversalVesAdapter/src/main/resources/application.properties new file mode 100644 index 0000000..a0c32b4 --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/application.properties @@ -0,0 +1,10 @@ +logging.level.org.springframework.web=ERROR +logging.level.org.onap.universalvesadapter=DEBUG +dmaap.url=http://localhost:8091/greeting +snmpTrap.configFile=snmpTrapToVes.xml +universal.configFiles=snmp:snmpTrapToVes.xml,default:defaultConfig.xml +fileService.url=http://localhost:8888/fileAsString/ +messagesInBatch=1000 +dmaap.consumer_props=/src/main/resources/dme2/consumer.properties +dmaap.publisher_props=/src/main/resources/dme2/publisher.properties +server.port=8091 \ No newline at end of file diff --git a/UniversalVesAdapter/src/main/resources/dme2/consumer.properties b/UniversalVesAdapter/src/main/resources/dme2/consumer.properties new file mode 100644 index 0000000..6ba59d1 --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/dme2/consumer.properties @@ -0,0 +1,61 @@ + + + + +
###############################################################################
+#  ============LICENSE_START=======================================================
+#  org.onap.dmaap
+#  ================================================================================
+#  Copyright � 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=========================================================
+#
+#  ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#  
+###############################################################################
+TransportType=DME2
+Latitude =47.778998
+Longitude =-122.182883
+Version =1.0
+ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+Environment =TEST
+Partner=BOT_R
+routeOffer=MR1
+SubContextPath =/
+Protocol =http
+MethodType =GET
+username =<att uid>
+password =<password>
+contenttype =application/json
+authKey=<auth key>
+authDate=2016-02-18T13:57:37-0800
+#host=uebsb91bodc.it.att.com:3904
+host=<host>:<port>
+topic=com.att.ecomp_test.crm.preDemo1
+group=con
+id=5
+timeout=15000
+limit=1000
+filter=
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=15000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=/src/main/resources/dme2/preferredRoute.txt
+
+
+
diff --git a/UniversalVesAdapter/src/main/resources/dme2/preferredRoute.properties b/UniversalVesAdapter/src/main/resources/dme2/preferredRoute.properties new file mode 100644 index 0000000..506df76 --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/dme2/preferredRoute.properties @@ -0,0 +1,5 @@ + + + + +
preferredRouteKey=MR1
diff --git a/UniversalVesAdapter/src/main/resources/dme2/producer.properties b/UniversalVesAdapter/src/main/resources/dme2/producer.properties new file mode 100644 index 0000000..fb9e639 --- /dev/null +++ b/UniversalVesAdapter/src/main/resources/dme2/producer.properties @@ -0,0 +1,59 @@ + + + + +
###############################################################################
+#  ============LICENSE_START=======================================================
+#  org.onap.dmaap
+#  ================================================================================
+#  Copyright � 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=========================================================
+#
+#  ECOMP is a trademark and service mark of AT&T Intellectual Property.
+#  
+###############################################################################
+TransportType=DME2
+Latitude =47.778998
+Longitude =-122.182883
+Version =1.0
+ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+#com.att.acsi.saat.dt.dmaap.dev.mrclientnew1
+Environment =TEST
+Partner=BOT_R
+routeOffer=MR1
+SubContextPath =/
+Protocol =http
+MethodType =POST
+username =<att uid>
+password =<global logon password>
+contenttype = application/json
+authKey=<auth key>
+authDate=2016-07-20T11:30:56-0700
+host=<host>:<port>
+topic=com.att.ecomp_test.crm.preDemo1
+#host=uebsb91bodc.it.att.com:3904
+partition=1
+maxBatchSize=100
+maxAgeMs=250
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=15000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=/src/main/resources/dme2/preferredRoute.txt
+MessageSentThreadOccurance=50
+
diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..15c2e26 --- /dev/null +++ b/pom.xml @@ -0,0 +1,675 @@ + + + + + 4.0.0 + + + org.onap.oparent + oparent + 1.1.0 + + + + org.onap.dcaegen2.services.mapper + mapper + 0.0.1-SNAPSHOT + pom + + dcae-services-mapper + Universal VES mapper for DCAE Analytics Service + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + + UTF-8 + UTF-8 + ${project.basedir} + + + true + + 1.7.25 + 2.9.4 + + 0.16.0 + 2.2.4 + 13.0.1 + 3.0 + 1.0.9 + 2.0.1 + 3.0.0 + 1.16.10 + + 2.2.0 + 2.2.0 + 4.5.2 + 3.5 + + + + 4.12 + 2.2.0 + 1.4.0 + 2.5.7 + 1.2.5 + + + + 3.3 + 2.19.1 + 2.19.1 + 2.5.4 + 1.7 + 2.10 + 3.0.2 + 3.5 + 2.19.1 + 2.16 + 2.10.4 + 2.4 + 2.4 + 1.16.10.0 + 1.0-m5.1 + 2.2.3 + 3.5.1 + 2.5 + 2.7 + + + + 1.8 + 1.8 + **/*Test.java + false + **/*IT.java + true + + true + true + checkstyle.xml + suppressions.xml + false + https://nexus.onap.org + content/repositories/snapshots/ + content/repositories/releases/ + + content/sites/site/org/onap/dcaegen2/services/mapper/${project.artifactId}/${project.version} + + + + + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + provided + + + + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + + + + + + + + junit + junit + ${junit.version} + test + + + + org.mockito + mockito-core + ${mockito.version} + + + + com.jayway.jsonpath + json-path-assert + ${jayway.jsonpath.version} + test + + + + + + + + + + + + ${project.basedir}/src/main/resources + + + ${project.build.directory}/git + + + + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 1.0-beta-7 + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.plugin.version} + + ${compiler.target.version} + ${compiler.source.version} + + + + + + org.apache.maven.plugins + maven-source-plugin + ${source.plugin.version} + + true + + + + attach-sources + verify + + jar-no-fork + + + + + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + *;inline=false;scope=compile + true + lib + + + + + Bundling mapper Jar + package + + bundle + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + ${autorun.plugin.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.plugin.version} + + ${skip.unit.tests} + -Xmx2048m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC + -XX:OnOutOfMemoryError="kill -9 %p" -XX:+HeapDumpOnOutOfMemoryError + + ${surefire.redirectTestOutputToFile} + methods + 8 + 8 + true + xml + false + + ${project.build.directory} + + ${basedir}/src/test/resources/logback-test.xml + + ${project.build.directory} + + + ${unit.test.pattern} + + + ${integration.test.pattern} + + + ${surefireArgLine} + + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.plugin.version} + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${failsafe.plugin.version} + + + integration-tests + + integration-test + verify + + + ${skip.integration.tests} + + + ${failsafeArgLine} + + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + ${findbugs.plugin.version} + + Max + Low + true + + ${findbugs.failOnError} + ${main.basedir}/findbugs-exclude.xml + ${project.reporting.outputDirectory}/findbugs + ${project.reporting.outputDirectory}/findbugs + + + + + analyze-compile + compile + + check + + + + + + + + + + + + + org.apache.maven.plugins + maven-eclipse-plugin + ${eclipe.plugin.version} + + + + + + + pl.project13.maven + git-commit-id-plugin + ${gitcommitid.plugin.version} + + + generate-git-properties + generate-resources + + revision + + + false + true + + ${project.build.directory}/git/git.properties + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + ${jar.plugin.version} + + + + true + + + ${project.version} + + + + + + + org.apache.maven.plugins + maven-site-plugin + ${maven.site.plugin} + + + + org.apache.maven.plugins + maven-jxr-plugin + ${jxr.plugin.version} + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${project.info.reports.plugin.version} + + false + false + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${surefire.report.plugin.version} + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + org.apache.maven.plugins + maven-source-plugin + + + + + + + + + + + pl.project13.maven + git-commit-id-plugin + + + + + + + + + org.apache.maven.plugins + maven-site-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + ${checkstyle.file.name} + ${checkstyle.suppression.file.name} + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + + + + + doclint-java8-disable + + [1.8,) + + + + + + + + + + + UniversalVesAdapter + + + + -- 2.16.6