--- /dev/null
+#\r
+# ============LICENSE_START====================================================\r
+# =============================================================================\r
+# Copyright (c) 2019 TechMahindra. All rights reserved.\r
+# =============================================================================\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+# ============LICENSE_END======================================================\r
+\r
+description: "This blueprint deploys the UniversalVESAdapter(UVA) as a Docker container\n"\r
+imports: \r
+ - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"\r
+ - "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R3/k8splugin/1.4.4/k8splugin_types.yaml"\r
+inputs: \r
+ rcc_notification_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unathenticated.DCAE_RCC_OUTPUT"\r
+ type: string\r
+ snmp_notification_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.ONAP-COLLECTOR-SNMPTRAP"\r
+ type: string\r
+ tag_version: \r
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest"\r
+ type: string\r
+ universal_mapper_name: \r
+ default: dcaegen2-svc-mapper\r
+ type: string\r
+ ves_fault_publish_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.SEC_FAULT_OUTPUT"\r
+ type: string\r
+ ves_measurement_publish_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_MEASUREMENT_OUTPUT"\r
+ type: string\r
+ ves_notification_publish_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_NOTIFICATION_OUTPUT"\r
+ type: string\r
+ ves_pnfRegistration_publish_url: \r
+ default: "http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_PNFREG_OUTPUT"\r
+ type: string\r
+node_templates: \r
+ universalvesadapter: \r
+ interfaces: \r
+ cloudify.interfaces.lifecycle: \r
+ start: \r
+ inputs: \r
+ envs: \r
+ CONFIG_BINDING_SERVICE: config_binding_service\r
+ max_wait: 3600\r
+ ports: \r
+ - "80:0"\r
+ properties: \r
+ application_config: \r
+ app_preferences: \r
+ collectors: \r
+ - \r
+ identifier: notification-id\r
+ mapping-files: \r
+ - \r
+ defaultMappingFile-rcc-notification: "<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /></json:keyMap></json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='pnfRegistrationFields' beanIdRef='pnfRegistrationFields' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1</jb:expression><jb:expression property='eventType'>'pnfRegistration'</jb:expression><jb:expression property='vesEventListenerVersion'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1</jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'registration_'+commonEventHeader.ts1</jb:expression><jb:expression property='reportingEntityName'>'VESMapper'</jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION</jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain</jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:expression property='lastEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1</jb:expression><jb:expression property='startEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1</jb:expression><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL</jb:expression><jb:expression property='sourceName' execOnElement='vesevent'>pnfRegistrationFields.vendorName+'-'+pnfRegistrationFields.serialNumber</jb:expression></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields' beanId='pnfRegistrationFields' createOnElement='vesevent'><jb:expression property='pnfRegistrationFieldsVersion'>org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0</jb:expression><jb:value property='serialNumber' data='pnfRegistration/serialNumber' /><jb:value property='lastServiceDate' data='pnfRegistration/lastServiceDate' /><jb:value property='manufactureDate' data='pnfRegistration/manufactureDate' /><jb:value property='modelNumber' data='pnfRegistration/modelNumber' /><jb:value property='oamV4IpAddress' data='pnfRegistration/oamV4IpAddress' /><jb:value property='oamV6IpAddress' data='pnfRegistration/oamV6IpAddress' /><jb:value property='softwareVersion' data='pnfRegistration/softwareVersion' /><jb:value property='unitFamily' data='pnfRegistration/unitFamily' /><jb:value property='unitType' data='pnfRegistration/unitType' /><jb:value property='vendorName' data='pnfRegistration/vendorName' /><jb:wiring property='additionalFields' beanIdRef='alarmAdditionalInformation' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.AlarmAdditionalInformation' beanId='alarmAdditionalInformation' createOnElement='vesevent'><jb:wiring property='additionalProperties' beanIdRef='additionalFields2' /></jb:bean><jb:bean beanId='additionalFields2' class='java.util.HashMap' createOnElement='vesevent/pnfRegistration/additionalFields'><jb:value data='pnfRegistration/additionalFields/*'/></jb:bean></smooks-resource-list>"\r
+ stream_publisher: ves-pnfRegistration\r
+ stream_subscriber: rcc-notification\r
+ streams_publishes: \r
+ ves-fault: \r
+ dmaap_info: \r
+ topic_url: \r
+ get_input: ves_fault_publish_url\r
+ type: message_router\r
+ ves-pnfRegistration: \r
+ dmaap_info: \r
+ topic_url: \r
+ get_input: ves_pnfRegistration_publish_url\r
+ type: message_router\r
+ streams_subscribes: \r
+ rcc-notification: \r
+ dmaap_info: \r
+ topic_url: \r
+ get_input: rcc_notification_url\r
+ type: message_router\r
+ snmp-notification: \r
+ dmaap_info: \r
+ topic_url: \r
+ get_input: snmp_notification_url\r
+ type: message_router\r
+ docker_config: {}\r
+ image: \r
+ get_input: tag_version\r
+ service_component_type: \r
+ get_input: universal_mapper_name\r
+ type: dcae.nodes.ContainerizedServiceComponent\r
+tosca_definitions_version: cloudify_dsl_1_3\r
+++ /dev/null
-{ \r
- "app_preferences":{ \r
- "collectors":[ \r
- { \r
- "identifier":"notification-id",\r
- "subscriberTopic":"ONAP-COLLECTOR-RESTCONFTRAP",\r
- "mapping-files":[ \r
- { \r
- "defaultMappingFile-ONAP-COLLECTOR-RESTCONFTRAP":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /><\/json:keyMap><\/json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='pnfRegistrationFields' beanIdRef='pnfRegistrationFields' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1<\/jb:expression><jb:expression property='eventType'>'pnfRegistration'<\/jb:expression><jb:expression property='vesEventListenerVersion'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1<\/jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'registration_'+commonEventHeader.ts1<\/jb:expression><jb:expression property='reportingEntityName'>'VESMapper'<\/jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION<\/jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain<\/jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:expression property='lastEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1<\/jb:expression><jb:expression property='startEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1<\/jb:expression><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL<\/jb:expression><jb:value property='sourceName' data='notification/message/target' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields' beanId='pnfRegistrationFields' createOnElement='vesevent'><jb:expression property='pnfRegistrationFieldsVersion'>org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0<\/jb:expression><jb:value property='serialNumber' data='notification/message/content/onu/sn' /><\/jb:bean><\/smooks-resource-list>"\r
- }\r
- ]\r
- },\r
- { \r
- "identifier":"notify OID",\r
- "subscriberTopic":"ONAP-COLLECTOR-SNMPTRAP",\r
- "mapping-files":[ \r
- { \r
- "defaultMappingFile-ONAP-COLLECTOR-SNMPTRAP":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /></json:keyMap></json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='faultFields' beanIdRef='faultFields'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>'3.0'</jb:expression><jb:expression property='eventType'>'FaultField'</jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'XXXX'</jb:expression><jb:expression property='reportingEntityName'>'VESMapper'</jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Domain.FAULT</jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain</jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:value property='lastEpochMicrosec' data='#/time-received' /><jb:value property='startEpochMicrosec' data='#/time-received' /><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Priority.NORMAL</jb:expression><jb:expression property='sourceName'>'VesAdapter'</jb:expression></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.FaultFields' beanId='faultFields' createOnElement='vesevent'><jb:value property='faultFieldsVersion' data='2.0' default='2.0' decoder='Double' /><jb:value property='alarmCondition' data='#/trap-category' /><jb:expression property='specificProblem'>'SNMP Fault'</jb:expression><jb:expression property='vfStatus'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.VfStatus.ACTIVE</jb:expression><jb:expression property='eventSeverity'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.EventSeverity.MINOR</jb:expression><jb:wiring property='alarmAdditionalInformation' beanIdRef='alarmAdditionalInformationroot'/></jb:bean><jb:bean class='java.util.ArrayList' beanId='alarmAdditionalInformationroot' createOnElement='vesevent'><jb:wiring beanIdRef='alarmAdditionalInformation'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.AlarmAdditionalInformation' beanId='alarmAdditionalInformation' createOnElement='varbinds/element'><jb:value property='name' data='#/varbind_oid'/><jb:value property='value' data='#/varbind_value' /></jb:bean></smooks-resource-list>"\r
- }\r
- ]\r
- }\r
- ]\r
- }\r
-}
\ No newline at end of file
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-* ============LICENSE_START=======================================================
-* ONAP : DCAEGEN2
-* ================================================================================
-* Copyright 2018-2019 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=========================================================
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.onap.dcaegen2.services.mapper.vesadapter</groupId>
- <artifactId>UniversalVesAdapter</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
-
- <parent>
- <groupId>org.onap.dcaegen2.services.mapper</groupId>
- <artifactId>mapper</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <properties>
-
- <!-- PROJECT SETTINGS -->
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <java.version>8</java.version>
- <docker.image.name>onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor</docker.image.name>
-
- <!-- PLUGIN SETTINGS -->
- <dependency.locations.enabled>false</dependency.locations.enabled>
-
- <!-- NEXUS RELATED SETTINGS -->
- <nexusproxy>https://nexus.onap.org</nexusproxy>
- <snapshots.path>content/repositories/snapshots/</snapshots.path>
- <releases.path>content/repositories/releases/</releases.path>
- <site.path>
- content/sites/site/org/onap/dcaegen2/services/mapper/${project.artifactId}/${project.version}
- </site.path>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
-
- </properties>
- <dependencies>
- <!-- Junit, Mockito, PowerMock -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.0.5-beta</version>
- <scope>test</scope>
-</dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.18.2-GA</version>
- </dependency>
- <dependency>
- <groupId>com.googlecode.json-simple</groupId>
- <artifactId>json-simple</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- <version>1.10</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.8.5</version>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.5</version>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-assistedinject</artifactId>
- <version>4.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.milyn</groupId>
- <artifactId>milyn-smooks-all</artifactId>
- <version>1.7.0</version>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>ognl</groupId>
- <artifactId>ognl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>ognl</groupId>
- <artifactId>ognl</artifactId>
- <version>3.1.12</version>
- </dependency>
- <dependency>
- <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
- <artifactId>dmaapClient</artifactId>
- <version>1.1.3</version>
- <exclusions>
- <exclusion>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- Database dependency -->
- <dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>42.2.5</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>5.1.3.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <version>2.1.1.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <version>2.1.1.RELEASE</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-commons</artifactId>
- <version>2.1.3.RELEASE</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>2.4.14</version>
- </dependency>
- <dependency>
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- <version>2.4.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.7</version>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.10</version>
- <scope>test</scope>
- </dependency>
- <!-- https://mvnrepository.com/artifact/xalan/xalan -->
- <dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- <version>2.7.2</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.12.0</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
- <dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <version>1.4.10</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->
- <dependency>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- <version>1.4.01</version>
- </dependency>
- <!-- http client -->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>${httpclient.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>${httpclient.version}</version>
- <scope>compile</scope>
- </dependency>
- <!-- <dependency> <groupId>org.onap.aai.event-client</groupId> <artifactId>event-client-dmaap</artifactId>
- <version>1.2.0</version> </dependency> -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- <optional>true</optional>
- <version>2.1.1.RELEASE</version>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>3.1.0</version>
- </plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>1.0.0</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <reuseForks>false</reuseForks>
- <forkCount>1</forkCount>
- </configuration>
- </plugin> -->
-
-
-
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/dep.xml</descriptor>
- </descriptors>
- <attach>false</attach>
- <appendAssemblyId>false</appendAssemblyId>
- <updateOnly>true</updateOnly>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>1.0.0</version>
- <configuration>
- <skipDockerBuild>false</skipDockerBuild>
- <serverId>${onap.nexus.dockerregistry.daily}</serverId>
- <imageName>${onap.nexus.dockerregistry.daily}/${docker.image.name}</imageName>
- <imageTags>
- <tag>latest</tag>
- <tag>${project.version}-${maven.build.timestamp}Z</tag>
- <tag>${project.version}</tag>
- </imageTags>
- <baseImage>ubuntu:16.04</baseImage>
- <env>
- <HOSTALIASES>/etc/host.aliases</HOSTALIASES>
- </env>
- <workdir>/opt/app/VESAdapter</workdir>
- <resources>
- <resource>
- <targetPath>.</targetPath>
- <directory>${project.build.directory}/${project.artifactId}-${project.version}</directory>
- </resource>
- </resources>
- <runs>
- <run>chmod +x bin/run.sh</run>
- <run>
- <![CDATA[apt-get update && apt-get install -y curl && apt-get install -y openjdk-8-jdk && apt-get install -y vim && apt-get clean all]]>
- </run>
- </runs>
- <exposes>
- <expose>8080</expose>
- <expose>8443</expose>
- </exposes>
- <entryPoint>bin/run.sh</entryPoint>
-
- </configuration>
- <!--<executions>
- <execution>
- <id>build-image</id>
- <phase>package</phase>
- <goals>
- <goal>build</goal>
- </goals>
- </execution>
- <execution>
- <id>tag-and-push-image-latest</id>
- <phase>deploy</phase>
- <goals>
- <goal>tag</goal>
- </goals>
- <configuration>
- <image>${docker.image.name}:latest</image>
- <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName>
- <pushImage>true</pushImage>
- </configuration>
- </execution>
- <execution>
- <id>tag-and-push-image-with-version</id>
- <phase>deploy</phase>
- <goals>
- <goal>tag</goal>
- </goals>
- <configuration>
- <image>${docker.image.name}:latest</image>
- <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}
- </newName>
- <pushImage>true</pushImage>
- </configuration>
- </execution>
- <execution>
- <id>tag-and-push-image-with-version-and-date</id>
- <phase>deploy</phase>
- <goals>
- <goal>tag</goal>
- </goals>
- <configuration>
- <image>${docker.image.name}:latest</image>
- <newName>
- ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z
- </newName>
- <pushImage>true</pushImage>
- </configuration>
- </execution>
- </executions>-->
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>2.1.1.RELEASE</version>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- <configuration>
- <mainClass>org.onap.universalvesadapter.Application</mainClass>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.9.1</version>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>src/gen/java</source>
- </sources>
- </configuration>
- </execution>
- <!-- <execution> <id>regex-property</id> <goals> <goal>regex-property</goal>
- </goals> <configuration> <name>docker.version</name> <value>${project.version}</value>
- <regex>(^[0-9]+.[0-9]+.[0-9]+$)</regex> <replacement>$1-STAGING</replacement>
- <failIfNoMatch>false</failIfNoMatch> </configuration> </execution> -->
- </executions>
- </plugin>
- </plugins>
- <!-- <finalName>UniversalVesAdapter</finalName> -->
- </build>
-
- <profiles>
- <profile>
- <id>with-system-proxy</id>
- <build>
- <plugins>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <configuration>
- <buildArgs>
- <http_proxy>${env.http_proxy}</http_proxy>
- </buildArgs>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-
- <repositories>
- <repository>
- <id>spring-releases</id>
- <url>https://repo.spring.io/libs-release</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>spring-releases</id>
- <url>https://repo.spring.io/libs-release</url>
- </pluginRepository>
- </pluginRepositories>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!-- \r
+* ============LICENSE_START=======================================================\r
+* ONAP : DCAEGEN2\r
+* ================================================================================\r
+* Copyright 2018-2019 TechMahindra\r
+*=================================================================================\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+* ============LICENSE_END=========================================================\r
+ -->\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+ <modelVersion>4.0.0</modelVersion>\r
+\r
+ <groupId>org.onap.dcaegen2.services.mapper.vesadapter</groupId>\r
+ <artifactId>UniversalVesAdapter</artifactId>\r
+ <version>1.0.0-SNAPSHOT</version>\r
+\r
+\r
+ <parent>\r
+ <groupId>org.onap.dcaegen2.services.mapper</groupId>\r
+ <artifactId>mapper</artifactId>\r
+ <version>1.0.0-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <properties>\r
+\r
+ <!-- PROJECT SETTINGS -->\r
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\r
+ <java.version>8</java.version>\r
+ <docker.image.name>onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor</docker.image.name>\r
+\r
+ <!-- PLUGIN SETTINGS -->\r
+ <dependency.locations.enabled>false</dependency.locations.enabled>\r
+\r
+ <!-- NEXUS RELATED SETTINGS -->\r
+ <nexusproxy>https://nexus.onap.org</nexusproxy>\r
+ <snapshots.path>content/repositories/snapshots/</snapshots.path>\r
+ <releases.path>content/repositories/releases/</releases.path>\r
+ <site.path>\r
+ content/sites/site/org/onap/dcaegen2/services/mapper/${project.artifactId}/${project.version}\r
+ </site.path>\r
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>\r
+\r
+ </properties>\r
+ <dependencies>\r
+ <!-- Junit, Mockito, PowerMock -->\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.12</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.mockito</groupId>\r
+ <artifactId>mockito-core</artifactId>\r
+ <version>2.0.5-beta</version>\r
+ <scope>test</scope>\r
+</dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.powermock</groupId>\r
+ <artifactId>powermock-api-mockito</artifactId>\r
+ <version>1.6.2</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.powermock</groupId>\r
+ <artifactId>powermock-module-junit4</artifactId>\r
+ <version>1.6.2</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.javassist</groupId>\r
+ <artifactId>javassist</artifactId>\r
+ <version>3.18.2-GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.googlecode.json-simple</groupId>\r
+ <artifactId>json-simple</artifactId>\r
+ <version>1.1.1</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.google.guava</groupId>\r
+ <artifactId>guava</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-configuration</groupId>\r
+ <artifactId>commons-configuration</artifactId>\r
+ <version>1.10</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.google.code.gson</groupId>\r
+ <artifactId>gson</artifactId>\r
+ <version>2.8.5</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.google.inject</groupId>\r
+ <artifactId>guice</artifactId>\r
+ <version>4.2.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.apache.commons</groupId>\r
+ <artifactId>commons-lang3</artifactId>\r
+ <version>3.5</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.google.inject.extensions</groupId>\r
+ <artifactId>guice-assistedinject</artifactId>\r
+ <version>4.2.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.milyn</groupId>\r
+ <artifactId>milyn-smooks-all</artifactId>\r
+ <version>1.7.0</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>javax.servlet</groupId>\r
+ <artifactId>servlet-api</artifactId>\r
+ </exclusion>\r
+ <exclusion>\r
+ <groupId>ognl</groupId>\r
+ <artifactId>ognl</artifactId>\r
+ </exclusion>\r
+ <exclusion>\r
+ <groupId>javax.jms</groupId>\r
+ <artifactId>jms</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>ognl</groupId>\r
+ <artifactId>ognl</artifactId>\r
+ <version>3.1.12</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>\r
+ <artifactId>dmaapClient</artifactId>\r
+ <version>1.1.3</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>javax.jms</groupId>\r
+ <artifactId>jms</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <!-- Database dependency -->\r
+ <dependency>\r
+ <groupId>org.postgresql</groupId>\r
+ <artifactId>postgresql</artifactId>\r
+ <version>42.2.5</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-jdbc</artifactId>\r
+ <version>5.1.3.RELEASE</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.springframework.boot</groupId>\r
+ <artifactId>spring-boot-starter-web</artifactId>\r
+ <version>2.1.1.RELEASE</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.springframework.boot</groupId>\r
+ <artifactId>spring-boot-starter-test</artifactId>\r
+ <version>2.1.1.RELEASE</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.springframework.data</groupId>\r
+ <artifactId>spring-data-commons</artifactId>\r
+ <version>2.1.3.RELEASE</version>\r
+ </dependency>\r
+ <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ <version>1.7.25</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.codehaus.groovy</groupId>\r
+ <artifactId>groovy-all</artifactId>\r
+ <version>2.4.14</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.jayway.jsonpath</groupId>\r
+ <artifactId>json-path</artifactId>\r
+ <version>2.4.0</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.fasterxml.jackson.core</groupId>\r
+ <artifactId>jackson-databind</artifactId>\r
+ <version>2.9.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>hsqldb</groupId>\r
+ <artifactId>hsqldb</artifactId>\r
+ <version>1.8.0.10</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <!-- https://mvnrepository.com/artifact/xalan/xalan -->\r
+ <dependency>\r
+ <groupId>xalan</groupId>\r
+ <artifactId>xalan</artifactId>\r
+ <version>2.7.2</version>\r
+ </dependency>\r
+ <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->\r
+ <dependency>\r
+ <groupId>xerces</groupId>\r
+ <artifactId>xercesImpl</artifactId>\r
+ <version>2.12.0</version>\r
+ </dependency>\r
+ <!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->\r
+ <dependency>\r
+ <groupId>com.thoughtworks.xstream</groupId>\r
+ <artifactId>xstream</artifactId>\r
+ <version>1.4.10</version>\r
+ </dependency>\r
+ <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->\r
+ <dependency>\r
+ <groupId>xml-apis</groupId>\r
+ <artifactId>xml-apis</artifactId>\r
+ <version>1.4.01</version>\r
+ </dependency>\r
+ <!-- http client -->\r
+ <dependency>\r
+ <groupId>org.apache.httpcomponents</groupId>\r
+ <artifactId>httpclient</artifactId>\r
+ <version>${httpclient.version}</version>\r
+ <scope>compile</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.apache.httpcomponents</groupId>\r
+ <artifactId>httpmime</artifactId>\r
+ <version>${httpclient.version}</version>\r
+ <scope>compile</scope>\r
+ </dependency>\r
+ <!-- <dependency> <groupId>org.onap.aai.event-client</groupId> <artifactId>event-client-dmaap</artifactId> \r
+ <version>1.2.0</version> </dependency> -->\r
+ <dependency>\r
+ <groupId>org.springframework.boot</groupId>\r
+ <artifactId>spring-boot-configuration-processor</artifactId>\r
+ <optional>true</optional>\r
+ <version>2.1.1.RELEASE</version>\r
+ </dependency>\r
+ </dependencies>\r
+\r
+ <build>\r
+ <pluginManagement>\r
+ <plugins>\r
+ <plugin>\r
+ <artifactId>maven-assembly-plugin</artifactId>\r
+ <version>3.1.0</version>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>com.spotify</groupId>\r
+ <artifactId>docker-maven-plugin</artifactId>\r
+ <version>1.0.0</version>\r
+ </plugin>\r
+ </plugins>\r
+ </pluginManagement>\r
+ <plugins>\r
+ <!-- <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-plugin</artifactId>\r
+ <configuration>\r
+ <reuseForks>false</reuseForks>\r
+ <forkCount>1</forkCount>\r
+ </configuration>\r
+ </plugin> -->\r
+ \r
+ \r
+ \r
+ <plugin>\r
+ <artifactId>maven-assembly-plugin</artifactId>\r
+ <configuration>\r
+ <descriptors>\r
+ <descriptor>src/assembly/dep.xml</descriptor>\r
+ </descriptors>\r
+ <attach>false</attach>\r
+ <appendAssemblyId>false</appendAssemblyId>\r
+ <updateOnly>true</updateOnly>\r
+ </configuration>\r
+ <executions>\r
+ <execution>\r
+ <id>make-assembly</id>\r
+ <phase>package</phase>\r
+ <goals>\r
+ <goal>single</goal>\r
+ </goals>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>com.spotify</groupId>\r
+ <artifactId>docker-maven-plugin</artifactId>\r
+ <version>1.0.0</version>\r
+ <configuration>\r
+ <skipDockerBuild>false</skipDockerBuild>\r
+ <serverId>${onap.nexus.dockerregistry.daily}</serverId>\r
+ <imageName>${onap.nexus.dockerregistry.daily}/${docker.image.name}</imageName>\r
+ <imageTags>\r
+ <tag>latest</tag>\r
+ <tag>${project.version}-${maven.build.timestamp}Z</tag>\r
+ <tag>${project.version}</tag>\r
+ </imageTags>\r
+ <baseImage>ubuntu:16.04</baseImage>\r
+ <env>\r
+ <HOSTALIASES>/etc/host.aliases</HOSTALIASES>\r
+ </env>\r
+ <workdir>/opt/app/VESAdapter</workdir>\r
+ <resources>\r
+ <resource>\r
+ <targetPath>.</targetPath>\r
+ <directory>${project.build.directory}/${project.artifactId}-${project.version}</directory>\r
+ </resource>\r
+ </resources>\r
+ <runs>\r
+ <run>chmod +x bin/run.sh</run>\r
+ <run>\r
+ <![CDATA[apt-get update && apt-get install -y curl && apt-get install -y openjdk-8-jdk && apt-get install -y vim && apt-get clean all]]>\r
+ </run>\r
+ </runs>\r
+ <exposes>\r
+ <expose>8080</expose>\r
+ <expose>8443</expose>\r
+ </exposes>\r
+ <entryPoint>bin/run.sh</entryPoint>\r
+\r
+ </configuration>\r
+ <!--<executions>\r
+ <execution>\r
+ <id>build-image</id>\r
+ <phase>package</phase>\r
+ <goals>\r
+ <goal>build</goal>\r
+ </goals>\r
+ </execution>\r
+ <execution>\r
+ <id>tag-and-push-image-latest</id>\r
+ <phase>deploy</phase>\r
+ <goals>\r
+ <goal>tag</goal>\r
+ </goals>\r
+ <configuration>\r
+ <image>${docker.image.name}:latest</image>\r
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName>\r
+ <pushImage>true</pushImage>\r
+ </configuration>\r
+ </execution>\r
+ <execution>\r
+ <id>tag-and-push-image-with-version</id>\r
+ <phase>deploy</phase>\r
+ <goals>\r
+ <goal>tag</goal>\r
+ </goals>\r
+ <configuration>\r
+ <image>${docker.image.name}:latest</image>\r
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}\r
+ </newName>\r
+ <pushImage>true</pushImage>\r
+ </configuration>\r
+ </execution>\r
+ <execution>\r
+ <id>tag-and-push-image-with-version-and-date</id>\r
+ <phase>deploy</phase>\r
+ <goals>\r
+ <goal>tag</goal>\r
+ </goals>\r
+ <configuration>\r
+ <image>${docker.image.name}:latest</image>\r
+ <newName>\r
+ ${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z\r
+ </newName>\r
+ <pushImage>true</pushImage>\r
+ </configuration>\r
+ </execution>\r
+ </executions>-->\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.springframework.boot</groupId>\r
+ <artifactId>spring-boot-maven-plugin</artifactId>\r
+ <version>2.1.1.RELEASE</version>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>repackage</goal>\r
+ </goals>\r
+ <configuration>\r
+ <mainClass>org.onap.universalvesadapter.Application</mainClass>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>build-helper-maven-plugin</artifactId>\r
+ <version>1.9.1</version>\r
+ <executions>\r
+ <execution>\r
+ <id>add-source</id>\r
+ <phase>generate-sources</phase>\r
+ <goals>\r
+ <goal>add-source</goal>\r
+ </goals>\r
+ <configuration>\r
+ <sources>\r
+ <source>src/gen/java</source>\r
+ </sources>\r
+ </configuration>\r
+ </execution>\r
+ <!-- <execution> <id>regex-property</id> <goals> <goal>regex-property</goal> \r
+ </goals> <configuration> <name>docker.version</name> <value>${project.version}</value> \r
+ <regex>(^[0-9]+.[0-9]+.[0-9]+$)</regex> <replacement>$1-STAGING</replacement> \r
+ <failIfNoMatch>false</failIfNoMatch> </configuration> </execution> -->\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+ <!-- <finalName>UniversalVesAdapter</finalName> -->\r
+ </build>\r
+\r
+ <profiles>\r
+ <profile>\r
+ <id>with-system-proxy</id>\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>com.spotify</groupId>\r
+ <artifactId>docker-maven-plugin</artifactId>\r
+ <configuration>\r
+ <buildArgs>\r
+ <http_proxy>${env.http_proxy}</http_proxy>\r
+ </buildArgs>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+ </profile>\r
+ </profiles>\r
+\r
+\r
+ <repositories>\r
+ <repository>\r
+ <id>spring-releases</id>\r
+ <url>https://repo.spring.io/libs-release</url>\r
+ </repository>\r
+ </repositories>\r
+ <pluginRepositories>\r
+ <pluginRepository>\r
+ <id>spring-releases</id>\r
+ <url>https://repo.spring.io/libs-release</url>\r
+ </pluginRepository>\r
+ </pluginRepositories>\r
+</project>\r
public void setAdditionalProperty(String name, String value) {\r
this.additionalProperties.put(name, value);\r
}\r
+ @JsonAnySetter\r
+ public void setAdditionalProperties(Map<String, String> h) {\r
+ this.additionalProperties =h;\r
+ }\r
+\r
\r
@Override\r
public int hashCode() {\r
-/*\r
-* ============LICENSE_START=======================================================\r
-* ONAP : DCAE\r
-* ================================================================================\r
-* Copyright 2018-2019 TechMahindra\r
-*=================================================================================\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-* ============LICENSE_END=========================================================\r
-*/\r
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : DCAE\r
+ * ================================================================================\r
+ * Copyright 2018-2019 TechMahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
package org.onap.universalvesadapter.adapter;\r
\r
import java.io.ByteArrayInputStream;\r
import javax.annotation.PreDestroy;\r
\r
import org.milyn.Smooks;\r
-import org.onap.dcaegen2.ves.domain.ves70.VesEvent;\r
import org.onap.universalvesadapter.exception.ConfigFileSmooksConversionException;\r
import org.onap.universalvesadapter.exception.VesException;\r
import org.onap.universalvesadapter.service.VESAdapterInitializer;\r
\r
@Component\r
public class UniversalEventAdapter implements GenericAdapter {\r
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
- \r
- @Value("${defaultConfigFilelocation}")\r
- private String defaultConfigFilelocation;\r
- private String collectorIdentifierValue;\r
- private String collectorIdentifierKey;\r
- private Map<String, Smooks> eventToSmooksMapping = new ConcurrentHashMap<>();\r
-\r
- public UniversalEventAdapter() {\r
-\r
- }\r
-\r
- /**\r
- * transforms JSON to VES format and and returns the ves Event\r
- * \r
- * @param IncomingJason,eventType\r
- * @return ves Event\r
- */\r
- @Override\r
- public String transform(String incomingJsonString)\r
- throws ConfigFileSmooksConversionException, VesException {\r
- String result = "";\r
- String configFileData;\r
- \r
- String identifier[]= CollectorConfigPropertyRetrival.getProperyArray("identifier",defaultConfigFilelocation );\r
- String defaultMappingFile="defaultMappingFile-"+Thread.currentThread().getName();\r
- try {\r
-\r
- Gson gson = new Gson();\r
- JsonObject body = gson.fromJson(incomingJsonString, JsonObject.class);\r
- \r
- JsonElement results;\r
- for(int i=0;i<identifier.length;i++)\r
- {\r
- JsonObject obj;\r
- if((obj=keyObject(body,identifier[i])).has(identifier[i]))\r
- {\r
- collectorIdentifierKey=identifier[i];\r
- results=obj.get(identifier[i]);\r
- collectorIdentifierValue=results.getAsString();\r
- \r
- }\r
- \r
- }\r
- //collectorIdentifierValue = collectorIdentifierValue.substring(0, collectorIdentifierValue.length() - 4);\r
- if(collectorIdentifierKey.equals("notify OID"))\r
- {\r
- collectorIdentifierValue = collectorIdentifierValue.substring(0, collectorIdentifierValue.length() - 4);\r
- }\r
- \r
-\r
- if (VESAdapterInitializer.getMappingFiles().containsKey(collectorIdentifierValue)) {\r
- configFileData = VESAdapterInitializer.getMappingFiles().get(collectorIdentifierValue);\r
- debugLogger.debug("Using Mapping file as Mapping file is available for collector identifier:{}",collectorIdentifierValue);\r
- \r
- } else {\r
-\r
- configFileData = VESAdapterInitializer.getMappingFiles().get(defaultMappingFile);\r
- \r
- debugLogger.debug("Using Default Mapping file as Mapping file is not available for Enterprise Id:{}",collectorIdentifierValue);\r
- }\r
-\r
- Smooks smooksTemp = new Smooks(new ByteArrayInputStream(configFileData.getBytes(StandardCharsets.UTF_8)));\r
- eventToSmooksMapping.put(collectorIdentifierKey, smooksTemp);\r
-\r
- Object vesEvent = SmooksUtils.getTransformedObjectForInput(smooksTemp,incomingJsonString);\r
- debugLogger.info("Incoming json transformed to VES format successfully:"+Thread.currentThread().getName());\r
- ObjectMapper objectMapper = new ObjectMapper();\r
- result = objectMapper.writeValueAsString(vesEvent);\r
- debugLogger.info("Serialized VES json");\r
- } catch (JsonProcessingException exception) {\r
- throw new VesException("Unable to convert pojo to VES format, Reason :{}", exception);\r
- } catch (SAXException | IOException exception) {\r
- //Invalid Mapping file\r
- exception.printStackTrace();\r
- errorLogger.error("Dropping this Trap :{},Reason:{}", incomingJsonString, exception.getMessage()); \r
-\r
- } catch (JsonSyntaxException exception) {\r
- // Invalid Trap\r
- errorLogger.error("Dropping this Invalid json Trap :{}, Reason:{}", incomingJsonString, exception);\r
- }catch (JsonParseException exception) {\r
- // Invalid Trap\r
- errorLogger.error("Dropping this Invalid json Trap :{}, Reason:{}", incomingJsonString, exception);\r
- } \r
- catch (RuntimeException exception) {\r
-\r
- exception.printStackTrace();\r
- errorLogger.error("Dropping this Trap :{},Reason:{}", incomingJsonString, exception.getMessage());\r
-\r
- }\r
- return result;\r
- }\r
-\r
- /**\r
- * Closes all open smooks' instances before bean is destroyed\r
- */\r
- @PreDestroy\r
- public void destroy() {\r
- for (Smooks smooks : eventToSmooksMapping.values())\r
- smooks.close();\r
- debugLogger.warn("All Smooks objects closed");\r
- }\r
- \r
- public JsonObject keyObject(JsonObject object, String searchedKey) {\r
- boolean exists = object.has(searchedKey);\r
- JsonObject jsonObject = object;\r
- \r
- if(!exists) { \r
- Iterator<?> keys = object.keySet().iterator();\r
- while( keys.hasNext() ) {\r
- String key = (String)keys.next();\r
- if ( object.get(key) instanceof JsonObject ) {\r
- \r
- jsonObject=(JsonObject) object.get(key);\r
- JsonObject obj = keyObject(jsonObject, searchedKey);\r
- exists = obj.has(searchedKey);\r
- }\r
- }\r
- }\r
- \r
- return jsonObject;\r
- }\r
-\r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ \r
+ @Value("${defaultConfigFilelocation}")\r
+ private String defaultConfigFilelocation;\r
+ private String collectorIdentifierValue;\r
+ private String collectorIdentifierKey;\r
+ private Map<String, Smooks> eventToSmooksMapping = new ConcurrentHashMap<>();\r
+ \r
+ public UniversalEventAdapter() {\r
+ \r
+ }\r
+ \r
+ /**\r
+ * transforms JSON to VES format and and returns the ves Event\r
+ * \r
+ * @param IncomingJason,eventType\r
+ * @return ves Event\r
+ */\r
+ @Override\r
+ public String transform(String incomingJsonString)\r
+ throws ConfigFileSmooksConversionException, VesException {\r
+ String result = "";\r
+ String configFileData;\r
+ \r
+ String identifier[] = CollectorConfigPropertyRetrival.getProperyArray("identifier",\r
+ defaultConfigFilelocation);\r
+ String defaultMappingFile =\r
+ "defaultMappingFile-" + Thread.currentThread().getName();\r
+ try {\r
+ \r
+ Gson gson = new Gson();\r
+ JsonObject body = gson.fromJson(incomingJsonString, JsonObject.class);\r
+ \r
+ JsonElement results;\r
+ for (int i = 0; i < identifier.length; i++) {\r
+ JsonObject obj;\r
+ if ((obj = keyObject(body, identifier[i])).has(identifier[i])) {\r
+ collectorIdentifierKey = identifier[i];\r
+ results = obj.get(identifier[i]);\r
+ collectorIdentifierValue = results.getAsString();\r
+ \r
+ }\r
+ \r
+ }\r
+ // collectorIdentifierValue = collectorIdentifierValue.substring(0,\r
+ // collectorIdentifierValue.length() - 4);\r
+ if (collectorIdentifierKey.equals("notify OID")) {\r
+ collectorIdentifierValue = collectorIdentifierValue.substring(0,\r
+ collectorIdentifierValue.length() - 4);\r
+ }\r
+ \r
+ \r
+ if (VESAdapterInitializer.getMappingFiles()\r
+ .containsKey(collectorIdentifierValue)) {\r
+ configFileData = VESAdapterInitializer.getMappingFiles()\r
+ .get(collectorIdentifierValue);\r
+ debugLogger.debug(\r
+ "Using Mapping file as Mapping file is available for collector identifier:{}",\r
+ collectorIdentifierValue);\r
+ \r
+ } else {\r
+ \r
+ configFileData = VESAdapterInitializer.getMappingFiles()\r
+ .get(defaultMappingFile);\r
+ \r
+ debugLogger.debug(\r
+ "Using Default Mapping file as Mapping file is not available for Enterprise Id / identifer ID:{}",\r
+ collectorIdentifierValue);\r
+ }\r
+ \r
+ Smooks smooksTemp = new Smooks(new ByteArrayInputStream(\r
+ configFileData.getBytes(StandardCharsets.UTF_8)));\r
+ eventToSmooksMapping.put(collectorIdentifierKey, smooksTemp);\r
+ \r
+ Object vesEvent = SmooksUtils.getTransformedObjectForInput(smooksTemp,\r
+ incomingJsonString);\r
+ debugLogger.info("Incoming json transformed to VES format successfully:"\r
+ + Thread.currentThread().getName());\r
+ ObjectMapper objectMapper = new ObjectMapper();\r
+ result = objectMapper.writeValueAsString(vesEvent);\r
+ debugLogger.info("Serialized VES json");\r
+ } catch (JsonProcessingException exception) {\r
+ throw new VesException("Unable to convert pojo to VES format, Reason :{}",\r
+ exception);\r
+ } catch (SAXException | IOException exception) {\r
+ // Invalid Mapping file\r
+ exception.printStackTrace();\r
+ errorLogger.error("Dropping this Trap :{},Reason:{}", incomingJsonString,\r
+ exception.getMessage());\r
+ \r
+ } catch (JsonSyntaxException exception) {\r
+ // Invalid Trap\r
+ errorLogger.error("Dropping this Invalid json Trap :{}, Reason:{}",\r
+ incomingJsonString, exception);\r
+ } catch (JsonParseException exception) {\r
+ // Invalid Trap\r
+ errorLogger.error("Dropping this Invalid json Trap :{}, Reason:{}",\r
+ incomingJsonString, exception);\r
+ } catch (RuntimeException exception) {\r
+ \r
+ exception.printStackTrace();\r
+ errorLogger.error("Dropping this Trap :{},Reason:{}", incomingJsonString,\r
+ exception.getMessage());\r
+ \r
+ }\r
+ return result;\r
+ }\r
+ \r
+ /**\r
+ * Closes all open smooks' instances before bean is destroyed\r
+ */\r
+ @PreDestroy\r
+ public void destroy() {\r
+ for (Smooks smooks : eventToSmooksMapping.values())\r
+ smooks.close();\r
+ debugLogger.warn("All Smooks objects closed");\r
+ }\r
+ \r
+ public JsonObject keyObject(JsonObject object, String searchedKey) {\r
+ boolean exists = object.has(searchedKey);\r
+ JsonObject jsonObject = object;\r
+ \r
+ if (!exists) {\r
+ Iterator<?> keys = object.keySet().iterator();\r
+ while (keys.hasNext()) {\r
+ String key = (String) keys.next();\r
+ if (object.get(key) instanceof JsonObject) {\r
+ \r
+ jsonObject = (JsonObject) object.get(key);\r
+ JsonObject obj = keyObject(jsonObject, searchedKey);\r
+ exists = obj.has(searchedKey);\r
+ }\r
+ }\r
+ }\r
+ \r
+ return jsonObject;\r
+ }\r
+ \r
}\r
-/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * 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===========================================
- */
-
-
-//TO-DO Lisence Issue ASK to Kedar???????????
-package org.onap.universalvesadapter.configs;
-
-import java.io.IOException;
-import javax.annotation.Nonnull;
-import org.onap.universalvesadapter.utils.DmaapConfig;
-import com.att.aft.dme2.internal.springframework.context.annotation.ComponentScan;
-import com.google.common.base.Objects;
-
-/**
- * <p>
- * Immutable DMaaP MR Configuration for DMaaP MR Publisher.
- * <p>
- * Use {@link DMaaPMRPublisherConfig.Builder} to construct Subscriber
- * Configuration
- * </p>
- * <p>
- *
- * @author Rajiv Singla . Creation Date: 10/12/2016.
- *
- */
-@ComponentScan
-public class DMaaPMRPublisherConfig extends DMaaPMRBaseConfig {
-
-
- /**
- * Publisher batching queue size
- */
- private int maxBatchSize;
-
- /**
- * Publisher Recovery Queue Size
- */
- private int maxRecoveryQueueSize;
-
- /**
- * Default uri path prefix
- */
- private String dmaapUriPathPrefix ;
-
- private DMaaPMRPublisherConfig(Builder builder) {
- this.hostName = builder.hostName;
- this.portNumber = builder.portNumber;
- this.topicName = builder.topicName;
- this.protocol = builder.protocol;
- this.userName = builder.userName;
- this.userPassword = builder.userPassword;
- this.contentType = builder.contentType;
- this.maxBatchSize = builder.maxBatchSize;
- this.maxRecoveryQueueSize = builder.maxRecoveryQueueSize;
- this.dmaapUriPathPrefix = builder.dmaapUriPathPrefix;
- }
-
- /**
- * Builder to initialize immutable {@link DMaaPMRPublisherConfig} object
- */
- public static class Builder {
-
- private String hostName;
- private Integer portNumber;
- private String topicName;
- private String userName;
- private String userPassword;
- private String protocol;
- private String contentType;
- private int maxBatchSize;
- private int maxRecoveryQueueSize;
- private String dmaapUriPathPrefix ;
-
-
-
- public Builder(@Nonnull String hostName, @Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {
- this.hostName = hostName;
- this.topicName = topicName;
- // Default values
- this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();
- this.userName = dmaapConfig.getDEFAULT_USER_NAME();
- this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();
- this.protocol =dmaapConfig.getDEFAULT_PROTOCOL();
- this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();
-
- this.maxBatchSize =dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE();
- this.maxRecoveryQueueSize = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE();
- this.dmaapUriPathPrefix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();
- }
-
- /**
- * Setup for custom host port number - Defaults to 80.
- *
- * @param portNumber
- * custom port number
- * @return Builder object itself for chaining
- */
- public Builder setPortNumber(@Nonnull Integer portNumber) {
- this.portNumber = portNumber;
- return this;
- }
-
- /**
- * Setup user name for authentication. If no username is provided authentication
- * will be disabled
- *
- * @param userName
- * user name for DMaaP Topic Authentication
- * @return Builder object itself for chaining
- */
- public Builder setUserName(@Nonnull String userName) {
- this.userName = userName;
- return this;
- }
-
- /**
- * Setup user password for authentication. If no password is provided
- * authentication will be disabled
- *
- * @param userPassword
- * user password for DMaaP Topic Authentication
- * @return Builder object itself for chaining
- */
- public Builder setUserPassword(@Nonnull String userPassword) {
- this.userPassword = userPassword;
- return this;
- }
-
- /**
- * Setup custom Publisher protocol - Defaults to https. Note: Only http and
- * https are currently supported.
- *
- * @param protocol
- * protocol e.g. https
- * @return Builder object itself for chaining
- */
- public Builder setProtocol(@Nonnull String protocol) {
- this.protocol = normalizeValidateProtocol(protocol);
- return this;
- }
-
- /**
- * Setup custom Publisher content-type - Defaults to application/json
- *
- * @param contentType
- * content type e.g. application/json
- * @return Builder object itself for chaining
- */
- public Builder setContentType(@Nonnull String contentType) {
- final String normalizedContentType = normalizeValidateContentType(contentType);
- this.contentType = normalizedContentType;
- return this;
- }
-
- /**
- * Setup custom Publisher Max Batch Size - Defaults to 100
- *
- * @param maxBatchSize
- * max Batch Size
- * @return Builder object itself for chaining
- */
- public Builder setMaxBatchSize(int maxBatchSize) {
- this.maxBatchSize = maxBatchSize;
- return this;
- }
-
- /**
- * Setup custom Maximum Recovery Queue Size. Recovery Queue is used to hold
- * messages temporarily in case DMaaP MR Publisher topic is not responding for
- * any reason. Defaults to 100,000
- *
- * @param maxRecoveryQueueSize
- * max recovery queue size
- * @return Builder object itself for chaining
- */
- public Builder setMaxRecoveryQueueSize(int maxRecoveryQueueSize) {
- this.maxRecoveryQueueSize = maxRecoveryQueueSize;
- return this;
- }
-
-
- /**
- * Creates immutable instance of {@link DMaaPMRPublisherConfig}
- *
- * @return Builds and returns thread safe, immutable
- * {@link DMaaPMRPublisherConfig} object
- */
- public DMaaPMRPublisherConfig build() {
- return new DMaaPMRPublisherConfig(this);
- }
-
- }
- public String getDmaapUriPathPrefix() {
- return dmaapUriPathPrefix;
- }
-
- /**
- * Returns max Publisher Batch Queue Size
- *
- * @return max Publisher Batch Queue size
- */
- public int getMaxBatchSize() {
- return maxBatchSize;
- }
-
- /**
- * Returns max Publisher Recovery Queue Size
- *
- * @return max Recovery Queue size
- */
- public int getMaxRecoveryQueueSize() {
- return maxRecoveryQueueSize;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- if (!super.equals(o)) {
- return false;
- }
- DMaaPMRPublisherConfig that = (DMaaPMRPublisherConfig) o;
- return maxBatchSize == that.maxBatchSize && maxRecoveryQueueSize == that.maxRecoveryQueueSize;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), maxBatchSize, maxRecoveryQueueSize);
- }
-
-}
+/*\r
+ * ===============================LICENSE_START======================================\r
+ * dcae-analytics\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============================LICENSE_END===========================================\r
+ */\r
+\r
+\r
+//TO-DO Lisence Issue ASK to Kedar???????????\r
+package org.onap.universalvesadapter.configs;\r
+\r
+import java.io.IOException;\r
+import javax.annotation.Nonnull;\r
+import org.onap.universalvesadapter.utils.DmaapConfig;\r
+import com.att.aft.dme2.internal.springframework.context.annotation.ComponentScan;\r
+import com.google.common.base.Objects;\r
+\r
+/**\r
+ * <p>\r
+ * Immutable DMaaP MR Configuration for DMaaP MR Publisher.\r
+ * <p>\r
+ * Use {@link DMaaPMRPublisherConfig.Builder} to construct Subscriber\r
+ * Configuration\r
+ * </p>\r
+ * <p>\r
+ * \r
+ * @author Rajiv Singla . Creation Date: 10/12/2016.\r
+ * \r
+ */\r
+@ComponentScan\r
+public class DMaaPMRPublisherConfig extends DMaaPMRBaseConfig {\r
+\r
+\r
+ /**\r
+ * Publisher batching queue size\r
+ */\r
+ private int maxBatchSize;\r
+\r
+ /**\r
+ * Publisher Recovery Queue Size\r
+ */\r
+ private int maxRecoveryQueueSize;\r
+ \r
+ /**\r
+ * Default uri path prefix\r
+ */\r
+ private String dmaapUriPathPrefix ;\r
+\r
+ private DMaaPMRPublisherConfig(Builder builder) {\r
+ this.hostName = builder.hostName;\r
+ this.portNumber = builder.portNumber;\r
+ this.topicName = builder.topicName;\r
+ this.protocol = builder.protocol;\r
+ this.userName = builder.userName;\r
+ this.userPassword = builder.userPassword;\r
+ this.contentType = builder.contentType;\r
+ this.maxBatchSize = builder.maxBatchSize;\r
+ this.maxRecoveryQueueSize = builder.maxRecoveryQueueSize;\r
+ this.dmaapUriPathPrefix = builder.dmaapUriPathPrefix;\r
+ }\r
+\r
+ /**\r
+ * Builder to initialize immutable {@link DMaaPMRPublisherConfig} object\r
+ */\r
+ public static class Builder {\r
+\r
+ private String hostName;\r
+ private Integer portNumber;\r
+ private String topicName;\r
+ private String userName;\r
+ private String userPassword;\r
+ private String protocol;\r
+ private String contentType;\r
+ private int maxBatchSize;\r
+ private int maxRecoveryQueueSize;\r
+ private String dmaapUriPathPrefix ;\r
+ \r
+ \r
+\r
+ public Builder(@Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {\r
+this.topicName = topicName;\r
+this.hostName = dmaapConfig.getDmaaphost();\r
+ this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();\r
+ // Default values\r
+ \r
+ this.userName = dmaapConfig.getDEFAULT_USER_NAME();\r
+ this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();\r
+ this.protocol =dmaapConfig.getDEFAULT_PROTOCOL();\r
+ this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();\r
+\r
+ this.maxBatchSize =dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE();\r
+ this.maxRecoveryQueueSize = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE();\r
+ this.dmaapUriPathPrefix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();\r
+ }\r
+\r
+ /**\r
+ * Setup for custom host port number - Defaults to 80.\r
+ *\r
+ * @param portNumber\r
+ * custom port number\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setPortNumber(@Nonnull Integer portNumber) {\r
+ this.portNumber = portNumber;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup user name for authentication. If no username is provided authentication\r
+ * will be disabled\r
+ *\r
+ * @param userName\r
+ * user name for DMaaP Topic Authentication\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setUserName(@Nonnull String userName) {\r
+ this.userName = userName;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup user password for authentication. If no password is provided\r
+ * authentication will be disabled\r
+ *\r
+ * @param userPassword\r
+ * user password for DMaaP Topic Authentication\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setUserPassword(@Nonnull String userPassword) {\r
+ this.userPassword = userPassword;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Publisher protocol - Defaults to https. Note: Only http and\r
+ * https are currently supported.\r
+ *\r
+ * @param protocol\r
+ * protocol e.g. https\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setProtocol(@Nonnull String protocol) {\r
+ this.protocol = normalizeValidateProtocol(protocol);\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Publisher content-type - Defaults to application/json\r
+ *\r
+ * @param contentType\r
+ * content type e.g. application/json\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setContentType(@Nonnull String contentType) {\r
+ final String normalizedContentType = normalizeValidateContentType(contentType);\r
+ this.contentType = normalizedContentType;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Publisher Max Batch Size - Defaults to 100\r
+ *\r
+ * @param maxBatchSize\r
+ * max Batch Size\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setMaxBatchSize(int maxBatchSize) {\r
+ this.maxBatchSize = maxBatchSize;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Maximum Recovery Queue Size. Recovery Queue is used to hold\r
+ * messages temporarily in case DMaaP MR Publisher topic is not responding for\r
+ * any reason. Defaults to 100,000\r
+ *\r
+ * @param maxRecoveryQueueSize\r
+ * max recovery queue size\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setMaxRecoveryQueueSize(int maxRecoveryQueueSize) {\r
+ this.maxRecoveryQueueSize = maxRecoveryQueueSize;\r
+ return this;\r
+ }\r
+ \r
+\r
+ /**\r
+ * Creates immutable instance of {@link DMaaPMRPublisherConfig}\r
+ *\r
+ * @return Builds and returns thread safe, immutable\r
+ * {@link DMaaPMRPublisherConfig} object\r
+ */\r
+ public DMaaPMRPublisherConfig build() {\r
+ return new DMaaPMRPublisherConfig(this);\r
+ }\r
+\r
+ }\r
+ public String getDmaapUriPathPrefix() {\r
+ return dmaapUriPathPrefix;\r
+ }\r
+\r
+ /**\r
+ * Returns max Publisher Batch Queue Size\r
+ *\r
+ * @return max Publisher Batch Queue size\r
+ */\r
+ public int getMaxBatchSize() {\r
+ return maxBatchSize;\r
+ }\r
+\r
+ /**\r
+ * Returns max Publisher Recovery Queue Size\r
+ *\r
+ * @return max Recovery Queue size\r
+ */\r
+ public int getMaxRecoveryQueueSize() {\r
+ return maxRecoveryQueueSize;\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object o) {\r
+ if (this == o) {\r
+ return true;\r
+ }\r
+ if (o == null || getClass() != o.getClass()) {\r
+ return false;\r
+ }\r
+ if (!super.equals(o)) {\r
+ return false;\r
+ }\r
+ DMaaPMRPublisherConfig that = (DMaaPMRPublisherConfig) o;\r
+ return maxBatchSize == that.maxBatchSize && maxRecoveryQueueSize == that.maxRecoveryQueueSize;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return Objects.hashCode(super.hashCode(), maxBatchSize, maxRecoveryQueueSize);\r
+ }\r
+\r
+}
\ No newline at end of file
-/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * 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===========================================
- */
-
-package org.onap.universalvesadapter.configs;
-
-import java.io.IOException;
-
-import javax.annotation.Nonnull;
-
-import org.onap.universalvesadapter.utils.DmaapConfig;
-
-import com.google.common.base.Objects;
-
-/**
- * <p>
- * Immutable DMaaP MR Configuration for Subscriber.
- * <p>
- * Use {@link DMaaPMRSubscriberConfig.Builder} to construct Subscriber Configuration
- * <p>
- *
- * @author Rajiv Singla . Creation Date: 10/12/2016.
- */
-public final class DMaaPMRSubscriberConfig extends DMaaPMRBaseConfig {
-
- private final String consumerId;
- private final String consumerGroup;
- private final int timeoutMS;
- private final int messageLimit;
- private String timeoutMSParam;
- private String messageLimitParam;
- private String uriPrefix;
-
- public DMaaPMRSubscriberConfig(Builder builder) {
- this.hostName = builder.hostName;
- this.portNumber = builder.portNumber;
- this.topicName = builder.topicName;
- this.protocol = builder.protocol;
- this.userName = builder.userName;
- this.userPassword = builder.userPassword;
- this.contentType = builder.contentType;
- this.consumerId = builder.consumerId;
- this.consumerGroup = builder.consumerGroup;
- this.timeoutMS = builder.timeoutMS;
- this.messageLimit = builder.messageLimit;
- this.timeoutMSParam = builder.timeoutMSParam;
- this.messageLimitParam = builder.messageLimitParam;
- this.uriPrefix = builder.uriPreifix;
- }
-
- /**
- * Builder to initialize immutable {@link DMaaPMRSubscriberConfig} object
- */
- public static class Builder {
-
- private String hostName;
- private Integer portNumber;
- private String topicName;
- private String userName;
- private String userPassword;
- private String protocol;
- private String contentType;
- private String consumerId;
- private String consumerGroup;
- private int timeoutMS;
- private int messageLimit;
- private String timeoutMSParam;
- private String messageLimitParam;
- private String uriPreifix;
-
-
-
- public Builder(@Nonnull String hostName,
- @Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {
-
- // Required Values
- this.hostName = hostName;
- this.topicName = topicName;
- // Default values
- this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();
- this.userName = dmaapConfig.getDEFAULT_USER_NAME();
- this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();
- this.protocol = dmaapConfig.getDEFAULT_PROTOCOL();
- this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();
- this.consumerId = dmaapConfig.getDMAAP_DEFAULT_CONSUMER_ID();
- this.consumerGroup = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX();
- this.timeoutMS =dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS();
- this.messageLimit = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT();
- this.timeoutMSParam=dmaapConfig.getsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME();
- this.messageLimitParam=dmaapConfig.getsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME();
- this.uriPreifix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();
-
- }
-
-
- /**
- * Setup for custom host port number - Defaults to 80.
- *
- * @param portNumber custom port number
- * @return Builder object itself for chaining
- */
- public Builder setPortNumber(@Nonnull Integer portNumber) {
- this.portNumber = portNumber;
- return this;
- }
-
-
- /**
- * Setup user name for authentication. If no username is provided authentication will be disabled
- *
- * @param userName user name for DMaaP Topic Authentication
- * @return Builder object itself for chaining
- */
- public Builder setUserName(@Nonnull String userName) {
- this.userName = userName;
- return this;
- }
-
-
- /**
- * Setup user password for authentication. If no password is provided authentication will be disabled
- *
- * @param userPassword user password for DMaaP Topic Authentication
- * @return Builder object itself for chaining
- */
- public Builder setUserPassword(@Nonnull String userPassword) {
- this.userPassword = userPassword;
- return this;
- }
-
-
- /**
- * Setup custom Subscriber protocol - Defaults to https.
- * Note: Only http and https are currently supported.
- *
- * @param protocol protocol e.g. https or http
- * @return Builder object itself for chaining
- */
- public Builder setProtocol(@Nonnull String protocol) {
-
- this.protocol = normalizeValidateProtocol(protocol);
- return this;
- }
-
- /**
- * Setup custom Subscriber content-type - Defaults to application/json
- *
- * @param contentType content type e.g. application/json
- * @return Builder object itself for chaining
- */
- public Builder setContentType(@Nonnull String contentType) {
- final String normalizedContentType = normalizeValidateContentType(contentType);
- this.contentType = normalizedContentType;
- return this;
- }
-
-
- /**
- * Setup custom Consumer Id - Defaults to random Id
- *
- * @param consumerId - custom consumer ID
- * @return Builder object itself for chaining
- */
- public Builder setConsumerId(@Nonnull String consumerId) {
- this.consumerId = consumerId;
- return this;
- }
-
- /**
- * Setup custom Consumer Group - Default to OpenDCAE-DMaaPSub-ConsumerID
- *
- * @param consumerGroup - custom Consumer Group
- * @return Builder object itself for chaining
- */
- public Builder setConsumerGroup(@Nonnull String consumerGroup) {
- this.consumerGroup = consumerGroup;
- return this;
- }
-
- /**
- * Setup Custom Subscriber timeout in ms - Default to no timeout limit
- *
- * @param timeoutMS timeout in milliseconds
- * @return Builder object itself for chaining
- */
- public Builder setTimeoutMS(@Nonnull int timeoutMS) {
- this.timeoutMS = timeoutMS;
- return this;
- }
-
- /**
- * Setup custom Subscriber Message Limit - Default to no limit
- *
- * @param messageLimit message Limit
- * @return Builder object itself for chaining
- */
- public Builder setMessageLimit(@Nonnull int messageLimit) {
- this.messageLimit = messageLimit;
- return this;
- }
-
- /**
- * Builds Immutable instance of {@link DMaaPMRSubscriberConfig}
- *
- * @return immutable DMaaP Subscriber Config Object
- */
- public DMaaPMRSubscriberConfig build() {
- return new DMaaPMRSubscriberConfig(this);
- }
-
- }
-
-
- public String getTimeoutMSParam() {
- return timeoutMSParam;
- }
-
- public void setTimeoutMSParam(String timeoutMSParam) {
- this.timeoutMSParam = timeoutMSParam;
- }
-
- public String getMessageLimitParam() {
- return messageLimitParam;
- }
-
- public void setMessageLimitParam(String messageLimitParam) {
- this.messageLimitParam = messageLimitParam;
- }
-
- public String getUriPrefix() {
- return uriPrefix;
- }
-
- public void setUriPrefix(String uriPreifix) {
- this.uriPrefix = uriPreifix;
- }
-
- /**
- * DMaaP MR Subscriber Consumer Id
- *
- * @return consumer Id
- */
- public String getConsumerId() {
- return consumerId;
- }
-
- /**
- * DMaaP MR Subscriber Consumer Group
- *
- * @return consumer group
- */
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
- /**
- * DMaaP MR Subscriber Timeout in ms
- *
- * @return subscriber timeout ms
- */
- public int getTimeoutMS() {
- return timeoutMS;
- }
-
- /**
- * DMaaP MR Subscriber message limit
- *
- * @return subscriber message limit
- */
- public int getMessageLimit() {
- return messageLimit;
- }
-
- /**
- * DMaaP property file
- *
- * @return Properties
- */
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- if (!super.equals(o)) {
- return false;
- }
- DMaaPMRSubscriberConfig that = (DMaaPMRSubscriberConfig) o;
- return Objects.equal(consumerId, that.consumerId) &&
- Objects.equal(consumerGroup, that.consumerGroup) &&
- Objects.equal(timeoutMS, that.timeoutMS) &&
- Objects.equal(messageLimit, that.messageLimit);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), consumerId, consumerGroup, timeoutMS, messageLimit);
- }
-
-}
+/*\r
+ * ===============================LICENSE_START======================================\r
+ * dcae-analytics\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============================LICENSE_END===========================================\r
+ */\r
+\r
+package org.onap.universalvesadapter.configs;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.annotation.Nonnull;\r
+\r
+import org.onap.universalvesadapter.utils.DmaapConfig;\r
+\r
+import com.google.common.base.Objects;\r
+\r
+/**\r
+ * <p>\r
+ * Immutable DMaaP MR Configuration for Subscriber.\r
+ * <p>\r
+ * Use {@link DMaaPMRSubscriberConfig.Builder} to construct Subscriber Configuration\r
+ * <p>\r
+ *\r
+ * @author Rajiv Singla . Creation Date: 10/12/2016.\r
+ */\r
+public final class DMaaPMRSubscriberConfig extends DMaaPMRBaseConfig {\r
+\r
+ private final String consumerId;\r
+ private final String consumerGroup;\r
+ private final int timeoutMS;\r
+ private final int messageLimit;\r
+ private String timeoutMSParam;\r
+ private String messageLimitParam;\r
+ private String uriPrefix;\r
+\r
+ public DMaaPMRSubscriberConfig(Builder builder) {\r
+ this.hostName = builder.hostName;\r
+ this.portNumber = builder.portNumber;\r
+ this.topicName = builder.topicName;\r
+ this.protocol = builder.protocol;\r
+ this.userName = builder.userName;\r
+ this.userPassword = builder.userPassword;\r
+ this.contentType = builder.contentType;\r
+ this.consumerId = builder.consumerId;\r
+ this.consumerGroup = builder.consumerGroup;\r
+ this.timeoutMS = builder.timeoutMS;\r
+ this.messageLimit = builder.messageLimit;\r
+ this.timeoutMSParam = builder.timeoutMSParam;\r
+ this.messageLimitParam = builder.messageLimitParam;\r
+ this.uriPrefix = builder.uriPreifix;\r
+ }\r
+\r
+ /**\r
+ * Builder to initialize immutable {@link DMaaPMRSubscriberConfig} object\r
+ */\r
+ public static class Builder {\r
+\r
+ private String hostName;\r
+ private Integer portNumber;\r
+ private String topicName;\r
+ private String userName;\r
+ private String userPassword;\r
+ private String protocol;\r
+ private String contentType;\r
+ private String consumerId;\r
+ private String consumerGroup;\r
+ private int timeoutMS;\r
+ private int messageLimit;\r
+ private String timeoutMSParam;\r
+ private String messageLimitParam;\r
+ private String uriPreifix;\r
+ \r
+\r
+\r
+ public Builder(@Nonnull String topicName, DmaapConfig dmaapConfig) throws IOException {\r
+ \r
+ // Required Values\r
+ this.hostName = dmaapConfig.getDmaaphost();\r
+ this.portNumber = dmaapConfig.getDEFAULT_PORT_NUMBER();\r
+ this.topicName = topicName;\r
+ // Default values\r
+ \r
+ this.userName = dmaapConfig.getDEFAULT_USER_NAME();\r
+ this.userPassword = dmaapConfig.getDEFAULT_USER_PASSWORD();\r
+ this.protocol = dmaapConfig.getDEFAULT_PROTOCOL();\r
+ this.contentType = dmaapConfig.getDEFAULT_CONTENT_TYPE();\r
+ this.consumerId = dmaapConfig.getDMAAP_DEFAULT_CONSUMER_ID();\r
+ this.consumerGroup = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX();\r
+ this.timeoutMS =dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS();\r
+ this.messageLimit = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT();\r
+ this.timeoutMSParam=dmaapConfig.getsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME();\r
+ this.messageLimitParam=dmaapConfig.getsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME();\r
+ this.uriPreifix=dmaapConfig.getDMAAP_URI_PATH_PREFIX();\r
+ \r
+ }\r
+\r
+\r
+ /**\r
+ * Setup for custom host port number - Defaults to 80.\r
+ *\r
+ * @param portNumber custom port number\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setPortNumber(@Nonnull Integer portNumber) {\r
+ this.portNumber = portNumber;\r
+ return this;\r
+ }\r
+\r
+\r
+ /**\r
+ * Setup user name for authentication. If no username is provided authentication will be disabled\r
+ *\r
+ * @param userName user name for DMaaP Topic Authentication\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setUserName(@Nonnull String userName) {\r
+ this.userName = userName;\r
+ return this;\r
+ }\r
+\r
+\r
+ /**\r
+ * Setup user password for authentication. If no password is provided authentication will be disabled\r
+ *\r
+ * @param userPassword user password for DMaaP Topic Authentication\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setUserPassword(@Nonnull String userPassword) {\r
+ this.userPassword = userPassword;\r
+ return this;\r
+ }\r
+\r
+\r
+ /**\r
+ * Setup custom Subscriber protocol - Defaults to https.\r
+ * Note: Only http and https are currently supported.\r
+ *\r
+ * @param protocol protocol e.g. https or http\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setProtocol(@Nonnull String protocol) {\r
+\r
+ this.protocol = normalizeValidateProtocol(protocol);\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Subscriber content-type - Defaults to application/json\r
+ *\r
+ * @param contentType content type e.g. application/json\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setContentType(@Nonnull String contentType) {\r
+ final String normalizedContentType = normalizeValidateContentType(contentType);\r
+ this.contentType = normalizedContentType;\r
+ return this;\r
+ }\r
+\r
+\r
+ /**\r
+ * Setup custom Consumer Id - Defaults to random Id\r
+ *\r
+ * @param consumerId - custom consumer ID\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setConsumerId(@Nonnull String consumerId) {\r
+ this.consumerId = consumerId;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Consumer Group - Default to OpenDCAE-DMaaPSub-ConsumerID\r
+ *\r
+ * @param consumerGroup - custom Consumer Group\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setConsumerGroup(@Nonnull String consumerGroup) {\r
+ this.consumerGroup = consumerGroup;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup Custom Subscriber timeout in ms - Default to no timeout limit\r
+ *\r
+ * @param timeoutMS timeout in milliseconds\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setTimeoutMS(@Nonnull int timeoutMS) {\r
+ this.timeoutMS = timeoutMS;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Setup custom Subscriber Message Limit - Default to no limit\r
+ *\r
+ * @param messageLimit message Limit\r
+ * @return Builder object itself for chaining\r
+ */\r
+ public Builder setMessageLimit(@Nonnull int messageLimit) {\r
+ this.messageLimit = messageLimit;\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Builds Immutable instance of {@link DMaaPMRSubscriberConfig}\r
+ *\r
+ * @return immutable DMaaP Subscriber Config Object\r
+ */\r
+ public DMaaPMRSubscriberConfig build() {\r
+ return new DMaaPMRSubscriberConfig(this);\r
+ }\r
+\r
+ }\r
+\r
+\r
+ public String getTimeoutMSParam() {\r
+ return timeoutMSParam;\r
+ }\r
+\r
+ public void setTimeoutMSParam(String timeoutMSParam) {\r
+ this.timeoutMSParam = timeoutMSParam;\r
+ }\r
+\r
+ public String getMessageLimitParam() {\r
+ return messageLimitParam;\r
+ }\r
+\r
+ public void setMessageLimitParam(String messageLimitParam) {\r
+ this.messageLimitParam = messageLimitParam;\r
+ }\r
+\r
+ public String getUriPrefix() {\r
+ return uriPrefix;\r
+ }\r
+\r
+ public void setUriPrefix(String uriPreifix) {\r
+ this.uriPrefix = uriPreifix;\r
+ }\r
+\r
+ /**\r
+ * DMaaP MR Subscriber Consumer Id\r
+ *\r
+ * @return consumer Id\r
+ */\r
+ public String getConsumerId() {\r
+ return consumerId;\r
+ }\r
+\r
+ /**\r
+ * DMaaP MR Subscriber Consumer Group\r
+ *\r
+ * @return consumer group\r
+ */\r
+ public String getConsumerGroup() {\r
+ return consumerGroup;\r
+ }\r
+\r
+ /**\r
+ * DMaaP MR Subscriber Timeout in ms\r
+ *\r
+ * @return subscriber timeout ms\r
+ */\r
+ public int getTimeoutMS() {\r
+ return timeoutMS;\r
+ }\r
+\r
+ /**\r
+ * DMaaP MR Subscriber message limit\r
+ *\r
+ * @return subscriber message limit\r
+ */\r
+ public int getMessageLimit() {\r
+ return messageLimit;\r
+ }\r
+\r
+ /**\r
+ * DMaaP property file\r
+ *\r
+ * @return Properties\r
+ */\r
+ \r
+ @Override\r
+ public boolean equals(Object o) {\r
+ if (this == o) {\r
+ return true;\r
+ }\r
+ if (o == null || getClass() != o.getClass()) {\r
+ return false;\r
+ }\r
+ if (!super.equals(o)) {\r
+ return false;\r
+ }\r
+ DMaaPMRSubscriberConfig that = (DMaaPMRSubscriberConfig) o;\r
+ return Objects.equal(consumerId, that.consumerId) &&\r
+ Objects.equal(consumerGroup, that.consumerGroup) &&\r
+ Objects.equal(timeoutMS, that.timeoutMS) &&\r
+ Objects.equal(messageLimit, that.messageLimit);\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return Objects.hashCode(super.hashCode(), consumerId, consumerGroup, timeoutMS, messageLimit);\r
+ }\r
+\r
+}
\ No newline at end of file
-/*
-* ============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.dmaap;
-
-import java.io.IOException;
-
-import org.onap.universalvesadapter.configs.DMaaPMRPublisherConfig;
-import org.onap.universalvesadapter.configs.DMaaPMRSubscriberConfig;
-import org.onap.universalvesadapter.dmaap.MRPublisher.DMaaPMRPublisher;
-import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber;
-import org.onap.universalvesadapter.utils.DmaapConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Creator {
-
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
- private DMaaPMRFactory dMaaPMRFactoryInstance;
- private String dmaaphost;
- private String publisherTopic;
- @Autowired
- private DmaapConfig dmaapConfig;
-
- // prop initializer
-
- public void propertyFileInitializer() {
-
- this.dmaaphost = dmaapConfig.getDmaaphost();
- this.publisherTopic = dmaapConfig.getPublisherTopic();
- this.dMaaPMRFactoryInstance = DMaaPMRFactory.create();
- debugLogger.info("The Hostname of DMaap is :" + dmaaphost);
-
-
- }
-
- // publisher
- public DMaaPMRPublisher getDMaaPMRPublisher(){
- propertyFileInitializer();
- DMaaPMRPublisherConfig dMaaPMRPublisherConfig = null;
- try {
- dMaaPMRPublisherConfig = new DMaaPMRPublisherConfig.Builder(dmaaphost, publisherTopic,dmaapConfig).build();
- } catch (IOException e) {
- errorLogger.error("failed or interrupted I/O operations while creating publisher config:{}",e.getCause());
- }
- return dMaaPMRFactoryInstance.createPublisher(dMaaPMRPublisherConfig);
- }
-
- // subscriber
- public DMaaPMRSubscriber getDMaaPMRSubscriber(String subcriberTopic){
- propertyFileInitializer();
- DMaaPMRSubscriberConfig dMaaPMRSubscriberConfig = null;
- try {
- dMaaPMRSubscriberConfig = new DMaaPMRSubscriberConfig.Builder(dmaaphost, subcriberTopic, dmaapConfig).build();
- } catch (IOException e) {
-
- errorLogger.error("failed or interrupted I/O operations while creating subcriber config:{}",e.getCause());
- }
-
- return dMaaPMRFactoryInstance.createSubscriber(dMaaPMRSubscriberConfig);
-
- }
- public void setDmaapConfig(DmaapConfig dmaapConfig) {
- this.dmaapConfig = dmaapConfig;
- }
-
- public DmaapConfig getDmaapConfig() {
- return dmaapConfig;
- }
-
-}
+/*\r
+* ============LICENSE_START=======================================================\r
+* ONAP : DCAE\r
+* ================================================================================\r
+* Copyright 2018 TechMahindra\r
+*=================================================================================\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+* ============LICENSE_END=========================================================\r
+*/\r
+package org.onap.universalvesadapter.dmaap;\r
+\r
+import java.io.IOException;\r
+\r
+import org.onap.universalvesadapter.configs.DMaaPMRPublisherConfig;\r
+import org.onap.universalvesadapter.configs.DMaaPMRSubscriberConfig;\r
+import org.onap.universalvesadapter.dmaap.MRPublisher.DMaaPMRPublisher;\r
+import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber;\r
+import org.onap.universalvesadapter.utils.DmaapConfig;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Component;\r
+\r
+@Component\r
+public class Creator {\r
+\r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ private DMaaPMRFactory dMaaPMRFactoryInstance;\r
+\r
+\r
+ @Autowired\r
+ private DmaapConfig dmaapConfig;\r
+\r
+ // prop initializer\r
+\r
+ public void propertyFileInitializer() {\r
+ \r
+ this.dMaaPMRFactoryInstance = DMaaPMRFactory.create();\r
+\r
+ }\r
+\r
+ // publisher \r
+ public DMaaPMRPublisher getDMaaPMRPublisher(String publisherTopic){\r
+ propertyFileInitializer();\r
+ DMaaPMRPublisherConfig dMaaPMRPublisherConfig = null;\r
+ try {\r
+ dMaaPMRPublisherConfig = new DMaaPMRPublisherConfig.Builder(publisherTopic,dmaapConfig).build();\r
+ } catch (IOException e) {\r
+ errorLogger.error("failed or interrupted I/O operations while creating publisher config:{}",e.getCause());\r
+ }\r
+ return dMaaPMRFactoryInstance.createPublisher(dMaaPMRPublisherConfig);\r
+ }\r
+\r
+ // subscriber\r
+ public DMaaPMRSubscriber getDMaaPMRSubscriber(String subcriberTopic){\r
+ propertyFileInitializer();\r
+ DMaaPMRSubscriberConfig dMaaPMRSubscriberConfig = null;\r
+ try {\r
+ dMaaPMRSubscriberConfig = new DMaaPMRSubscriberConfig.Builder(subcriberTopic, dmaapConfig).build();\r
+ } catch (IOException e) {\r
+ \r
+ errorLogger.error("failed or interrupted I/O operations while creating subcriber config:{}",e.getCause());\r
+ }\r
+ \r
+ return dMaaPMRFactoryInstance.createSubscriber(dMaaPMRSubscriberConfig);\r
+\r
+ }\r
+ public void setDmaapConfig(DmaapConfig dmaapConfig) {\r
+ this.dmaapConfig = dmaapConfig;\r
+ }\r
+\r
+ public DmaapConfig getDmaapConfig() {\r
+ return dmaapConfig;\r
+ }\r
+\r
+}\r
-/*
-* ============LICENSE_START=======================================================
-* ONAP : DCAE
-* ================================================================================
-* Copyright 2018-2019 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.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.onap.universalvesadapter.dmaap.Creator;
-import org.onap.universalvesadapter.utils.CollectorConfigPropertyRetrival;
-import org.onap.universalvesadapter.utils.DmaapConfig;
-import org.onap.universalvesadapter.utils.FetchDynamicConfig;
-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.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.context.ApplicationContext;
-import org.springframework.core.Ordered;
-import org.springframework.stereotype.Component;
-
-//AdapterInitializer
-@Component
-public class VESAdapterInitializer implements CommandLineRunner, Ordered {
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
-
- @Autowired
- private Creator creator;
- @Autowired
- private DmaapConfig dmaapConfig;
- @Value("${defaultConfigFilelocation}")
- String defaultConfigFilelocation;
- @Value("${server.port}")
- String serverPort;
-
- private static Map<String, String> mappingFiles = new HashMap<String, String>();
- private static Map<String, String> env;
-
- @Autowired
- private ApplicationContext applicationContext;
-
- @Override
- public void run(String... args) throws Exception {
- debugLogger.info("The Default Config file Location:" + defaultConfigFilelocation.trim());
-
- if (ClassLoader.getSystemResource(defaultConfigFilelocation.trim()) == null) {
- errorLogger.error("Default Config file " + defaultConfigFilelocation.trim() + " is missing");
- System.exit(SpringApplication.exit(applicationContext, () -> {
- errorLogger.error("Application stoped due to missing default Config file");
- return -1;
- }));
- }
- env = System.getenv();
- for (Map.Entry<String, String> entry : env.entrySet()) {
- debugLogger.debug(entry.getKey() + ":" + entry.getValue());
- }
-
- //checks for DMaaP Host and Port No
- if( (env.get("DMAAPHOST")==null ||(env.get("MR_DEFAULT_PORT_NUMBER")==null))) {
-
- errorLogger.error("DMAAPHOST,MR_DEFAULT_PORT_NUMBER environment parameter is missing. Sample Usage is -\n sudo docker run -d -p 8085:8085/tcp --env MR_DEFAULT_PORT_NUMBER=3904 --env CONSUL_HOST=10.53.172.109 --env HOSTNAME=mvp-dcaegen2-service-mua --env CONFIG_BINDING_SERVICE=config_binding_service --env DMAAPHOST='10.53.172.156' nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.mapper.vesadapter.universalvesadaptor:latest");
-
- System.exit(SpringApplication.exit(applicationContext, () -> {errorLogger.error("Application stoped due missing DMAAPHOST or MR_DEFAULT_PORT_NUMBER environment varibales.Please refer above example for environment varibales to pass ");return-1;}));
- }
-
- dmaapConfig.setDmaaphost(env.get("DMAAPHOST"));
- dmaapConfig.setDEFAULT_PORT_NUMBER(Integer.parseInt(env.get("MR_DEFAULT_PORT_NUMBER")));
- creator.setDmaapConfig(dmaapConfig);
- //check for consul details
- if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE") && env.containsKey("HOSTNAME")) {
- debugLogger.info(">>>Dynamic configuration to be used");
- FetchDynamicConfig.cbsCall(defaultConfigFilelocation);
-
- } else {
- debugLogger.info(">>>Static configuration to be used");
-
- }
- readJsonToMap(defaultConfigFilelocation);
-
- //prepareDatabase();
- //fetchMappingFile();
-
- debugLogger.info("Triggering controller's start url ");
- executecurl("http://localhost:"+serverPort+"/start");
- }
-
-
- private static String executecurl(String url) {
-
- debugLogger.info("Running curl command for url:{}",url);
- String[] command = { "curl", "-v", url };
- ProcessBuilder process = new ProcessBuilder(command);
- Process p;
- String result = null;
- try {
- p = process.start();
- try(InputStreamReader ipr = new InputStreamReader(p.getInputStream());
- BufferedReader reader = new BufferedReader(ipr)){
- StringBuilder builder = new StringBuilder();
- String line;
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
- result = builder.toString();
- }
- } catch (IOException e) {
- errorLogger.error("error", e);
- }
- return result;
-
- }
-
- private void readJsonToMap(String configFile) {
- try {
- JSONArray collectorArray=CollectorConfigPropertyRetrival.collectorConfigArray(configFile);
-
- for (int i = 0; i < collectorArray.size(); i++) {
- JSONObject obj2 = (JSONObject) collectorArray.get(i);
-
- if (obj2.containsKey("mapping-files")) {
-
- JSONArray a1 = (JSONArray) obj2.get("mapping-files");
-
- for (int j = 0; j < a1.size(); j++) {
- JSONObject obj3 = (JSONObject) a1.get(j);
- Set<Entry<String, String>> set = obj3.entrySet();
-
- for (Entry<String, String> entry : set) {
-
- mappingFiles.put(entry.getKey(), entry.getValue());
- }
- }
-
- }
- }
-
- } catch (Exception e) {
- errorLogger.error("Exception occured while reading Collector config file cause: ",e.getCause());
- }
-
- }
-
-
- /* private void prepareDatabase() throws IOException {
-
-
- debugLogger.info("The Default Mapping file Location:" + defaultMappingFileLocation.trim());
-
- if (ClassLoader.getSystemResource(defaultMappingFileLocation.trim()) == null) {
- errorLogger.error(
- "Default mapping file " + defaultMappingFileLocation.trim() + " is missing");
- System.exit(SpringApplication.exit(applicationContext, () -> {
- errorLogger.error("Application stoped due to missing default mapping file");
- return -1;
- }));
- }
-
- File file = new File(
- ClassLoader.getSystemResource(defaultMappingFileLocation.trim()).getFile());
-
- try (FileInputStream fileInputStream = new FileInputStream(file)) {
- bytesArray = new byte[(int) file.length()];
- fileInputStream.read(bytesArray);
-
- } catch (IOException e1) {
- errorLogger.error("Exception Occured while reading the default mapping file ,Cause: "
- + e1.getMessage(), e1);
- // exit on missing default mapping file
- System.exit(SpringApplication.exit(applicationContext, () -> {
- errorLogger.error("Application stoped due to missing default mapping file");
- return -1;
- }));
- }
-
- try (Connection con = DriverManager.getConnection(dBurl, user, pwd);
- // creating table if not exist
- PreparedStatement pstmt11 =
- con.prepareStatement("CREATE TABLE IF NOT EXISTS public."
- + MappingFileTableName + "\r\n" + "(\r\n"
- + " enterpriseid character varying COLLATE pg_catalog.\"default\" NOT NULL,\r\n"
- + " mappingfilecontents bytea,\r\n"
- + " mimetype character varying COLLATE pg_catalog.\"default\",\r\n"
- + " file_name character varying COLLATE pg_catalog.\"default\",\r\n"
- + " CONSTRAINT mapping_file_pkey5 PRIMARY KEY (enterpriseid)\r\n"
- + ")\r\n" + "WITH (\r\n" + " OIDS = FALSE\r\n" + ")\r\n"
- + "TABLESPACE pg_default;")) {
-
- metricsLogger.info("Postgresql Connection successful...");
- debugLogger.debug("Connection object:{}" , con.toString());
-
- pstmt11.executeUpdate();
- debugLogger.info("CREATE TABLE IF NOT EXISTS executed successfully....");
-
- if ((bytesArray.length > 0) && (!Arrays.toString(bytesArray).equals(""))) {
-
- try (PreparedStatement pstmt = con.prepareStatement("INSERT INTO "
- + MappingFileTableName
- + "(enterpriseid, mappingfilecontents, mimetype, File_Name) VALUES (?, ?, ?, ?) ON CONFLICT (enterpriseid) DO NOTHING;")) {
- pstmt.setString(1, defaultEnterpriseId);
- pstmt.setBytes(2, bytesArray);
- pstmt.setString(3, "text/xml");
- pstmt.setString(4, file.getName());
-
- pstmt.executeUpdate();
- debugLogger.info("Made sure that default mapping file is present in table");
- }
- } else {
- errorLogger.error(file.getName() + " is empty");
- // exit on empty mapping file
- System.exit(SpringApplication.exit(applicationContext, () -> {
- errorLogger.error("Application stoped beacuase default mapping file is empty..");
- return -1;
- }));
- }
-
- } catch (SQLException e) {
- errorLogger.error("Received exception : " + e.getMessage(), e);
- // exit on SqlException
- System.exit(SpringApplication.exit(applicationContext, () -> {
- errorLogger.error("Application Stoped due to ", e.getCause());
- return -1;
- }));
- }
-
- }*/
- /*public void fetchMappingFile() {
-
- try (Connection con = DriverManager.getConnection(dBurl, user, pwd)) {
- debugLogger.info("Retrieving data from DB");
- PreparedStatement pstmt = con.prepareStatement("SELECT * FROM mapping_file");
- ResultSet rs = pstmt.executeQuery();
- // parsing the column each time is a linear search
- int column1Pos = rs.findColumn("enterpriseid");
- int column2Pos = rs.findColumn("mappingfilecontents");
- String hexString;
- while (rs.next()) {
- String column1 = rs.getString(column1Pos);
- String column2 = rs.getString(column2Pos);
- hexString = column2.substring(2);
- byte[] bytes = Hex.decodeHex(hexString.toCharArray());
- String data = new String(bytes, "UTF-8");
- mappingFiles.put(column1, data);
- }
- debugLogger.info("DB Initialization Completed, Total # Mappingfiles are" + mappingFiles.size());
- } catch (Exception e) {
- errorLogger.error("Error occured due to :" + e.getMessage());
- e.printStackTrace();
- }
-
- }*/
-
- public static Map<String, String> getMappingFiles() {
- return mappingFiles;
- }
-
- public static void setMappingFiles(Map<String, String> mappingFiles) {
- VESAdapterInitializer.mappingFiles = mappingFiles;
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : DCAE\r
+ * ================================================================================\r
+ * Copyright 2018-2019 TechMahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.universalvesadapter.service;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+import java.util.Set;\r
+\r
+import org.json.simple.JSONArray;\r
+import org.json.simple.JSONObject;\r
+import org.onap.universalvesadapter.utils.CollectorConfigPropertyRetrival;\r
+import org.onap.universalvesadapter.utils.FetchDynamicConfig;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.CommandLineRunner;\r
+import org.springframework.boot.SpringApplication;\r
+import org.springframework.context.ApplicationContext;\r
+import org.springframework.core.Ordered;\r
+import org.springframework.stereotype.Component;\r
+\r
+// AdapterInitializer\r
+@Component\r
+public class VESAdapterInitializer implements CommandLineRunner, Ordered {\r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ \r
+ @Value("${defaultConfigFilelocation}")\r
+ String defaultConfigFilelocation;\r
+ @Value("${server.port}")\r
+ String serverPort;\r
+ \r
+ private static Map<String, String> mappingFiles = new HashMap<String, String>();\r
+ private static Map<String, String> env;\r
+ \r
+ @Autowired\r
+ private ApplicationContext applicationContext;\r
+ \r
+ @Override\r
+ public void run(String... args) throws Exception {\r
+ debugLogger.info("The Default Config file Location:"\r
+ + defaultConfigFilelocation.trim());\r
+ // final Path configFilePath =\r
+ // Paths.get(defaultConfigFilelocation.trim()).toAbsolutePath();\r
+ // File f = new File(configFilePath.toString());\r
+ \r
+ if (ClassLoader.getSystemResource(defaultConfigFilelocation.trim()) == null) {\r
+ errorLogger.error("Default Config file " + defaultConfigFilelocation.trim()\r
+ + " is missing");\r
+ System.exit(SpringApplication.exit(applicationContext, () -> {\r
+ errorLogger.error(\r
+ "Application stoped due to missing default Config file");\r
+ return -1;\r
+ }));\r
+ }\r
+ env = System.getenv();\r
+ for (Map.Entry<String, String> entry : env.entrySet()) {\r
+ debugLogger.debug(entry.getKey() + ":" + entry.getValue());\r
+ }\r
+ \r
+ // check for consul details\r
+ if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE")\r
+ && env.containsKey("HOSTNAME")) {\r
+ debugLogger.info(">>>Dynamic configuration to be used");\r
+ FetchDynamicConfig.cbsCall(defaultConfigFilelocation);\r
+ \r
+ } else {\r
+ debugLogger.info(">>>Static configuration to be used");\r
+ \r
+ }\r
+ readJsonToMap(defaultConfigFilelocation);\r
+ \r
+ // prepareDatabase();\r
+ // fetchMappingFile();\r
+ \r
+ debugLogger.info("Triggering controller's start url ");\r
+ executecurl("http://localhost:" + serverPort + "/start");\r
+ }\r
+ \r
+ \r
+ private static String executecurl(String url) {\r
+ \r
+ debugLogger.info("Running curl command for url:{}", url);\r
+ String[] command = {"curl", "-v", url};\r
+ ProcessBuilder process = new ProcessBuilder(command);\r
+ Process p;\r
+ String result = null;\r
+ try {\r
+ p = process.start();\r
+ try (InputStreamReader ipr = new InputStreamReader(p.getInputStream());\r
+ BufferedReader reader = new BufferedReader(ipr)) {\r
+ StringBuilder builder = new StringBuilder();\r
+ String line;\r
+ \r
+ while ((line = reader.readLine()) != null) {\r
+ builder.append(line);\r
+ }\r
+ result = builder.toString();\r
+ }\r
+ } catch (IOException e) {\r
+ errorLogger.error("error", e);\r
+ }\r
+ return result;\r
+ \r
+ }\r
+ \r
+ private void readJsonToMap(String configFile) {\r
+ try {\r
+ JSONArray collectorArray = CollectorConfigPropertyRetrival\r
+ .collectorConfigArray(configFile);\r
+ \r
+ for (int i = 0; i < collectorArray.size(); i++) {\r
+ JSONObject obj2 = (JSONObject) collectorArray.get(i);\r
+ \r
+ if (obj2.containsKey("mapping-files")) {\r
+ \r
+ JSONArray a1 = (JSONArray) obj2.get("mapping-files");\r
+ \r
+ for (int j = 0; j < a1.size(); j++) {\r
+ JSONObject obj3 = (JSONObject) a1.get(j);\r
+ Set<Entry<String, String>> set = obj3.entrySet();\r
+ \r
+ for (Entry<String, String> entry : set) {\r
+ \r
+ mappingFiles.put(entry.getKey(),\r
+ entry.getValue());\r
+ }\r
+ }\r
+ \r
+ }\r
+ }\r
+ \r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ errorLogger.error(\r
+ "Exception occured while reading Collector config file cause: ",\r
+ e.getCause());\r
+ }\r
+ \r
+ }\r
+ \r
+ \r
+ /*\r
+ * private void prepareDatabase() throws IOException {\r
+ * \r
+ * \r
+ * debugLogger.info("The Default Mapping file Location:" +\r
+ * defaultMappingFileLocation.trim());\r
+ * \r
+ * if (ClassLoader.getSystemResource(defaultMappingFileLocation.trim()) == null) {\r
+ * errorLogger.error( "Default mapping file " + defaultMappingFileLocation.trim() +\r
+ * " is missing"); System.exit(SpringApplication.exit(applicationContext, () -> {\r
+ * errorLogger.error("Application stoped due to missing default mapping file"); return -1;\r
+ * })); }\r
+ * \r
+ * File file = new File(\r
+ * ClassLoader.getSystemResource(defaultMappingFileLocation.trim()).getFile());\r
+ * \r
+ * try (FileInputStream fileInputStream = new FileInputStream(file)) { bytesArray = new\r
+ * byte[(int) file.length()]; fileInputStream.read(bytesArray);\r
+ * \r
+ * } catch (IOException e1) {\r
+ * errorLogger.error("Exception Occured while reading the default mapping file ,Cause: " +\r
+ * e1.getMessage(), e1); // exit on missing default mapping file\r
+ * System.exit(SpringApplication.exit(applicationContext, () -> {\r
+ * errorLogger.error("Application stoped due to missing default mapping file"); return -1;\r
+ * })); }\r
+ * \r
+ * try (Connection con = DriverManager.getConnection(dBurl, user, pwd); // creating table if\r
+ * not exist PreparedStatement pstmt11 =\r
+ * con.prepareStatement("CREATE TABLE IF NOT EXISTS public." + MappingFileTableName + "\r\n"\r
+ * + "(\r\n" +\r
+ * " enterpriseid character varying COLLATE pg_catalog.\"default\" NOT NULL,\r\n" +\r
+ * " mappingfilecontents bytea,\r\n" +\r
+ * " mimetype character varying COLLATE pg_catalog.\"default\",\r\n" +\r
+ * " file_name character varying COLLATE pg_catalog.\"default\",\r\n" +\r
+ * " CONSTRAINT mapping_file_pkey5 PRIMARY KEY (enterpriseid)\r\n" + ")\r\n" +\r
+ * "WITH (\r\n" + " OIDS = FALSE\r\n" + ")\r\n" + "TABLESPACE pg_default;")) {\r
+ * \r
+ * metricsLogger.info("Postgresql Connection successful...");\r
+ * debugLogger.debug("Connection object:{}" , con.toString());\r
+ * \r
+ * pstmt11.executeUpdate();\r
+ * debugLogger.info("CREATE TABLE IF NOT EXISTS executed successfully....");\r
+ * \r
+ * if ((bytesArray.length > 0) && (!Arrays.toString(bytesArray).equals(""))) {\r
+ * \r
+ * try (PreparedStatement pstmt = con.prepareStatement("INSERT INTO " + MappingFileTableName\r
+ * +\r
+ * "(enterpriseid, mappingfilecontents, mimetype, File_Name) VALUES (?, ?, ?, ?) ON CONFLICT (enterpriseid) DO NOTHING;"\r
+ * )) { pstmt.setString(1, defaultEnterpriseId); pstmt.setBytes(2, bytesArray);\r
+ * pstmt.setString(3, "text/xml"); pstmt.setString(4, file.getName());\r
+ * \r
+ * pstmt.executeUpdate();\r
+ * debugLogger.info("Made sure that default mapping file is present in table"); } } else {\r
+ * errorLogger.error(file.getName() + " is empty"); // exit on empty mapping file\r
+ * System.exit(SpringApplication.exit(applicationContext, () -> {\r
+ * errorLogger.error("Application stoped beacuase default mapping file is empty.."); return\r
+ * -1; })); }\r
+ * \r
+ * } catch (SQLException e) { errorLogger.error("Received exception : " + e.getMessage(),\r
+ * e); // exit on SqlException System.exit(SpringApplication.exit(applicationContext, () ->\r
+ * { errorLogger.error("Application Stoped due to ", e.getCause()); return -1; })); }\r
+ * \r
+ * }\r
+ */\r
+ /*\r
+ * public void fetchMappingFile() {\r
+ * \r
+ * try (Connection con = DriverManager.getConnection(dBurl, user, pwd)) {\r
+ * debugLogger.info("Retrieving data from DB"); PreparedStatement pstmt =\r
+ * con.prepareStatement("SELECT * FROM mapping_file"); ResultSet rs = pstmt.executeQuery();\r
+ * // parsing the column each time is a linear search int column1Pos =\r
+ * rs.findColumn("enterpriseid"); int column2Pos = rs.findColumn("mappingfilecontents");\r
+ * String hexString; while (rs.next()) { String column1 = rs.getString(column1Pos); String\r
+ * column2 = rs.getString(column2Pos); hexString = column2.substring(2); byte[] bytes =\r
+ * Hex.decodeHex(hexString.toCharArray()); String data = new String(bytes, "UTF-8");\r
+ * mappingFiles.put(column1, data); }\r
+ * debugLogger.info("DB Initialization Completed, Total # Mappingfiles are" +\r
+ * mappingFiles.size()); } catch (Exception e) { errorLogger.error("Error occured due to :"\r
+ * + e.getMessage()); e.printStackTrace(); }\r
+ * \r
+ * }\r
+ */\r
+ \r
+ public static Map<String, String> getMappingFiles() {\r
+ return mappingFiles;\r
+ }\r
+ \r
+ public static void setMappingFiles(Map<String, String> mappingFiles) {\r
+ VESAdapterInitializer.mappingFiles = mappingFiles;\r
+ }\r
+ \r
+ @Override\r
+ public int getOrder() {\r
+ return 0;\r
+ }\r
+ \r
+}\r
-/*
-* ============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.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import org.onap.universalvesadapter.adapter.UniversalEventAdapter;
-import org.onap.universalvesadapter.dmaap.Creator;
-import org.onap.universalvesadapter.dmaap.MRPublisher.DMaaPMRPublisher;
-import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber;
-import org.onap.universalvesadapter.exception.DMaapException;
-import org.onap.universalvesadapter.exception.MapperConfigException;
-import org.onap.universalvesadapter.exception.VesException;
-import org.onap.universalvesadapter.utils.CollectorConfigPropertyRetrival;
-import org.onap.universalvesadapter.utils.DmaapConfig;
-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 static final Logger metricsLogger = LoggerFactory.getLogger("metricsLogger");
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
-
- private boolean isRunning = true;
- @Value("${defaultConfigFilelocation}")
- private String defaultConfigFilelocation;
- @Autowired
- private Creator creator;
- @Autowired
- private UniversalEventAdapter eventAdapter;
- @Autowired
- private DmaapConfig dmaapConfig;
- private static List<String> list = new LinkedList<String>();
-
-
- /**
- * method triggers universal VES adapter module.
- */
- public void start() throws MapperConfigException {
- debugLogger.info("Creating Subcriber and Publisher with creator.............");
-
-
- DMaaPMRPublisher publisher = creator.getDMaaPMRPublisher();
-
- String topicArray[]= CollectorConfigPropertyRetrival.getProperyArray("subscriberTopic",defaultConfigFilelocation);
-
-
- ExecutorService executorService=Executors.newFixedThreadPool(topicArray.length);
- for(int i=0;i<topicArray.length;i++) {
- String topicName =topicArray[i];
- DMaaPMRSubscriber subcriber = creator.getDMaaPMRSubscriber(topicArray[i]);
-
- executorService.submit(new Runnable() {
-
- @Override
- public void run(){
-
- Thread.currentThread().setName(topicName);
- metricsLogger.info("fetch and publish from and to Dmaap started:"+Thread.currentThread().getName());
- int pollingInternalInt=dmaapConfig.getPollingInterval();
- debugLogger.info("The Polling Interval in Milli Second is :{}" +pollingInternalInt);
- debugLogger.info("starting subscriber & publisher thread:{}", Thread.currentThread().getName());
- while (true) {
- synchronized (this) {
- for (String incomingJsonString : subcriber.fetchMessages().getFetchedMessages()) {
- list.add(incomingJsonString);
-
- }
-
- if (list.isEmpty()) {
- try {
- Thread.sleep(pollingInternalInt);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- debugLogger.debug("number of messages to be converted :{}", list.size());
-
- if (!list.isEmpty()) {
- String val = ((LinkedList<String>) list).removeFirst();
- List<String> messages = new ArrayList<>();
- String vesEvent = processReceivedJson(val);
- if (vesEvent!=null && (!(vesEvent.isEmpty() || vesEvent.equals("")))) {
- messages.add(vesEvent);
- publisher.publish(messages);
- metricsLogger.info("Message successfully published to DMaaP Topic");
- }
-
- }
-
- }
- }
-
-
-
- }
- });
- }
-
-
-
- }
-
- /**
- * method stops universal ves adapter module
- */
- public void stop() {
- isRunning = false;
- }
-
- private String processReceivedJson(String incomingJsonString) {
- String outgoingJsonString = null;
- if (!"".equals(incomingJsonString)) {
-
- try {
-
- outgoingJsonString = eventAdapter.transform(incomingJsonString);
-
- } catch (VesException exception) {
- errorLogger.error("Received exception : {},{}" + exception.getMessage(), exception);
- debugLogger.warn("APPLICATION WILL BE SHUTDOWN UNTIL ABOVE ISSUE IS RESOLVED.");
- } catch (DMaapException e) {
- errorLogger.error("Received exception : {}", e.getMessage());
- }
- }
- return outgoingJsonString;
- }
-}
-
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : DCAE\r
+ * ================================================================================\r
+ * Copyright 2018-2019 TechMahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.universalvesadapter.service;\r
+\r
+import java.util.ArrayList;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.concurrent.ExecutorService;\r
+import java.util.concurrent.Executors;\r
+\r
+import org.onap.universalvesadapter.adapter.UniversalEventAdapter;\r
+import org.onap.universalvesadapter.dmaap.Creator;\r
+import org.onap.universalvesadapter.dmaap.MRPublisher.DMaaPMRPublisher;\r
+import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber;\r
+import org.onap.universalvesadapter.exception.DMaapException;\r
+import org.onap.universalvesadapter.exception.MapperConfigException;\r
+import org.onap.universalvesadapter.exception.VesException;\r
+import org.onap.universalvesadapter.utils.CollectorConfigPropertyRetrival;\r
+import org.onap.universalvesadapter.utils.DmaapConfig;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.stereotype.Component;\r
+\r
+/**\r
+ * Service that starts the universal ves adapter module to listen for events\r
+ * \r
+ * @author kmalbari\r
+ *\r
+ */\r
+/**\r
+ * @author PM00501616\r
+ *\r
+ */\r
+/**\r
+ * @author PM00501616\r
+ *\r
+ */\r
+@Component\r
+public class VesService {\r
+ \r
+ private static final Logger metricsLogger = LoggerFactory.getLogger("metricsLogger");\r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ \r
+ private boolean isRunning = true;\r
+ @Value("${defaultConfigFilelocation}")\r
+ private String defaultConfigFilelocation;\r
+ @Autowired\r
+ private Creator creator;\r
+ @Autowired\r
+ private UniversalEventAdapter eventAdapter;\r
+ @Autowired\r
+ private DmaapConfig dmaapConfig;\r
+ @Autowired\r
+ private CollectorConfigPropertyRetrival collectorConfigPropertyRetrival;\r
+ private static List<String> list = new LinkedList<String>();\r
+ \r
+ \r
+ /**\r
+ * method triggers universal VES adapter module.\r
+ */\r
+ public void start() throws MapperConfigException {\r
+ debugLogger.info("Creating Subcriber and Publisher with creator.............");\r
+ String topicName = null;\r
+ String publisherTopic = null;\r
+ // Hashmap of subscriber and publisher details in correspondence to the respective\r
+ // collectors in kv file\r
+ Map<String, String> dmaapTopics = collectorConfigPropertyRetrival.getDmaapTopics(\r
+ "stream_subscriber", "stream_publisher", defaultConfigFilelocation);\r
+ \r
+ ExecutorService executorService = Executors.newFixedThreadPool(dmaapTopics.size());\r
+ for (Map.Entry<String, String> entry : dmaapTopics.entrySet()) {\r
+ String threadName = entry.getKey();\r
+ // subcriber and corresponding publisher topics in a Map\r
+ Map<String, String> subpubTopics = collectorConfigPropertyRetrival\r
+ .getTopics(entry.getKey(), entry.getValue(),\r
+ defaultConfigFilelocation);\r
+ for (Map.Entry<String, String> entry2 : subpubTopics.entrySet()) {\r
+ topicName = entry2.getKey();\r
+ publisherTopic = entry2.getValue();\r
+ }\r
+ \r
+ \r
+ // Publisher and subcriber as per each collector\r
+ DMaaPMRSubscriber subcriber = creator.getDMaaPMRSubscriber(topicName);\r
+ \r
+ DMaaPMRPublisher publisher = creator.getDMaaPMRPublisher(publisherTopic);\r
+ debugLogger.info("Created scriber topic:" + topicName + "publisher topic:"\r
+ + publisherTopic);\r
+ \r
+ executorService.submit(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ \r
+ Thread.currentThread().setName(threadName);\r
+ metricsLogger.info(\r
+ "fetch and publish from and to Dmaap started:"\r
+ + Thread.currentThread()\r
+ .getName());\r
+ int pollingInternalInt = dmaapConfig.getPollingInterval();\r
+ debugLogger.info(\r
+ "The Polling Interval in Milli Second is :{}"\r
+ + pollingInternalInt);\r
+ debugLogger.info(\r
+ "starting subscriber & publisher thread:{}",\r
+ Thread.currentThread().getName());\r
+ while (true) {\r
+ synchronized (this) {\r
+ for (String incomingJsonString : subcriber\r
+ .fetchMessages()\r
+ .getFetchedMessages()) {\r
+ list.add(incomingJsonString);\r
+ \r
+ }\r
+ \r
+ if (list.isEmpty()) {\r
+ try {\r
+ Thread.sleep(pollingInternalInt);\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ debugLogger.debug(\r
+ "number of messages to be converted :{}",\r
+ list.size());\r
+ \r
+ if (!list.isEmpty()) {\r
+ String val = ((LinkedList<String>) list)\r
+ .removeFirst();\r
+ List<String> messages =\r
+ new ArrayList<>();\r
+ String vesEvent =\r
+ processReceivedJson(\r
+ val);\r
+ if (vesEvent != null && (!(vesEvent\r
+ .isEmpty()\r
+ || vesEvent.equals(\r
+ "")))) {\r
+ messages.add(vesEvent);\r
+ publisher.publish(messages);\r
+ \r
+ metricsLogger.info(\r
+ "Message successfully published to DMaaP Topic-\n"\r
+ + vesEvent);\r
+ }\r
+ \r
+ }\r
+ \r
+ }\r
+ }\r
+ \r
+ \r
+ \r
+ }\r
+ });\r
+ }\r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ /**\r
+ * method stops universal ves adapter module\r
+ */\r
+ public void stop() {\r
+ isRunning = false;\r
+ }\r
+ \r
+ \r
+ /**\r
+ * method for processing the incoming json to ves\r
+ * \r
+ * @param incomingJsonString\r
+ * @return ves\r
+ */\r
+ private String processReceivedJson(String incomingJsonString) {\r
+ String outgoingJsonString = null;\r
+ if (!"".equals(incomingJsonString)) {\r
+ \r
+ try {\r
+ \r
+ outgoingJsonString = eventAdapter.transform(incomingJsonString);\r
+ \r
+ } catch (VesException exception) {\r
+ errorLogger.error(\r
+ "Received exception : {},{}"\r
+ + exception.getMessage(),\r
+ exception);\r
+ debugLogger.warn(\r
+ "APPLICATION WILL BE SHUTDOWN UNTIL ABOVE ISSUE IS RESOLVED.");\r
+ } catch (DMaapException e) {\r
+ errorLogger.error("Received exception : {}", e.getMessage());\r
+ }\r
+ }\r
+ return outgoingJsonString;\r
+ }\r
+}\r
+\r
-/*
-* ============LICENSE_START=======================================================
-* ONAP : DCAE
-* ================================================================================
-* Copyright 2019 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.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-public class CollectorConfigPropertyRetrival {
-
- @Value("${defaultConfigFilelocation}")
- public String defaultConfigFilelocation;
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
- private static JSONArray array;
-
- public static JSONArray collectorConfigArray(String configFile) {
- try {
- JSONParser parser = new JSONParser();
-
- File file = new File(ClassLoader.getSystemResource(configFile.trim()).getFile());
-
- FileReader fileReader = new FileReader(file);
- JSONObject obj = (JSONObject) parser.parse(fileReader);
- JSONObject appobj = (JSONObject) obj.get("app_preferences");
- array = (JSONArray) appobj.get("collectors");
-
- debugLogger.info("Retrieved JsonArray from Collector Config File");
-
- } catch (ParseException e) {
- errorLogger.error("ParseException occured at position:", e.getPosition());
- } catch (FileNotFoundException e) {
-
- errorLogger.error("Collector Config File is not found..", e.getMessage());
- } catch (IOException e) {
-
- errorLogger.error("Error occured due to :", e.getMessage());
- }
-
- return array;
-
- }
-
- public static String[] getProperyArray(String properyName, String defaultConfigFilelocation) {
- JSONArray jsonArray = collectorConfigArray(defaultConfigFilelocation);
-
- String[] propertyArray = new String[jsonArray.size()];
-
- for (int k = 0; k < jsonArray.size(); k++) {
-
- JSONObject collJson = (JSONObject) jsonArray.get(k);
-
- propertyArray[k] = (String) collJson.get(properyName);
- }
- debugLogger.info("returning " + properyName + " array from Collector Config");
- return propertyArray;
-
- }
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : DCAE\r
+ * ================================================================================\r
+ * Copyright 2018-2019 TechMahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.universalvesadapter.utils;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.net.URI;\r
+import java.net.URISyntaxException;\r
+import java.nio.file.Files;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.json.simple.JSONArray;\r
+import org.json.simple.JSONObject;\r
+import org.json.simple.parser.JSONParser;\r
+import org.json.simple.parser.ParseException;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Component;\r
+import org.springframework.util.ResourceUtils;\r
+\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+@Component\r
+public class CollectorConfigPropertyRetrival {\r
+ \r
+ \r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ private static JSONArray array;\r
+ @Autowired\r
+ private DmaapConfig dmaapConfig;\r
+ \r
+ public static JSONArray collectorConfigArray(String configFile) {\r
+ try {\r
+ JSONParser parser = new JSONParser();\r
+ String content = readFile(configFile);\r
+ JSONObject obj = (JSONObject) parser.parse(content);\r
+ JSONObject appobj = (JSONObject) obj.get("app_preferences");\r
+ array = (JSONArray) appobj.get("collectors");\r
+ \r
+ debugLogger.info("Retrieved JsonArray from Collector Config File");\r
+ \r
+ } catch (ParseException e) {\r
+ errorLogger.error("ParseException occured at position:", e.getPosition());\r
+ }\r
+ \r
+ \r
+ return array;\r
+ \r
+ }\r
+ \r
+ public static String[] getProperyArray(String properyName,\r
+ String defaultConfigFilelocation) {\r
+ JSONArray jsonArray = collectorConfigArray(defaultConfigFilelocation);\r
+ \r
+ String[] propertyArray = new String[jsonArray.size()];\r
+ \r
+ for (int k = 0; k < jsonArray.size(); k++) {\r
+ \r
+ JSONObject collJson = (JSONObject) jsonArray.get(k);\r
+ \r
+ propertyArray[k] = (String) collJson.get(properyName);\r
+ }\r
+ debugLogger.info("returning " + properyName + " array from Collector Config");\r
+ return propertyArray;\r
+ \r
+ }\r
+ \r
+ public Map<String, String> getDmaapTopics(String subscriber, String publisher,\r
+ String defaultConfigFilelocation) {\r
+ JSONArray jsonArray = collectorConfigArray(defaultConfigFilelocation);\r
+ \r
+ Map<String, String> dmaapTopics = new HashMap<>();\r
+ \r
+ for (int k = 0; k < jsonArray.size(); k++) {\r
+ \r
+ JSONObject collJson = (JSONObject) jsonArray.get(k);\r
+ \r
+ dmaapTopics.put(collJson.get(subscriber).toString(),\r
+ collJson.get(publisher).toString());\r
+ \r
+ }\r
+ debugLogger.info("returning Dmaap topics from Collector Config");\r
+ return dmaapTopics;\r
+ \r
+ }\r
+ \r
+ public Map<String, String> getTopics(String subscriber, String publisher,\r
+ String defaultConfigFilelocation) {\r
+ Map<String, String> dmaapTopics = new HashMap<>();\r
+ \r
+ try {\r
+ \r
+ ObjectMapper objectMapper = new ObjectMapper();\r
+ String content = readFile(defaultConfigFilelocation);\r
+ // read JSON like DOM Parser\r
+ JsonNode rootNode = objectMapper.readTree(content);\r
+ JsonNode subscriberUrl = rootNode.path("streams_subscribes")\r
+ .path(subscriber).path("dmaap_info").path("topic_url");\r
+ JsonNode publisherUrl = rootNode.path("streams_publishes").path(publisher)\r
+ .path("dmaap_info").path("topic_url");\r
+ \r
+ dmaapTopics.put(getTopicName(subscriberUrl.asText()),\r
+ getTopicName(publisherUrl.asText()));\r
+ setDmaapConfig(subscriberUrl.asText());\r
+ } catch (IOException ex) {\r
+ errorLogger.error("IOException occured:" + ex.getMessage());\r
+ \r
+ } catch (URISyntaxException e) {\r
+ \r
+ errorLogger.error("Invalid URI :" + e.getInput() + ": " + e.getReason());\r
+ }\r
+ \r
+ return dmaapTopics;\r
+ \r
+ }\r
+ \r
+ public String getTopicName(String url) throws URISyntaxException {\r
+ URI uri = new URI(url);\r
+ String path = uri.getPath();\r
+ String idStr = path.substring(path.lastIndexOf('/') + 1);\r
+ return idStr;\r
+ \r
+ }\r
+ \r
+ public void setDmaapConfig(String url) throws URISyntaxException {\r
+ URI uri = new URI(url);\r
+ dmaapConfig.setDmaaphost(uri.getHost());\r
+ dmaapConfig.setDEFAULT_PORT_NUMBER(uri.getPort());\r
+ \r
+ }\r
+ \r
+ public static String readFile(String configFileName) {\r
+ String content = null;\r
+ File file = null;\r
+ \r
+ try {\r
+ file = ResourceUtils.getFile("classpath:" + configFileName);\r
+ content = new String(Files.readAllBytes(file.toPath()));\r
+ } catch (FileNotFoundException e) {\r
+ errorLogger.error("colud not find file :", configFileName);\r
+ \r
+ } catch (IOException e) {\r
+ errorLogger.error("unable to read the file , reason:", e.getCause());\r
+ }\r
+ \r
+ return content;\r
+ \r
+ }\r
+}\r
-/*
- * ===============================LICENSE_START======================================
- * dcae-analytics
- * ================================================================================
- * 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===========================================
- */
-package org.onap.universalvesadapter.utils;
-
-import javax.validation.constraints.NotEmpty;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.stereotype.Component;
-
-@Component
-@PropertySource(value = {"classpath:application.properties","classpath:mapper.properties"})
-@ConfigurationProperties
-public class DmaapConfig {
-
- // Hostname of DMaaP to be taken from ENV var
- @NotEmpty
- private String dmaaphost;
-
- // default port number to be taken from ENV var
- @NotEmpty
- private int DEFAULT_PORT_NUMBER;
-
- @Value("${mr.POLLING_INTERVAL}")
- @NotEmpty
- private int pollingInterval;
-
- // default to no username
- @Value("${mr.DEFAULT_USER_NAME}")
- private String DEFAULT_USER_NAME;
-
-
- //defaults to no userPassword
- @Value("${mr.DEFAULT_USER_PASSWORD}")
- private String DEFAULT_USER_PASSWORD;
-
- //defaults to using https protocol
- @Value("${mr.DEFAULT_PROTOCOL}")
- @NotEmpty
- private String DEFAULT_PROTOCOL;
-
- //defaults to json content type
- @Value("${mr.DEFAULT_CONTENT_TYPE}")
- @NotEmpty
- private String DEFAULT_CONTENT_TYPE;
-
- @Value("${mr.DMAAP_URI_PATH_PREFIX}")
- @NotEmpty
- private String DMAAP_URI_PATH_PREFIX;
-
- @Value("${mr.DMAAP_DEFAULT_CONSUMER_ID}")
- @NotEmpty
- private String DMAAP_DEFAULT_CONSUMER_ID;
-
- @Value("${mr.DMAAP_GROUP_PREFIX}")
- @NotEmpty
- private String DMAAP_GROUP_PREFIX;
-
- // Publisher Constants
-
- //Dmaap Publisher Topic
- @Value("${mr.publisher.topic}")
- @NotEmpty
- private String publisherTopic;
-
- //disable batching by default
- @Value("${mr.publisher.DEFAULT_PUBLISHER_MAX_BATCH_SIZE}")
- @NotEmpty
- private int publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;
-
- //default recovery messages size
- @Value("${mr.publisher.DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE}")
- @NotEmpty
- private int publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;
-
-//number of retries when flushing messages
- @Value("${mr.publisher.PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE}")
- @NotEmpty
- private int publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;
-
- //delay in retrying for flushing messages
- @Value("${mr.publisher.PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE}")
- @NotEmpty
- private int publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;
-
- // Subscriber Constants
-
- @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_TIMEOUT_MS}")
- @NotEmpty
- private int subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;
-
- @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_MESSAGE_LIMIT}")
- @NotEmpty
- private int subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;
-
- @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_GROUP_PREFIX}")
- @NotEmpty
- private String subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;
-
- @Value("${mr.subscriber.SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME}")
- @NotEmpty
- private String subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;
-
- @Value("${mr.subscriber.SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME}")
- @NotEmpty
- private String subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;
-
- public void setDmaaphost(String dmaaphost) {
- this.dmaaphost = dmaaphost;
- }
-
- public String getDmaaphost() {
- return dmaaphost;
- }
-
- public int getDEFAULT_PORT_NUMBER() {
- return DEFAULT_PORT_NUMBER;
- }
-
- public void setDEFAULT_PORT_NUMBER(int dEFAULT_PORT_NUMBER) {
- DEFAULT_PORT_NUMBER = dEFAULT_PORT_NUMBER;
- }
-
- public String getDEFAULT_USER_NAME() {
- return DEFAULT_USER_NAME;
- }
-
- public void setDEFAULT_USER_NAME(String dEFAULT_USER_NAME) {
- DEFAULT_USER_NAME = dEFAULT_USER_NAME;
- }
-
- public String getDEFAULT_USER_PASSWORD() {
- return DEFAULT_USER_PASSWORD;
- }
-
- public void setDEFAULT_USER_PASSWORD(String dEFAULT_USER_PASSWORD) {
- DEFAULT_USER_PASSWORD = dEFAULT_USER_PASSWORD;
- }
-
- public String getDEFAULT_PROTOCOL() {
- return DEFAULT_PROTOCOL;
- }
-
- public void setDEFAULT_PROTOCOL(String dEFAULT_PROTOCOL) {
- DEFAULT_PROTOCOL = dEFAULT_PROTOCOL;
- }
-
- public String getDEFAULT_CONTENT_TYPE() {
- return DEFAULT_CONTENT_TYPE;
- }
-
- public void setDEFAULT_CONTENT_TYPE(String dEFAULT_CONTENT_TYPE) {
- DEFAULT_CONTENT_TYPE = dEFAULT_CONTENT_TYPE;
- }
-
- public String getDMAAP_URI_PATH_PREFIX() {
- return DMAAP_URI_PATH_PREFIX;
- }
-
- public void setDMAAP_URI_PATH_PREFIX(String dMAAP_URI_PATH_PREFIX) {
- DMAAP_URI_PATH_PREFIX = dMAAP_URI_PATH_PREFIX;
- }
-
- public String getDMAAP_DEFAULT_CONSUMER_ID() {
- return DMAAP_DEFAULT_CONSUMER_ID;
- }
-
- public void setDMAAP_DEFAULT_CONSUMER_ID(String dMAAP_DEFAULT_CONSUMER_ID) {
- DMAAP_DEFAULT_CONSUMER_ID = dMAAP_DEFAULT_CONSUMER_ID;
- }
-
- public String getDMAAP_GROUP_PREFIX() {
- return DMAAP_GROUP_PREFIX;
- }
-
- public void setDMAAP_GROUP_PREFIX(String dMAAP_GROUP_PREFIX) {
- DMAAP_GROUP_PREFIX = dMAAP_GROUP_PREFIX;
- }
-
- public String getPublisherTopic() {
- return publisherTopic;
- }
-
- public void setPublisherTopic(String publisherTopic) {
- this.publisherTopic = publisherTopic;
- }
-
- public int getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE() {
- return publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;
- }
-
- public void setPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE(int publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE) {
- this.publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE = publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;
- }
-
- public int getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE() {
- return publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;
- }
-
- public void setPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE(
- int publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE) {
- this.publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;
- }
-
- public int getPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE() {
- return publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;
- }
-
- public void setPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE(int publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE) {
- this.publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE = publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;
- }
-
- public int getPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE() {
- return publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;
- }
-
- public void setPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE(int publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE) {
- this.publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE = publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;
- }
-
- public int getsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS() {
- return subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;
- }
-
- public void setsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS(int subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS) {
- this.subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS = subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;
- }
-
- public int getsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT() {
- return subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;
- }
-
- public void setsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT(int subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT) {
- this.subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT = subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;
- }
-
- public String getsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX() {
- return subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;
- }
-
- public void setsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX(String subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX) {
- this.subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX = subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;
- }
-
- public String getsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME() {
- return subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;
- }
-
- public void setsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME(String subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME) {
- this.subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME = subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;
- }
-
- public String getsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME() {
- return subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;
- }
-
- public void setsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME(String subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME) {
- this.subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME = subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;
- }
-
- public int getPollingInterval() {
- return pollingInterval;
- }
-
- public void setPollingInterval(int pollingInterval) {
- this.pollingInterval = pollingInterval;
- }
-
-
-}
+/*\r
+ * ===============================LICENSE_START======================================\r
+ * dcae-analytics\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============================LICENSE_END===========================================\r
+ */\r
+package org.onap.universalvesadapter.utils;\r
+\r
+import javax.validation.constraints.NotEmpty;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.context.properties.ConfigurationProperties;\r
+import org.springframework.context.annotation.PropertySource;\r
+import org.springframework.stereotype.Component;\r
+\r
+@Component\r
+@PropertySource(value = {"classpath:application.properties","classpath:mapper.properties"})\r
+@ConfigurationProperties\r
+public class DmaapConfig {\r
+ \r
+ @NotEmpty\r
+ private String dmaaphost;\r
+ \r
+ @NotEmpty\r
+ private int DEFAULT_PORT_NUMBER;\r
+ \r
+ @Value("${mr.POLLING_INTERVAL}")\r
+ @NotEmpty\r
+ private int pollingInterval;\r
+ \r
+ // default to no username\r
+ @Value("${mr.DEFAULT_USER_NAME}")\r
+ private String DEFAULT_USER_NAME;\r
+ \r
+ \r
+ //defaults to no userPassword\r
+ @Value("${mr.DEFAULT_USER_PASSWORD}")\r
+ private String DEFAULT_USER_PASSWORD;\r
+ \r
+ //defaults to using https protocol\r
+ @Value("${mr.DEFAULT_PROTOCOL}")\r
+ @NotEmpty\r
+ private String DEFAULT_PROTOCOL;\r
+ \r
+ //defaults to json content type\r
+ @Value("${mr.DEFAULT_CONTENT_TYPE}")\r
+ @NotEmpty\r
+ private String DEFAULT_CONTENT_TYPE;\r
+\r
+ @Value("${mr.DMAAP_URI_PATH_PREFIX}")\r
+ @NotEmpty\r
+ private String DMAAP_URI_PATH_PREFIX;\r
+ \r
+ @Value("${mr.DMAAP_DEFAULT_CONSUMER_ID}")\r
+ @NotEmpty\r
+ private String DMAAP_DEFAULT_CONSUMER_ID;\r
+ \r
+ @Value("${mr.DMAAP_GROUP_PREFIX}")\r
+ @NotEmpty\r
+ private String DMAAP_GROUP_PREFIX;\r
+ \r
+ // Publisher Constants\r
+ \r
+ //disable batching by default\r
+ @Value("${mr.publisher.DEFAULT_PUBLISHER_MAX_BATCH_SIZE}")\r
+ @NotEmpty\r
+ private int publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;\r
+ \r
+ //default recovery messages size\r
+ @Value("${mr.publisher.DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE}")\r
+ @NotEmpty\r
+ private int publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;\r
+ \r
+//number of retries when flushing messages\r
+ @Value("${mr.publisher.PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE}")\r
+ @NotEmpty\r
+ private int publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;\r
+\r
+ //delay in retrying for flushing messages\r
+ @Value("${mr.publisher.PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE}")\r
+ @NotEmpty \r
+ private int publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;\r
+\r
+ // Subscriber Constants\r
+ \r
+ @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_TIMEOUT_MS}")\r
+ @NotEmpty\r
+ private int subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;\r
+ \r
+ @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_MESSAGE_LIMIT}")\r
+ @NotEmpty\r
+ private int subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;\r
+ \r
+ @Value("${mr.subscriber.DEFAULT_SUBSCRIBER_GROUP_PREFIX}")\r
+ @NotEmpty\r
+ private String subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;\r
+ \r
+ @Value("${mr.subscriber.SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME}")\r
+ @NotEmpty\r
+ private String subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;\r
+ \r
+ @Value("${mr.subscriber.SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME}")\r
+ @NotEmpty\r
+ private String subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;\r
+\r
+ public void setDmaaphost(String dmaaphost) {\r
+ this.dmaaphost = dmaaphost;\r
+ }\r
+ \r
+ public String getDmaaphost() {\r
+ return dmaaphost;\r
+ }\r
+\r
+ public int getDEFAULT_PORT_NUMBER() {\r
+ return DEFAULT_PORT_NUMBER;\r
+ }\r
+\r
+ public void setDEFAULT_PORT_NUMBER(int dEFAULT_PORT_NUMBER) {\r
+ DEFAULT_PORT_NUMBER = dEFAULT_PORT_NUMBER;\r
+ }\r
+\r
+ public String getDEFAULT_USER_NAME() {\r
+ return DEFAULT_USER_NAME;\r
+ }\r
+\r
+ public void setDEFAULT_USER_NAME(String dEFAULT_USER_NAME) {\r
+ DEFAULT_USER_NAME = dEFAULT_USER_NAME;\r
+ }\r
+\r
+ public String getDEFAULT_USER_PASSWORD() {\r
+ return DEFAULT_USER_PASSWORD;\r
+ }\r
+\r
+ public void setDEFAULT_USER_PASSWORD(String dEFAULT_USER_PASSWORD) {\r
+ DEFAULT_USER_PASSWORD = dEFAULT_USER_PASSWORD;\r
+ }\r
+\r
+ public String getDEFAULT_PROTOCOL() {\r
+ return DEFAULT_PROTOCOL;\r
+ }\r
+\r
+ public void setDEFAULT_PROTOCOL(String dEFAULT_PROTOCOL) {\r
+ DEFAULT_PROTOCOL = dEFAULT_PROTOCOL;\r
+ }\r
+\r
+ public String getDEFAULT_CONTENT_TYPE() {\r
+ return DEFAULT_CONTENT_TYPE;\r
+ }\r
+\r
+ public void setDEFAULT_CONTENT_TYPE(String dEFAULT_CONTENT_TYPE) {\r
+ DEFAULT_CONTENT_TYPE = dEFAULT_CONTENT_TYPE;\r
+ }\r
+\r
+ public String getDMAAP_URI_PATH_PREFIX() {\r
+ return DMAAP_URI_PATH_PREFIX;\r
+ }\r
+\r
+ public void setDMAAP_URI_PATH_PREFIX(String dMAAP_URI_PATH_PREFIX) {\r
+ DMAAP_URI_PATH_PREFIX = dMAAP_URI_PATH_PREFIX;\r
+ }\r
+\r
+ public String getDMAAP_DEFAULT_CONSUMER_ID() {\r
+ return DMAAP_DEFAULT_CONSUMER_ID;\r
+ }\r
+\r
+ public void setDMAAP_DEFAULT_CONSUMER_ID(String dMAAP_DEFAULT_CONSUMER_ID) {\r
+ DMAAP_DEFAULT_CONSUMER_ID = dMAAP_DEFAULT_CONSUMER_ID;\r
+ }\r
+\r
+ public String getDMAAP_GROUP_PREFIX() {\r
+ return DMAAP_GROUP_PREFIX;\r
+ }\r
+\r
+ public void setDMAAP_GROUP_PREFIX(String dMAAP_GROUP_PREFIX) {\r
+ DMAAP_GROUP_PREFIX = dMAAP_GROUP_PREFIX;\r
+ }\r
+\r
+ public int getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE() {\r
+ return publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;\r
+ }\r
+\r
+ public void setPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE(int publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE) {\r
+ this.publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE = publisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE;\r
+ }\r
+\r
+ public int getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE() {\r
+ return publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;\r
+ }\r
+\r
+ public void setPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE(\r
+ int publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE) {\r
+ this.publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = publisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE;\r
+ }\r
+\r
+ public int getPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE() {\r
+ return publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;\r
+ }\r
+\r
+ public void setPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE(int publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE) {\r
+ this.publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE = publisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE;\r
+ }\r
+\r
+ public int getPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE() {\r
+ return publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;\r
+ }\r
+\r
+ public void setPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE(int publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE) {\r
+ this.publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE = publisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE;\r
+ }\r
+\r
+ public int getsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS() {\r
+ return subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;\r
+ }\r
+\r
+ public void setsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS(int subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS) {\r
+ this.subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS = subscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS;\r
+ }\r
+\r
+ public int getsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT() {\r
+ return subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;\r
+ }\r
+\r
+ public void setsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT(int subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT) {\r
+ this.subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT = subscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT;\r
+ }\r
+\r
+ public String getsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX() {\r
+ return subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;\r
+ }\r
+\r
+ public void setsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX(String subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX) {\r
+ this.subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX = subscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX;\r
+ }\r
+\r
+ public String getsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME() {\r
+ return subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;\r
+ }\r
+\r
+ public void setsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME(String subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME) {\r
+ this.subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME = subscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME;\r
+ }\r
+\r
+ public String getsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME() {\r
+ return subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;\r
+ }\r
+\r
+ public void setsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME(String subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME) {\r
+ this.subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME = subscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME;\r
+ }\r
+\r
+ public int getPollingInterval() {\r
+ return pollingInterval;\r
+ }\r
+\r
+ public void setPollingInterval(int pollingInterval) {\r
+ this.pollingInterval = pollingInterval;\r
+ }\r
+ \r
+\r
+}\r
-/*
-* ============LICENSE_START=======================================================
-* ONAP : DCAE
-* ================================================================================
-* Copyright 2019 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.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Map;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@Component
-public class FetchDynamicConfig {
-
- private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");
-
- private static String url;
- public static String retString;
- public static String retCBSString;
- private static Map<String, String> env;
-
- public FetchDynamicConfig() {
- }
-
- public static void cbsCall(String configFile) {
-
- env = System.getenv();
- Boolean areEqual;
- // Call consul api and identify the CBS Service address and port
- getconsul();
- // Construct and invoke CBS API to get application Configuration
- getCBS();
- // Verify if data has changed
- areEqual = verifyConfigChange(configFile);
-
- if (!areEqual) {
- FetchDynamicConfig fc = new FetchDynamicConfig();
- fc.writefile(retCBSString,configFile);
- } else {
- debugLogger.info("New config pull results identical - " + configFile + " NOT refreshed");
- }
- }
-
-
- private static void getconsul() {
- url = env.get("CONSUL_HOST") + ":8500/v1/catalog/service/" + env.get("CONFIG_BINDING_SERVICE");
- retString = executecurl(url);
- debugLogger.info("CBS details fetched from Consul");
- }
-
- public static boolean verifyConfigChange(String configFile) {
-
- boolean areEqual = false;
- // Read current data
- try {
- File f = new File(configFile);
- if (f.exists() && !f.isDirectory()) {
-
- String jsonData = readFile(configFile);
- JSONObject jsonObject = new JSONObject(jsonData);
-
- ObjectMapper mapper = new ObjectMapper();
-
- JsonNode tree1 = mapper.readTree(jsonObject.toString());
- JsonNode tree2 = mapper.readTree(retCBSString);
- areEqual = tree1.equals(tree2);
- debugLogger.info("Comparison value:" + areEqual);
- } else {
- debugLogger.info("First time config file read: " + configFile);
- }
-
- } catch (IOException e) {
- errorLogger.error("Comparison with new fetched data failed" + e.getMessage());
-
- }
-
- return areEqual;
-
- }
-
- public static void getCBS() {
-
- // consul return as array
- JSONTokener temp = new JSONTokener(retString);
- JSONObject cbsjobj = (JSONObject) new JSONArray(temp).get(0);
-
- String urlPart1 = null;
- if (cbsjobj.has("ServiceAddress") && cbsjobj.has("ServicePort")) {
-
- urlPart1 = cbsjobj.getString("ServiceAddress") + ":" + cbsjobj.getInt("ServicePort");
-
- }
- debugLogger.info("CONFIG_BINDING_SERVICE DNS RESOLVED:" + urlPart1);
-
- if (env.containsKey("HOSTNAME")) {
- url = urlPart1 + "/service_component/" + env.get("HOSTNAME");
- retCBSString = executecurl(url);
- } else if (env.containsKey("SERVICE_NAME")) {
- url = urlPart1 + "/service_component/" + env.get("SERVICE_NAME");
- retCBSString = executecurl(url);
- } else {
- errorLogger.error("Service name environment variable - HOSTNAME/SERVICE_NAME not found within container ");
- }
-
- }
-
- public void writefile(String retCBSString, String configFile) {
- debugLogger.info("URL to fetch configuration:" + url);
-
- String indentedretstring = (new JSONObject(retCBSString)).toString(4);
-
- try (FileWriter file = new FileWriter(configFile)) {
- file.write(indentedretstring);
-
- debugLogger.info("Successfully Copied JSON Object to file " + configFile);
- } catch (IOException e) {
- errorLogger.error("Error in writing configuration into file " + configFile + retString + e.getMessage());
- e.printStackTrace();
- }
-
- }
-
- public static String readFile(String filename) {
- String result = "";
- try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
- StringBuilder sb = new StringBuilder();
- String line = br.readLine();
- while (line != null) {
- sb.append(line);
- line = br.readLine();
- }
- result = sb.toString();
- } catch (FileNotFoundException e) {
- errorLogger.error("colud not find file :",filename);
-
- } catch (Exception e) {
- errorLogger.error("unable to read the file , reason:",e.getCause());
- }
- return result;
- }
- private static String executecurl(String url) {
-
- String[] command = { "curl", "-v", url };
- ProcessBuilder process = new ProcessBuilder(command);
- Process p;
- String result = null;
- try {
- p = process.start();
- InputStreamReader ipr = new InputStreamReader(p.getInputStream());
- BufferedReader reader = new BufferedReader(ipr);
- StringBuilder builder = new StringBuilder();
- String line;
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
- result = builder.toString();
- reader.close();
- ipr.close();
- } catch (IOException e) {
- errorLogger.error("error", e);
- e.printStackTrace();
- }
- return result;
-
- }
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : DCAE\r
+ * ================================================================================\r
+ * Copyright 2019 TechMahindra\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.universalvesadapter.utils;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.io.InputStreamReader;\r
+import java.io.PrintWriter;\r
+import java.nio.file.Files;\r
+import java.util.Map;\r
+\r
+import org.json.JSONArray;\r
+import org.json.JSONObject;\r
+import org.json.JSONTokener;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.stereotype.Component;\r
+import org.springframework.util.ResourceUtils;\r
+\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+@Component\r
+public class FetchDynamicConfig {\r
+ \r
+ private static final Logger debugLogger = LoggerFactory.getLogger("debugLogger");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
+ \r
+ private static String url;\r
+ public static String retString;\r
+ public static String retCBSString;\r
+ private static Map<String, String> env;\r
+ \r
+ public FetchDynamicConfig() {}\r
+ \r
+ public static void cbsCall(String configFile) {\r
+ \r
+ env = System.getenv();\r
+ Boolean areEqual;\r
+ // Call consul api and identify the CBS Service address and port\r
+ getconsul();\r
+ // Construct and invoke CBS API to get application Configuration\r
+ getCBS();\r
+ // Verify if data has changed\r
+ areEqual = verifyConfigChange(configFile);\r
+ \r
+ if (!areEqual) {\r
+ FetchDynamicConfig fc = new FetchDynamicConfig();\r
+ fc.writefile(retCBSString, configFile);\r
+ } else {\r
+ debugLogger.info("New config pull results identical - " + configFile\r
+ + " NOT refreshed");\r
+ }\r
+ }\r
+ \r
+ \r
+ private static void getconsul() {\r
+ url = env.get("CONSUL_HOST") + ":8500/v1/catalog/service/"\r
+ + env.get("CONFIG_BINDING_SERVICE");\r
+ retString = executecurl(url);\r
+ debugLogger.info("CBS details fetched from Consul");\r
+ }\r
+ \r
+ public static boolean verifyConfigChange(String configFile) {\r
+ \r
+ boolean areEqual = false;\r
+ // Read current data\r
+ try {\r
+ \r
+ File f = new File(\r
+ ClassLoader.getSystemResource(configFile.trim()).getFile());\r
+ \r
+ if (f.exists() && !f.isDirectory()) {\r
+ debugLogger.info(\r
+ "Comparing local configuration with the configuration fethed from CBS ");\r
+ \r
+ String jsonData = readFile(configFile);\r
+ JSONObject jsonObject = new JSONObject(jsonData);\r
+ \r
+ ObjectMapper mapper = new ObjectMapper();\r
+ \r
+ JsonNode tree1 = mapper.readTree(jsonObject.toString());\r
+ JsonNode tree2 = mapper.readTree(retCBSString);\r
+ areEqual = tree1.equals(tree2);\r
+ debugLogger.info("Comparison value:" + areEqual);\r
+ } else {\r
+ debugLogger.info("First time config file read: " + configFile);\r
+ }\r
+ \r
+ } catch (IOException e) {\r
+ errorLogger.error(\r
+ "Comparison with new fetched data failed" + e.getMessage());\r
+ \r
+ }\r
+ \r
+ return areEqual;\r
+ \r
+ }\r
+ \r
+ public static void getCBS() {\r
+ \r
+ // consul return as array\r
+ JSONTokener temp = new JSONTokener(retString);\r
+ JSONObject cbsjobj = (JSONObject) new JSONArray(temp).get(0);\r
+ \r
+ String urlPart1 = null;\r
+ if (cbsjobj.has("ServiceAddress") && cbsjobj.has("ServicePort")) {\r
+ \r
+ urlPart1 = cbsjobj.getString("ServiceAddress") + ":"\r
+ + cbsjobj.getInt("ServicePort");\r
+ \r
+ }\r
+ debugLogger.info("CONFIG_BINDING_SERVICE HOST:PORT is " + urlPart1);\r
+ \r
+ if (env.containsKey("HOSTNAME")) {\r
+ url = urlPart1 + "/service_component/" + env.get("HOSTNAME");\r
+ retCBSString = executecurl(url);\r
+ debugLogger.info("Configuration fetched from CBS successfully..");\r
+ } else if (env.containsKey("SERVICE_NAME")) {\r
+ url = urlPart1 + "/service_component/" + env.get("SERVICE_NAME");\r
+ retCBSString = executecurl(url);\r
+ debugLogger.info("Configuration fetched from CBS successfully..");\r
+ } else {\r
+ errorLogger.error(\r
+ "Service name environment variable - HOSTNAME/SERVICE_NAME not found within container ");\r
+ }\r
+ \r
+ }\r
+ \r
+ public void writefile(String retCBSString, String configFile) {\r
+ \r
+ String indentedretstring = (new JSONObject(retCBSString)).toString(4);\r
+ File f = new File(ClassLoader.getSystemResource(configFile.trim()).getFile());\r
+ try {\r
+ debugLogger.info("Overwriting local configuration file " + configFile\r
+ + " with configuartions received from CBS");\r
+ \r
+ \r
+ File file2 = ResourceUtils.getFile("classpath:" + configFile);\r
+ FileWriter fstream = new FileWriter(file2, false);\r
+ PrintWriter printWriter = new PrintWriter(fstream);\r
+ printWriter.print(indentedretstring);\r
+ printWriter.close();\r
+ \r
+ debugLogger.info("New Config successfully written to local file to "\r
+ + configFile);\r
+ } catch (IOException e) {\r
+ errorLogger.error("Error in writing configuration into local KV file "\r
+ + configFile + retString + e.getMessage());\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
+ \r
+ public static String readFile(String configFileName) {\r
+ String content = null;\r
+ File file = null;\r
+ \r
+ try {\r
+ file = ResourceUtils.getFile("classpath:" + configFileName);\r
+ content = new String(Files.readAllBytes(file.toPath()));\r
+ } catch (FileNotFoundException e) {\r
+ errorLogger.error("colud not find file :", file.getName());\r
+ \r
+ } catch (IOException e) {\r
+ errorLogger.error("unable to read the file , reason:", e.getCause());\r
+ } catch (Exception e) {\r
+ errorLogger.error("Exception occured , reason:", e.getMessage());\r
+ }\r
+ \r
+ return content;\r
+ \r
+ }\r
+ \r
+ private static String executecurl(String url) {\r
+ \r
+ String[] command = {"curl", "-v", url};\r
+ ProcessBuilder process = new ProcessBuilder(command);\r
+ Process p;\r
+ String result = null;\r
+ try {\r
+ p = process.start();\r
+ InputStreamReader ipr = new InputStreamReader(p.getInputStream());\r
+ BufferedReader reader = new BufferedReader(ipr);\r
+ StringBuilder builder = new StringBuilder();\r
+ String line;\r
+ \r
+ while ((line = reader.readLine()) != null) {\r
+ builder.append(line);\r
+ }\r
+ result = builder.toString();\r
+ reader.close();\r
+ ipr.close();\r
+ } catch (IOException e) {\r
+ errorLogger.error("error", e);\r
+ e.printStackTrace();\r
+ }\r
+ return result;\r
+ \r
+ }\r
+ \r
+}\r
<?xml version="1.0" encoding="UTF-8"?>\r
-<!-- Created with Liquid Technologies Online Tools 1.0 (https://www.liquid-technologies.com) -->\r
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd" xmlns:json="http://www.milyn.org/xsd/smooks/json-1.1.xsd">\r
<json:reader rootName="vesevent" keyWhitspaceReplacement="-">\r
<json:keyMap>\r
<json:key from="date&time" to="date-and-time" />\r
</json:keyMap>\r
</json:reader>\r
- <jb:bean class="org.onap.dcaegen2.ves.domain.ves5_4.VesEvent" beanId="vesEvent" createOnElement="vesevent">\r
+ <jb:bean class="org.onap.dcaegen2.ves.domain.ves54.VesEvent" beanId="vesEvent" createOnElement="vesevent">\r
<jb:wiring property="event" beanIdRef="event" />\r
</jb:bean>\r
- <jb:bean class="org.onap.dcaegen2.ves.domain.ves5_4.Event" beanId="event" createOnElement="vesevent">\r
+ <jb:bean class="org.onap.dcaegen2.ves.domain.ves54.Event" beanId="event" createOnElement="vesevent">\r
<jb:wiring property="commonEventHeader" beanIdRef="commonEventHeader" />\r
- <jb:wiring property="faultFields" beanIdRef="faultFields"/>\r
+ <jb:wiring property="faultFields" beanIdRef="faultFields" />\r
</jb:bean>\r
- <jb:bean class="org.onap.dcaegen2.ves.domain.ves5_4.CommonEventHeader" beanId="commonEventHeader" createOnElement="vesevent">\r
- <jb:expression property="version">"3.0"</jb:expression>\r
+ <jb:bean class="org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader" beanId="commonEventHeader" createOnElement="vesevent">\r
+ <jb:expression property="version">'3.0'</jb:expression>\r
<jb:expression property="eventType">'FaultField'</jb:expression>\r
<jb:expression property="eventId" execOnElement="vesevent">'XXXX'</jb:expression>\r
<jb:expression property="reportingEntityName">'VESMapper'</jb:expression>\r
- <jb:expression property="domain">org.onap.dcaegen2.ves.domain.ves5_4.CommonEventHeader.Domain.FAULT</jb:expression>\r
+ <jb:expression property="domain">org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Domain.FAULT</jb:expression>\r
<jb:expression property="eventName" execOnElement="vesevent">commonEventHeader.domain</jb:expression>\r
<jb:value property="sequence" data="0" default="0" decoder="Long" />\r
- <jb:value property="lastEpochMicrosec" data="#/time-received" />\r
- <jb:value property="startEpochMicrosec" data="#/time-received" />\r
- <jb:expression property="priority">org.onap.dcaegen2.ves.domain.ves5_4.CommonEventHeader.Priority.NORMAL</jb:expression>\r
- <jb:expression property="sourceName">"VesAdapter"</jb:expression>\r
-\r
- </jb:bean>\r
- <jb:bean class="org.onap.dcaegen2.ves.domain.ves5_4.FaultFields" beanId="faultFields" createOnElement="vesevent">\r
- <jb:value property="faultFieldsVersion" data="2.0" default="2.0" decoder="Double" />\r
-<jb:value property="alarmCondition" data="#/trap-category" />\r
- <jb:expression property="specificProblem">"SNMP Fault"</jb:expression>\r
- <jb:expression property="vfStatus">org.onap.dcaegen2.ves.domain.ves5_4.FaultFields.VfStatus.ACTIVE</jb:expression>\r
-\r
- <jb:expression property="eventSeverity">org.onap.dcaegen2.ves.domain.ves5_4.FaultFields.EventSeverity.MINOR</jb:expression>\r
-\r
- <jb:wiring property="alarmAdditionalInformation" beanIdRef="alarmAdditionalInformationroot"/>\r
-\r
- </jb:bean>\r
- \r
- \r
- <jb:bean class="java.util.ArrayList" beanId="alarmAdditionalInformationroot" createOnElement="vesevent">\r
- <jb:wiring beanIdRef="alarmAdditionalInformation"/>\r
- </jb:bean>\r
-\r
- <jb:bean class="org.onap.dcaegen2.ves.domain.ves5_4.AlarmAdditionalInformation" beanId="alarmAdditionalInformation" createOnElement="varbinds/element">\r
- <jb:value property="name" data="#/varbind_oid"/>\r
- <jb:value property="value" data="#/varbind_value" />\r
- </jb:bean>\r
+ <jb:value property="lastEpochMicrosec" data="#/time-received" />\r
+ <jb:value property="startEpochMicrosec" data="#/time-received" />\r
+ <jb:expression property="priority">org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Priority.NORMAL</jb:expression>\r
+ <jb:expression property="sourceName">'VesAdapter'</jb:expression>\r
+ </jb:bean>\r
+ <jb:bean class="org.onap.dcaegen2.ves.domain.ves54.FaultFields" beanId="faultFields" createOnElement="vesevent">\r
+ <jb:value property="faultFieldsVersion" data="2.0" default="2.0" decoder="Double" />\r
+ <jb:value property="alarmCondition" data="#/trap-category" />\r
+ <jb:expression property="specificProblem">'SNMP Fault'</jb:expression>\r
+ <jb:expression property="vfStatus">org.onap.dcaegen2.ves.domain.ves54.FaultFields.VfStatus.ACTIVE</jb:expression>\r
+ <jb:expression property="eventSeverity">org.onap.dcaegen2.ves.domain.ves54.FaultFields.EventSeverity.MINOR</jb:expression>\r
+ <jb:wiring property="alarmAdditionalInformation" beanIdRef="alarmAdditionalInformationroot" />\r
+ </jb:bean>\r
+ <jb:bean class="java.util.ArrayList" beanId="alarmAdditionalInformationroot" createOnElement="vesevent">\r
+ <jb:wiring beanIdRef="alarmAdditionalInformation" />\r
+ </jb:bean>\r
+ <jb:bean class="org.onap.dcaegen2.ves.domain.ves54.AlarmAdditionalInformation" beanId="alarmAdditionalInformation" createOnElement="varbinds/element">\r
+ <jb:value property="name" data="#/varbind_oid" />\r
+ <jb:value property="value" data="#/varbind_value" />\r
+ </jb:bean>\r
</smooks-resource-list>
\ No newline at end of file
"app_preferences":{ \r
"collectors":[ \r
{ \r
- "identifier":"notification-id",\r
- "subscriberTopic":"ONAP-COLLECTOR-RESTCONFTRAP",\r
+ "stream_subscriber":"rcc-notification",\r
"mapping-files":[ \r
{ \r
- "defaultMappingFile-ONAP-COLLECTOR-RESTCONFTRAP":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /><\/json:keyMap><\/json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='pnfRegistrationFields' beanIdRef='pnfRegistrationFields' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1<\/jb:expression><jb:expression property='eventType'>'pnfRegistration'<\/jb:expression><jb:expression property='vesEventListenerVersion'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1<\/jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'registration_'+commonEventHeader.ts1<\/jb:expression><jb:expression property='reportingEntityName'>'VESMapper'<\/jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION<\/jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain<\/jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:expression property='lastEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1<\/jb:expression><jb:expression property='startEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1<\/jb:expression><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL<\/jb:expression><jb:value property='sourceName' data='notification/message/target' /><\/jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields' beanId='pnfRegistrationFields' createOnElement='vesevent'><jb:expression property='pnfRegistrationFieldsVersion'>org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0<\/jb:expression><jb:value property='serialNumber' data='notification/message/content/onu/sn' /><\/jb:bean><\/smooks-resource-list>"\r
+ "defaultMappingFile-rcc-notification":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /></json:keyMap></json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='pnfRegistrationFields' beanIdRef='pnfRegistrationFields' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1</jb:expression><jb:expression property='eventType'>'pnfRegistration'</jb:expression><jb:expression property='vesEventListenerVersion'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1</jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'registration_'+commonEventHeader.ts1</jb:expression><jb:expression property='reportingEntityName'>'VESMapper'</jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION</jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain</jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:expression property='lastEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1</jb:expression><jb:expression property='startEpochMicrosec' execOnElement='vesevent'>commonEventHeader.ts1</jb:expression><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL</jb:expression><jb:expression property='sourceName' execOnElement='vesevent'>pnfRegistrationFields.vendorName+'-'+pnfRegistrationFields.serialNumber</jb:expression></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields' beanId='pnfRegistrationFields' createOnElement='vesevent'><jb:expression property='pnfRegistrationFieldsVersion'>org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0</jb:expression><jb:value property='serialNumber' data='pnfRegistration/serialNumber' /><jb:value property='lastServiceDate' data='pnfRegistration/lastServiceDate' /><jb:value property='manufactureDate' data='pnfRegistration/manufactureDate' /><jb:value property='modelNumber' data='pnfRegistration/modelNumber' /><jb:value property='oamV4IpAddress' data='pnfRegistration/oamV4IpAddress' /><jb:value property='oamV6IpAddress' data='pnfRegistration/oamV6IpAddress' /><jb:value property='softwareVersion' data='pnfRegistration/softwareVersion' /><jb:value property='unitFamily' data='pnfRegistration/unitFamily' /><jb:value property='unitType' data='pnfRegistration/unitType' /><jb:value property='vendorName' data='pnfRegistration/vendorName' /><jb:wiring property='additionalFields' beanIdRef='alarmAdditionalInformation'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves70.AlarmAdditionalInformation' beanId='alarmAdditionalInformation' createOnElement='vesevent'><jb:wiring property='additionalProperties' beanIdRef='additionalFields2'/></jb:bean><jb:bean beanId='additionalFields2' class='java.util.HashMap' createOnElement='vesevent/pnfRegistration/additionalFields'><jb:value data='pnfRegistration/additionalFields/*' /></jb:bean></smooks-resource-list>"\r
}\r
- ]\r
+ ],\r
+ "identifier":"notification-id",\r
+ "stream_publisher":"ves-pnfRegistration"\r
},\r
- { \r
+ { \r
"identifier":"notify OID",\r
- "subscriberTopic":"ONAP-COLLECTOR-SNMPTRAP",\r
+ "stream_subscriber":"snmp-notification",\r
"mapping-files":[ \r
{ \r
- "defaultMappingFile-ONAP-COLLECTOR-SNMPTRAP":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /></json:keyMap></json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='faultFields' beanIdRef='faultFields'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>'3.0'</jb:expression><jb:expression property='eventType'>'FaultField'</jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'XXXX'</jb:expression><jb:expression property='reportingEntityName'>'VESMapper'</jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Domain.FAULT</jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain</jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:value property='lastEpochMicrosec' data='#/time-received' /><jb:value property='startEpochMicrosec' data='#/time-received' /><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Priority.NORMAL</jb:expression><jb:expression property='sourceName'>'VesAdapter'</jb:expression></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.FaultFields' beanId='faultFields' createOnElement='vesevent'><jb:value property='faultFieldsVersion' data='2.0' default='2.0' decoder='Double' /><jb:value property='alarmCondition' data='#/trap-category' /><jb:expression property='specificProblem'>'SNMP Fault'</jb:expression><jb:expression property='vfStatus'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.VfStatus.ACTIVE</jb:expression><jb:expression property='eventSeverity'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.EventSeverity.MINOR</jb:expression><jb:wiring property='alarmAdditionalInformation' beanIdRef='alarmAdditionalInformationroot'/></jb:bean><jb:bean class='java.util.ArrayList' beanId='alarmAdditionalInformationroot' createOnElement='vesevent'><jb:wiring beanIdRef='alarmAdditionalInformation'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.AlarmAdditionalInformation' beanId='alarmAdditionalInformation' createOnElement='varbinds/element'><jb:value property='name' data='#/varbind_oid'/><jb:value property='value' data='#/varbind_value' /></jb:bean></smooks-resource-list>"\r
+ "defaultMappingFile-snmp-notification":"<?xml version='1.0' encoding='UTF-8'?><smooks-resource-list xmlns='http://www.milyn.org/xsd/smooks-1.1.xsd' xmlns:jb='http://www.milyn.org/xsd/smooks/javabean-1.4.xsd' xmlns:json='http://www.milyn.org/xsd/smooks/json-1.1.xsd'><json:reader rootName='vesevent' keyWhitspaceReplacement='-'><json:keyMap><json:key from='date&time' to='date-and-time' /></json:keyMap></json:reader><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.VesEvent' beanId='vesEvent' createOnElement='vesevent'><jb:wiring property='event' beanIdRef='event' /></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.Event' beanId='event' createOnElement='vesevent'><jb:wiring property='commonEventHeader' beanIdRef='commonEventHeader' /><jb:wiring property='faultFields' beanIdRef='faultFields'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader' beanId='commonEventHeader' createOnElement='vesevent'><jb:expression property='version'>'3.0'</jb:expression><jb:expression property='eventType'>'FaultField'</jb:expression><jb:expression property='eventId' execOnElement='vesevent'>'XXXX'</jb:expression><jb:expression property='reportingEntityName'>'VESMapper'</jb:expression><jb:expression property='domain'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Domain.FAULT</jb:expression><jb:expression property='eventName' execOnElement='vesevent'>commonEventHeader.domain</jb:expression><jb:value property='sequence' data='0' default='0' decoder='Long' /><jb:value property='lastEpochMicrosec' data='#/time-received' /><jb:value property='startEpochMicrosec' data='#/time-received' /><jb:expression property='priority'>org.onap.dcaegen2.ves.domain.ves54.CommonEventHeader.Priority.NORMAL</jb:expression><jb:expression property='sourceName'>'VesAdapter'</jb:expression></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.FaultFields' beanId='faultFields' createOnElement='vesevent'><jb:value property='faultFieldsVersion' data='2.0' default='2.0' decoder='Double' /><jb:value property='alarmCondition' data='#/trap-category' /><jb:expression property='specificProblem'>'SNMP Fault'</jb:expression><jb:expression property='vfStatus'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.VfStatus.ACTIVE</jb:expression><jb:expression property='eventSeverity'>org.onap.dcaegen2.ves.domain.ves54.FaultFields.EventSeverity.MINOR</jb:expression><jb:wiring property='alarmAdditionalInformation' beanIdRef='alarmAdditionalInformationroot'/></jb:bean><jb:bean class='java.util.ArrayList' beanId='alarmAdditionalInformationroot' createOnElement='vesevent'><jb:wiring beanIdRef='alarmAdditionalInformation'/></jb:bean><jb:bean class='org.onap.dcaegen2.ves.domain.ves54.AlarmAdditionalInformation' beanId='alarmAdditionalInformation' createOnElement='varbinds/element'><jb:value property='name' data='#/varbind_oid'/><jb:value property='value' data='#/varbind_value' /></jb:bean></smooks-resource-list>"\r
}\r
- ]\r
+ ],\r
+ "stream_publisher":"ves-fault"\r
}\r
]\r
+ },\r
+ "streams_publishes":{ \r
+ "ves-fault":{ \r
+ "type":"message_router",\r
+ "dmaap_info":{ \r
+ "topic_url":"http://10.53.172.156:3904/events/unauthenticated.SEC_FAULT_OUTPUT"\r
+ }\r
+ },\r
+ "ves-pnfRegistration":{ \r
+ "type":"message_router",\r
+ "dmaap_info":{ \r
+ "topic_url":"http://10.53.172.156:3904/events/unauthenticated.VES_PNFREG_OUTPUT"\r
+ }\r
+ }\r
+ },\r
+ "streams_subscribes":{ \r
+ "snmp-notification":{ \r
+ "type":"message_router",\r
+ "dmaap_info":{ \r
+ "topic_url":"http://10.53.172.156:3904/events/ONAP-COLLECTOR-SNMPTRAP"\r
+ }\r
+ },\r
+ "rcc-notification":{ \r
+ "type":"message_router",\r
+ "dmaap_info":{ \r
+ "topic_url":"http://10.53.172.156:3904/events/ONAP-COLLECTOR-RESTCONFTRAP"\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file
- # ///////////////// DMaaP Config Constants
-
- # defaults to no username
-mr.DEFAULT_USER_NAME=null
- # defaults to no userPassword
-mr.DEFAULT_USER_PASSWORD=null
- #d efaults to using https protocol
-mr.DEFAULT_PROTOCOL=http
- # defaults to json content type
-mr.DEFAULT_CONTENT_TYPE=application/json
-
-mr.DMAAP_URI_PATH_PREFIX=/events/
-mr.DMAAP_DEFAULT_CONSUMER_ID=con2
-mr.DMAAP_GROUP_PREFIX=grp2
-
-#DMaaP MR subscriber thread's polling interval in milli second
-mr.POLLING_INTERVAL=10000
-
-# ///////////////// Publisher Constants
-
-#Dmaap Publisher Topic
-mr.publisher.topic=unauthenticated.SEC_FAULT_OUTPUT
-#disable batching by default
-mr.publisher.DEFAULT_PUBLISHER_MAX_BATCH_SIZE=1
-# default recovery messages size
-mr.publisher.DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE=100000
-#number of retries when flushing messages
-mr.publisher.PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE=5
-#delay in retrying for flushing messages
-mr.publisher.PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE=5000
-
-
-#////////////////// Subscriber Constants
-mr.subscriber.DEFAULT_SUBSCRIBER_TIMEOUT_MS=-1
-mr.subscriber.DEFAULT_SUBSCRIBER_MESSAGE_LIMIT=-1
-mr.subscriber.DEFAULT_SUBSCRIBER_GROUP_PREFIX=grp2
-mr.subscriber.SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME=timeout
-mr.subscriber.SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME=limit
-mr.mr_URI_PATH_PREFIX = /events/
-mr.mr_GROUP_PREFIX = grp2
-mr.mr_DEFAULT_CONSUMER_ID = con2
+ # ///////////////// DMaaP Config Constants\r
+ \r
+ # defaults to no username\r
+mr.DEFAULT_USER_NAME=null\r
+ # defaults to no userPassword\r
+mr.DEFAULT_USER_PASSWORD=null\r
+ #d efaults to using https protocol\r
+mr.DEFAULT_PROTOCOL=http\r
+ # defaults to json content type\r
+mr.DEFAULT_CONTENT_TYPE=application/json\r
+\r
+mr.DMAAP_URI_PATH_PREFIX=/events/\r
+mr.DMAAP_DEFAULT_CONSUMER_ID=con2\r
+mr.DMAAP_GROUP_PREFIX=grp2\r
+\r
+#DMaaP MR subscriber thread's polling interval in milli second \r
+mr.POLLING_INTERVAL=10000\r
+ \r
+# ///////////////// Publisher Constants\r
+\r
+#Dmaap Publisher Topic\r
+mr.publisher.topic=unauthenticated.VES_PNFREG_OUTPUT\r
+#disable batching by default\r
+mr.publisher.DEFAULT_PUBLISHER_MAX_BATCH_SIZE=1\r
+# default recovery messages size\r
+mr.publisher.DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE=100000\r
+#number of retries when flushing messages\r
+mr.publisher.PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE=5\r
+#delay in retrying for flushing messages\r
+mr.publisher.PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE=5000\r
+\r
+\r
+#////////////////// Subscriber Constants\r
+mr.subscriber.DEFAULT_SUBSCRIBER_TIMEOUT_MS=-1\r
+mr.subscriber.DEFAULT_SUBSCRIBER_MESSAGE_LIMIT=-1\r
+mr.subscriber.DEFAULT_SUBSCRIBER_GROUP_PREFIX=grp2\r
+mr.subscriber.SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME=timeout\r
+mr.subscriber.SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME=limit\r
+mr.mr_URI_PATH_PREFIX = /events/\r
+mr.mr_GROUP_PREFIX = grp2\r
+mr.mr_DEFAULT_CONSUMER_ID = con2\r
@RunWith(PowerMockRunner.class)\r
@SpringBootTest(classes = Application.class)\r
public class UniversalEventAdapterTest {\r
- \r
- private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
- \r
- @Mock\r
- private VESAdapterInitializer vesAdapterInitializer;\r
- \r
- @InjectMocks\r
- private UniversalEventAdapter universalVesAdapter;\r
- \r
- @Before\r
- public void init() {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
- \r
- @PrepareForTest({CollectorConfigPropertyRetrival.class})\r
- @Test\r
- public void testtransform() {\r
\r
- StringBuffer incomingJsonString = new StringBuffer("{\n" + " \"rule-id\": \"12121\",\n"\r
- + " \"notification\": {\n"\r
- + " \"event-time\": \"2018-03-15T08:15:32.000Z\",\n"\r
- + " \"notification-id\": \"2541256\",\n" + " \"message\": {\n"\r
- + " \"topic\":\"resource\",\n"\r
- + " \"object-type\":\"onu\", \n"\r
- + " \"version\": \"v1\", \n"\r
- + " \"operation\": \"create\", \n"\r
- + " \"target\": \"ont/ont=23hk1231231232\", \n"\r
- + " \"content\": {\n" + " \"onu\": {\n"\r
- + " \"sn\": \"48575443FA637D1A\",\n"\r
- + " \"refParentNE\": \"550e8400-e29b-41d4-a716-446655440000\",\n"\r
- + " \"refParentNeNativeId\": \"FDN\",\n"\r
- + " \"refParentLTP\": \"8c0db89e-218c-4e18-b0de-7a6788b3dda4\",\n"\r
- + " \"refParentLTPNativeId\": \"FDN\",\n"\r
- + " \"onuId\": \"213\",\n"\r
- + " \"accessID\": \"HG65875420001\"\n" + " }\n"\r
- + " }\n" + " }\n" + " }\n" + "}");\r
- Map<String, String> testMap = new HashMap<String, String>();\r
- testMap.put("defaultMappingFile-" + Thread.currentThread().getName(),\r
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"\r
- + "<smooks-resource-list xmlns=\"http://www.milyn.org/xsd/smooks-1.1.xsd\" xmlns:jb=\"http://www.milyn.org/xsd/smooks/javabean-1.4.xsd\" xmlns:json=\"http://www.milyn.org/xsd/smooks/json-1.1.xsd\">\n"\r
- + " <json:reader rootName=\"vesevent\" keyWhitspaceReplacement=\"-\">\n"\r
- + " <json:keyMap>\n"\r
- + " <json:key from=\"date&time\" to=\"date-and-time\" />\n"\r
- + " </json:keyMap>\n" + " </json:reader>\n"\r
- + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.VesEvent\""\r
- + " beanId=\"vesEvent\" createOnElement=\"vesevent\">\n"\r
- + " <jb:wiring property=\"event\" beanIdRef=\"event\" />\n"\r
- + " </jb:bean>\n"\r
- + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.Event\" "\r
- + "beanId=\"event\" createOnElement=\"vesevent\">\n"\r
- + " <jb:wiring property=\"commonEventHeader\" beanIdRef=\"commonEventHeader\" />\n"\r
- + " <jb:wiring property=\"pnfRegistrationFields\" beanIdRef=\"pnfRegistrationFields\" />\n"\r
- + " </jb:bean>\n"\r
- + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader\""\r
- + " beanId=\"commonEventHeader\" createOnElement=\"vesevent\">\n"\r
- + "<jb:expression property=\"version\">"\r
- + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1</jb:expression> \n"\r
- + "<jb:expression property=\"eventType\">\"pnfRegistration\"</jb:expression>\n"\r
- + "<jb:expression property=\"vesEventListenerVersion\">"\r
- + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1"\r
- + "</jb:expression>\n"\r
- + " <jb:expression property=\"eventId\" execOnElement=\"vesevent\">"\r
- + "\"registration_\"+commonEventHeader.ts1</jb:expression>\n"\r
- + "<jb:expression property=\"reportingEntityName\">\"VESMapper\"</jb:expression>\n"\r
- + " <jb:expression property=\"domain\">"\r
- + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION"\r
- + "</jb:expression>\n"\r
- + " <jb:expression property=\"eventName\" execOnElement=\"vesevent\">"\r
- + "commonEventHeader.domain</jb:expression>\n"\r
- + "<jb:value property=\"sequence\" data=\"0\" default=\"0\" decoder=\"Long\" />\n"\r
- + "<jb:expression property=\"lastEpochMicrosec\" execOnElement=\"vesevent\">"\r
- + "commonEventHeader.ts1</jb:expression>\n"\r
- + " <jb:expression property=\"startEpochMicrosec\" execOnElement=\"vesevent\">"\r
- + "commonEventHeader.ts1</jb:expression>\n"\r
- + " <jb:expression property=\"priority\">"\r
- + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL</jb:expression>\n"\r
- + " <jb:value property=\"sourceName\" data=\"notification/message/target\" />\n"\r
- + " </jb:bean>\n"\r
- + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields\""\r
- + " beanId=\"pnfRegistrationFields\" createOnElement=\"vesevent\">\n"\r
- + " \n"\r
- + " <jb:expression property=\"pnfRegistrationFieldsVersion\">"\r
- + "org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0"\r
- + "</jb:expression>\n"\r
- + " <jb:value property=\"serialNumber\" data=\"notification/message/content/onu/sn\" />\n"\r
- + " \n" + " </jb:bean>\n" + "</smooks-resource-list>");\r
+ private static final Logger errorLogger = LoggerFactory.getLogger("errorLogger");\r
\r
- try {\r
- vesAdapterInitializer.setMappingFiles(testMap);\r
- \r
- String [] identifiertest =\r
- CollectorConfigPropertyRetrival.getProperyArray("identifier", "kvTest.json");\r
- PowerMockito.mockStatic(CollectorConfigPropertyRetrival.class);\r
- PowerMockito.when(CollectorConfigPropertyRetrival.getProperyArray("identifier", null))\r
- .thenReturn(identifiertest);\r
- \r
- String actualResult = universalVesAdapter.transform(incomingJsonString.toString());\r
- assertNotNull(actualResult);\r
- assertNotEquals("", actualResult);\r
- } catch (VesException exception) {\r
- errorLogger.error("Error occurred : {}", exception);\r
+ @Mock\r
+ private VESAdapterInitializer vesAdapterInitializer;\r
+ \r
+ @InjectMocks\r
+ private UniversalEventAdapter universalVesAdapter;\r
+ \r
+ @Before\r
+ public void init() {\r
+ MockitoAnnotations.initMocks(this);\r
}\r
- }\r
- \r
+ \r
+ @PrepareForTest({CollectorConfigPropertyRetrival.class})\r
+ @Test\r
+ public void testtransform() {\r
+ \r
+ StringBuffer incomingJsonString = new StringBuffer("{\n"\r
+ + " \"rule-id\": \"12121\",\n" + " \"notification\": {\n"\r
+ + " \"event-time\": \"2018-03-15T08:15:32.000Z\",\n"\r
+ + " \"notification-id\": \"2541256\",\n"\r
+ + " \"message\": {\n"\r
+ + " \"topic\":\"resource\",\n"\r
+ + " \"object-type\":\"onu\", \n"\r
+ + " \"version\": \"v1\", \n"\r
+ + " \"operation\": \"create\", \n"\r
+ + " \"target\": \"ont/ont=23hk1231231232\", \n"\r
+ + " \"content\": {\n" + " \"onu\": {\n"\r
+ + " \"sn\": \"48575443FA637D1A\",\n"\r
+ + " \"refParentNE\": \"550e8400-e29b-41d4-a716-446655440000\",\n"\r
+ + " \"refParentNeNativeId\": \"FDN\",\n"\r
+ + " \"refParentLTP\": \"8c0db89e-218c-4e18-b0de-7a6788b3dda4\",\n"\r
+ + " \"refParentLTPNativeId\": \"FDN\",\n"\r
+ + " \"onuId\": \"213\",\n"\r
+ + " \"accessID\": \"HG65875420001\"\n"\r
+ + " }\n" + " }\n" + " }\n"\r
+ + " }\n" + "}");\r
+ Map<String, String> testMap = new HashMap<String, String>();\r
+ testMap.put("defaultMappingFile-" + Thread.currentThread().getName(),\r
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"\r
+ + "<smooks-resource-list xmlns=\"http://www.milyn.org/xsd/smooks-1.1.xsd\" xmlns:jb=\"http://www.milyn.org/xsd/smooks/javabean-1.4.xsd\" xmlns:json=\"http://www.milyn.org/xsd/smooks/json-1.1.xsd\">\n"\r
+ + " <json:reader rootName=\"vesevent\" keyWhitspaceReplacement=\"-\">\n"\r
+ + " <json:keyMap>\n"\r
+ + " <json:key from=\"date&time\" to=\"date-and-time\" />\n"\r
+ + " </json:keyMap>\n" + " </json:reader>\n"\r
+ + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.VesEvent\""\r
+ + " beanId=\"vesEvent\" createOnElement=\"vesevent\">\n"\r
+ + " <jb:wiring property=\"event\" beanIdRef=\"event\" />\n"\r
+ + " </jb:bean>\n"\r
+ + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.Event\" "\r
+ + "beanId=\"event\" createOnElement=\"vesevent\">\n"\r
+ + " <jb:wiring property=\"commonEventHeader\" beanIdRef=\"commonEventHeader\" />\n"\r
+ + " <jb:wiring property=\"pnfRegistrationFields\" beanIdRef=\"pnfRegistrationFields\" />\n"\r
+ + " </jb:bean>\n"\r
+ + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader\""\r
+ + " beanId=\"commonEventHeader\" createOnElement=\"vesevent\">\n"\r
+ + "<jb:expression property=\"version\">"\r
+ + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Version._4_0_1</jb:expression> \n"\r
+ + "<jb:expression property=\"eventType\">\"pnfRegistration\"</jb:expression>\n"\r
+ + "<jb:expression property=\"vesEventListenerVersion\">"\r
+ + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.VesEventListenerVersion._7_0_1"\r
+ + "</jb:expression>\n"\r
+ + " <jb:expression property=\"eventId\" execOnElement=\"vesevent\">"\r
+ + "\"registration_\"+commonEventHeader.ts1</jb:expression>\n"\r
+ + "<jb:expression property=\"reportingEntityName\">\"VESMapper\"</jb:expression>\n"\r
+ + " <jb:expression property=\"domain\">"\r
+ + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Domain.PNF_REGISTRATION"\r
+ + "</jb:expression>\n"\r
+ + " <jb:expression property=\"eventName\" execOnElement=\"vesevent\">"\r
+ + "commonEventHeader.domain</jb:expression>\n"\r
+ + "<jb:value property=\"sequence\" data=\"0\" default=\"0\" decoder=\"Long\" />\n"\r
+ + "<jb:expression property=\"lastEpochMicrosec\" execOnElement=\"vesevent\">"\r
+ + "commonEventHeader.ts1</jb:expression>\n"\r
+ + " <jb:expression property=\"startEpochMicrosec\" execOnElement=\"vesevent\">"\r
+ + "commonEventHeader.ts1</jb:expression>\n"\r
+ + " <jb:expression property=\"priority\">"\r
+ + "org.onap.dcaegen2.ves.domain.ves70.CommonEventHeader.Priority.NORMAL</jb:expression>\n"\r
+ + " <jb:value property=\"sourceName\" data=\"notification/message/target\" />\n"\r
+ + " </jb:bean>\n"\r
+ + " <jb:bean class=\"org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields\""\r
+ + " beanId=\"pnfRegistrationFields\" createOnElement=\"vesevent\">\n"\r
+ + " \n"\r
+ + " <jb:expression property=\"pnfRegistrationFieldsVersion\">"\r
+ + "org.onap.dcaegen2.ves.domain.ves70.PnfRegistrationFields.PnfRegistrationFieldsVersion._2_0"\r
+ + "</jb:expression>\n"\r
+ + " <jb:value property=\"serialNumber\" data=\"notification/message/content/onu/sn\" />\n"\r
+ + " \n" + " </jb:bean>\n"\r
+ + "</smooks-resource-list>");\r
+ \r
+ try {\r
+ vesAdapterInitializer.setMappingFiles(testMap);\r
+ \r
+ String[] identifiertest = CollectorConfigPropertyRetrival\r
+ .getProperyArray("identifier", "kvTest.json");\r
+ PowerMockito.mockStatic(CollectorConfigPropertyRetrival.class);\r
+ PowerMockito.when(CollectorConfigPropertyRetrival\r
+ .getProperyArray("identifier", null))\r
+ .thenReturn(identifiertest);\r
+ \r
+ String actualResult = universalVesAdapter\r
+ .transform(incomingJsonString.toString());\r
+ assertNotNull(actualResult);\r
+ assertNotEquals("", actualResult);\r
+ } catch (VesException exception) {\r
+ errorLogger.error("Error occurred : {}", exception);\r
+ }\r
+ }\r
+ \r
}\r