dme2 & ueb support 61/60561/5
authorSmokowski, Kevin (ks6305) <ks6305@att.com>
Tue, 14 Aug 2018 14:43:31 +0000 (14:43 +0000)
committerDan Timoney <dt5972@att.com>
Tue, 14 Aug 2018 15:50:22 +0000 (15:50 +0000)
fix dme2 & ueb support in rest api call node

Change-Id: Ia387c0be8e907900e0b808879582048624dbef36
Issue-ID: CCSDK-459
Signed-off-by: Smokowski, Kevin (ks6305) <ks6305@att.com>
restapi-call-node/provider/pom.xml
restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml [deleted file]
restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml [deleted file]

index 18a20ce..6670cfd 100755 (executable)
@@ -14,7 +14,6 @@
     <packaging>bundle</packaging>
 
     <name>ccsdk-sli-plugins :: restapi-call-node :: ${project.artifactId}</name>
-    <url>http://maven.apache.org</url>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.sli.core</groupId>
             <artifactId>sli-common</artifactId>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
         <dependency>
             <groupId>com.sun.jersey</groupId>
             <artifactId>jersey-client</artifactId>
index 42462f0..46c74ff 100644 (file)
@@ -37,6 +37,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Properties;
 import java.util.Set;
 
 import javax.net.ssl.HostnameVerifier;
@@ -75,6 +76,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
     private String uebServers;
     private String defaultUebTemplateFileName = "/opt/bvc/restapi/templates/default-ueb-message.json";
     protected RetryPolicyStore retryPolicyStore;
+    protected static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties";
+    protected static final String UEB_PROPERTIES_FILE_NAME = "ueb.properties";
+    protected static final String DEFAULT_PROPERTIES_DIR = "/opt/onap/ccsdk/data/properties";
+    protected static final String PROPERTIES_DIR_KEY = "SDNC_CONFIG_DIR";
 
     protected RetryPolicyStore getRetryPolicyStore() {
         return retryPolicyStore;
@@ -85,7 +90,26 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
     }
 
     public RestapiCallNode() {
+        String configDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR);
+
+        try (FileInputStream in = new FileInputStream(configDir + "/" + DME2_PROPERTIES_FILE_NAME)) {
+            Properties props = new Properties();
+            props.load(in);
+            this.retryPolicyStore = new RetryPolicyStore();
+            this.retryPolicyStore.setProxyServers(props.getProperty("proxyUrl"));
+            log.info("DME2 support enabled");
+        } catch (Exception e) {
+            log.warn("DME2 properties could not be read, DME2 support will not be enabled.", e);
+        }
 
+        try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) {
+            Properties props = new Properties();
+            props.load(in);
+            this.uebServers = props.getProperty("servers");
+            log.info("UEB support enabled");
+        } catch (Exception e) {
+            log.warn("UEB properties could not be read, UEB support will not be enabled.", e);
+        }
     }
 
      /**
diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-context.xml
deleted file mode 100644 (file)
index 8785062..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ============LICENSE_START=======================================================
-  openECOMP : SDN-C
-  ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights
-                       reserved.
-  ================================================================================
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  
-       http://www.apache.org/licenses/LICENSE-2.0
-  
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ============LICENSE_END=========================================================
-  -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-            <property name="locations">
-            <list>
-                <value>file:${SDNC_CONFIG_DIR}/ueb.properties</value>
-                <value>file:${SDNC_CONFIG_DIR}/dme2.properties</value>
-            </list>
-        </property>
-        <property name="ignoreResourceNotFound" value="true" />
-        <property name="ignoreUnresolvablePlaceholders" value="true" />
-    </bean>
-
-    <!-- context:property-placeholder location="file:${SDNC_CONFIG_DIR}/ueb.properties" /-->
-
-    <bean id="restapiCallNode" class="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode">
-        <property name="uebServers" value="${servers}" />
-        <property name="retryPolicyStore" ref="retryPolicyStore"/>
-    </bean>
-
-    <bean id="retryPolicyStore" class="org.onap.ccsdk.sli.plugins.restapicall.RetryPolicyStore">
-        <property name="proxyServers" value="${proxyUrl}" />
-    </bean>
-</beans>
diff --git a/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml b/restapi-call-node/provider/src/main/resources/META-INF/spring/restapi-call-node-osgi-context.xml
deleted file mode 100644 (file)
index 2f1e4db..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ============LICENSE_START=======================================================
-  openECOMP : SDN-C
-  ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property. All rights
-                       reserved.
-  ================================================================================
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  
-       http://www.apache.org/licenses/LICENSE-2.0
-  
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ============LICENSE_END=========================================================
-  -->
-
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
-    xsi:schemaLocation="http://www.springframework.org/schema/osgi
-       http://www.springframework.org/schema/osgi/spring-osgi.xsd
-       http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-    <service ref="restapiCallNode" interface="org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode" />
-
-</beans:beans>