From 28d8801959ffa9b12a00114c3d389a58a0359c40 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Mon, 3 Feb 2020 16:02:18 +0000 Subject: Springboot-based SLI-API Implement SLI-API RESTCONF in springboot Change-Id: I8b9b07e3b1aeb4a5adac977307c6f95c905ea038 Issue-ID: CCSDK-2096 Signed-off-by: Dan Timoney --- .gitignore | 1 + features/ccsdk-sli/pom.xml | 6 - sli/pom.xml | 1 - .../ccsdk/sli/core/sli/recording/FileRecorder.java | 108 ++++++++ .../sli/core/sli/recording/Slf4jRecorder.java | 130 ++++++++++ .../sli/core/sli/recording/TestFileRecorder.java | 49 ++++ .../sli/core/sli/recording/TestSlf4jRecorder.java | 33 +++ .../resources/OSGI-INF/blueprint/sli-blueprint.xml | 14 ++ .../org/opendaylight/blueprint/sli-blueprint.xml | 14 ++ sli/recording/pom.xml | 48 ---- .../ccsdk/sli/core/sli/recording/FileRecorder.java | 108 -------- .../sli/core/sli/recording/Slf4jRecorder.java | 130 ---------- .../OSGI-INF/blueprint/recording-blueprint.xml | 20 -- .../opendaylight/blueprint/recording-blueprint.xml | 20 -- .../src/main/resources/svclogic.properties | 26 -- .../sli/core/sli/recording/TestFileRecorder.java | 49 ---- .../sli/core/sli/recording/TestSlf4jRecorder.java | 33 --- sliapi/.gitignore | 4 + .../model/src/main/resources/sli-api.20161110.yaml | 271 +++++++++++++++++++++ sliapi/pom.xml | 1 + sliapi/springboot/.swagger-codegen-ignore | 1 + sliapi/springboot/README.md | 10 + sliapi/springboot/pom.xml | 100 ++++++++ .../sliapi/springboot/ExecuteGraphController.java | 110 +++++++++ .../sliapi/springboot/RestconfApiController.java | 126 ++++++++++ .../src/main/resources/application.properties | 8 + .../springboot/src/main/resources/graph.versions | 1 + .../src/main/resources/sli_healthcheck.xml | 27 ++ .../src/main/resources/svclogic.properties | 27 ++ .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 15 +- 30 files changed, 1048 insertions(+), 443 deletions(-) create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java create mode 100644 sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java create mode 100644 sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java delete mode 100755 sli/recording/pom.xml delete mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java delete mode 100644 sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java delete mode 100644 sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml delete mode 100644 sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml delete mode 100644 sli/recording/src/main/resources/svclogic.properties delete mode 100644 sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java delete mode 100644 sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java create mode 100644 sliapi/model/src/main/resources/sli-api.20161110.yaml create mode 100644 sliapi/springboot/.swagger-codegen-ignore create mode 100644 sliapi/springboot/README.md create mode 100644 sliapi/springboot/pom.xml create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java create mode 100644 sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java create mode 100644 sliapi/springboot/src/main/resources/application.properties create mode 100644 sliapi/springboot/src/main/resources/graph.versions create mode 100644 sliapi/springboot/src/main/resources/sli_healthcheck.xml create mode 100644 sliapi/springboot/src/main/resources/svclogic.properties diff --git a/.gitignore b/.gitignore index 92a91c22..610f8902 100755 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ target target-ide MANIFEST.MF **/yang-gen-sal +*.interp sli/model/src/main/java ## Misc Ignores (OS specific etc) ## diff --git a/features/ccsdk-sli/pom.xml b/features/ccsdk-sli/pom.xml index 87fa657b..14c82312 100644 --- a/features/ccsdk-sli/pom.xml +++ b/features/ccsdk-sli/pom.xml @@ -30,12 +30,6 @@ ${project.version} - - org.onap.ccsdk.sli.core - sli-recording - ${project.version} - - org.onap.ccsdk.sli.core dblib-provider diff --git a/sli/pom.xml b/sli/pom.xml index 4f758a24..7363f5b7 100755 --- a/sli/pom.xml +++ b/sli/pom.xml @@ -25,7 +25,6 @@ model common provider - recording installer diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java new file mode 100644 index 00000000..37e4fe87 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Modifications Copyright (C) 2018 IBM. + * ================================================================================ + * 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.ccsdk.sli.core.sli.recording; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; + +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; + + +public class FileRecorder implements SvcLogicRecorder { + + @Override + public void record(Map parmMap) throws SvcLogicException { + + String fileName = parmMap.get("file"); + if (fileName == null) + { + throw new ConfigurationException("No file parameter specified"); + } + + String record = parmMap.get("record"); + if (record == null) + { + String delimiter = parmMap.get("delimiter"); + if (delimiter == null) + { + delimiter = "|"; + } + + int idx = 1; + boolean moreFields = true; + while (moreFields) + { + String curField = parmMap.get("field"+idx++); + if (curField == null) + { + moreFields = false; + } + else + { + if (record == null) + { + record = delimiter; + } + record = record + curField + delimiter; + } + } + } + + if (record == null) + { + throw new ConfigurationException("No record/fields passed in record node"); + } + + File recordFile = new File(fileName); + Date now = new Date(); + + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat dateFmt = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + dateFmt.setTimeZone(tz); + if (record.indexOf("__TIMESTAMP__") != -1) + { + record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); + } + + try ( FileWriter fileWriter = new FileWriter(recordFile, true); + PrintWriter recPrinter = new PrintWriter(fileWriter)) + { + recPrinter.println(record); + } + catch (Exception e) + { + throw new SvcLogicException("Cannot write record to file", e); + } + } + +} + diff --git a/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java new file mode 100644 index 00000000..e3f4f1b7 --- /dev/null +++ b/sli/provider-base/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java @@ -0,0 +1,130 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.core.sli.recording; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; + +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Slf4jRecorder implements SvcLogicRecorder { + + + public enum Level { + ERROR, + WARN, + INFO, + DEBUG, + TRACE + } + + @Override + public void record(Map parmMap) throws SvcLogicException { + String loggerName = parmMap.get("logger"); + if (loggerName == null) { + loggerName = "Log4jRecorder"; + } + + String lvl = parmMap.get("level"); + if (lvl == null) { + lvl = "INFO"; + } + + Level level = Level.INFO; + + try { + level = Level.valueOf(lvl.toUpperCase()); + } catch (Exception e) {} + + + + String record = parmMap.get("record"); + if (record == null) + { + String delimiter = parmMap.get("delimiter"); + if (delimiter == null) + { + delimiter = "|"; + } + + int idx = 1; + boolean moreFields = true; + while (moreFields) + { + String curField = parmMap.get("field"+idx++); + if (curField == null) + { + moreFields = false; + } + else + { + if (record == null) + { + record = delimiter; + } + record = record + curField + delimiter; + } + } + } + + if (record == null) + { + throw new ConfigurationException("No record/fields passed in record node"); + } + + Logger logger = LoggerFactory.getLogger(loggerName); + + Date now = new Date(); + TimeZone tz = TimeZone.getTimeZone("UTC"); + DateFormat dateFmt = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); + dateFmt.setTimeZone(tz); + if (record.indexOf("__TIMESTAMP__") != -1) + { + record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); + } + + switch (level) { + case ERROR: + logger.error(record); + break; + case WARN: + logger.warn(record); + break; + case INFO: + logger.info(record); + break; + case DEBUG: + logger.debug(record); + break; + case TRACE: + logger.trace(record); + } + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java new file mode 100644 index 00000000..d0cc8318 --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java @@ -0,0 +1,49 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.recording; + +import static org.junit.Assert.fail; + +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * @author dt5972 + * + */ +public class TestFileRecorder { + private FileRecorder recorder; + + @Before + public void setUp() { + recorder = new FileRecorder(); + } + + /** + * Test method for + * {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}. + */ + @Test + public void testRecord() { + HashMap parms = new HashMap<>(); + parms.put("file", "/dev/null"); + parms.put("field1", "hi"); + try { + recorder.record(parms); + } catch (SvcLogicException e) { + fail("Caught SvcLogicException : " + e.getMessage()); + } + } + + @Test(expected = Exception.class) + public void testRecordForEmptyFileName() throws Exception { + HashMap parms = new HashMap<>(); + parms.put("field1", "hi"); + recorder.record(parms); + } + +} diff --git a/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java new file mode 100644 index 00000000..c696f25b --- /dev/null +++ b/sli/provider-base/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java @@ -0,0 +1,33 @@ +/** + * + */ +package org.onap.ccsdk.sli.core.sli.recording; + +import static org.junit.Assert.*; +import java.util.HashMap; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; + +/** + * @author dt5972 + * + */ +public class TestSlf4jRecorder { + + /** + * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder#record(java.util.Map)}. + */ + @Test + public void testRecord() { + Slf4jRecorder recorder = new Slf4jRecorder(); + + HashMap parms = new HashMap<>(); + parms.put("field1","hi"); + try { + recorder.record(parms); + } catch (SvcLogicException e) { + fail("Caught SvcLogicException : "+e.getMessage()); + } + } + +} diff --git a/sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml b/sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml index d88cf331..fb3ab9a0 100644 --- a/sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml +++ b/sli/provider/src/main/resources/OSGI-INF/blueprint/sli-blueprint.xml @@ -19,4 +19,18 @@ + + + + + + + + diff --git a/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml b/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml index d88cf331..fb3ab9a0 100644 --- a/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml +++ b/sli/provider/src/main/resources/org/opendaylight/blueprint/sli-blueprint.xml @@ -19,4 +19,18 @@ + + + + + + + + diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml deleted file mode 100755 index 3a5afd97..00000000 --- a/sli/recording/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.sli.core - sli-recording - 0.7.1-SNAPSHOT - bundle - - ccsdk-sli-core :: sli :: ${project.artifactId} - SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - compile - - - org.slf4j - slf4j-api - - - commons-lang - commons-lang - compile - - - - junit - junit - test - - - org.mockito - mockito-core - test - - - diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java deleted file mode 100644 index 37e4fe87..00000000 --- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/FileRecorder.java +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.ccsdk.sli.core.sli.recording; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; - -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; - - -public class FileRecorder implements SvcLogicRecorder { - - @Override - public void record(Map parmMap) throws SvcLogicException { - - String fileName = parmMap.get("file"); - if (fileName == null) - { - throw new ConfigurationException("No file parameter specified"); - } - - String record = parmMap.get("record"); - if (record == null) - { - String delimiter = parmMap.get("delimiter"); - if (delimiter == null) - { - delimiter = "|"; - } - - int idx = 1; - boolean moreFields = true; - while (moreFields) - { - String curField = parmMap.get("field"+idx++); - if (curField == null) - { - moreFields = false; - } - else - { - if (record == null) - { - record = delimiter; - } - record = record + curField + delimiter; - } - } - } - - if (record == null) - { - throw new ConfigurationException("No record/fields passed in record node"); - } - - File recordFile = new File(fileName); - Date now = new Date(); - - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat dateFmt = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); - dateFmt.setTimeZone(tz); - if (record.indexOf("__TIMESTAMP__") != -1) - { - record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); - } - - try ( FileWriter fileWriter = new FileWriter(recordFile, true); - PrintWriter recPrinter = new PrintWriter(fileWriter)) - { - recPrinter.println(record); - } - catch (Exception e) - { - throw new SvcLogicException("Cannot write record to file", e); - } - } - -} - diff --git a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java b/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java deleted file mode 100644 index e3f4f1b7..00000000 --- a/sli/recording/src/main/java/org/onap/ccsdk/sli/core/sli/recording/Slf4jRecorder.java +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.sli.recording; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; -import java.util.TimeZone; - -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Slf4jRecorder implements SvcLogicRecorder { - - - public enum Level { - ERROR, - WARN, - INFO, - DEBUG, - TRACE - } - - @Override - public void record(Map parmMap) throws SvcLogicException { - String loggerName = parmMap.get("logger"); - if (loggerName == null) { - loggerName = "Log4jRecorder"; - } - - String lvl = parmMap.get("level"); - if (lvl == null) { - lvl = "INFO"; - } - - Level level = Level.INFO; - - try { - level = Level.valueOf(lvl.toUpperCase()); - } catch (Exception e) {} - - - - String record = parmMap.get("record"); - if (record == null) - { - String delimiter = parmMap.get("delimiter"); - if (delimiter == null) - { - delimiter = "|"; - } - - int idx = 1; - boolean moreFields = true; - while (moreFields) - { - String curField = parmMap.get("field"+idx++); - if (curField == null) - { - moreFields = false; - } - else - { - if (record == null) - { - record = delimiter; - } - record = record + curField + delimiter; - } - } - } - - if (record == null) - { - throw new ConfigurationException("No record/fields passed in record node"); - } - - Logger logger = LoggerFactory.getLogger(loggerName); - - Date now = new Date(); - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat dateFmt = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss:SS'+00:00'"); - dateFmt.setTimeZone(tz); - if (record.indexOf("__TIMESTAMP__") != -1) - { - record = record.replaceFirst("__TIMESTAMP__", dateFmt.format(now)); - } - - switch (level) { - case ERROR: - logger.error(record); - break; - case WARN: - logger.warn(record); - break; - case INFO: - logger.info(record); - break; - case DEBUG: - logger.debug(record); - break; - case TRACE: - logger.trace(record); - } - } - -} diff --git a/sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml b/sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml deleted file mode 100644 index 6786b955..00000000 --- a/sli/recording/src/main/resources/OSGI-INF/blueprint/recording-blueprint.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml b/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml deleted file mode 100644 index 6786b955..00000000 --- a/sli/recording/src/main/resources/org/opendaylight/blueprint/recording-blueprint.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/sli/recording/src/main/resources/svclogic.properties b/sli/recording/src/main/resources/svclogic.properties deleted file mode 100644 index 0ae6be71..00000000 --- a/sli/recording/src/main/resources/svclogic.properties +++ /dev/null @@ -1,26 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP : CCSDK -# ================================================================================ -# 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========================================================= -### - -org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = sdnctl -org.onap.ccsdk.sli.jdbc.password = gamma diff --git a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java deleted file mode 100644 index d0cc8318..00000000 --- a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestFileRecorder.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.recording; - -import static org.junit.Assert.fail; - -import java.util.HashMap; - -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -/** - * @author dt5972 - * - */ -public class TestFileRecorder { - private FileRecorder recorder; - - @Before - public void setUp() { - recorder = new FileRecorder(); - } - - /** - * Test method for - * {@link org.onap.ccsdk.sli.core.sli.recording.FileRecorder#record(java.util.Map)}. - */ - @Test - public void testRecord() { - HashMap parms = new HashMap<>(); - parms.put("file", "/dev/null"); - parms.put("field1", "hi"); - try { - recorder.record(parms); - } catch (SvcLogicException e) { - fail("Caught SvcLogicException : " + e.getMessage()); - } - } - - @Test(expected = Exception.class) - public void testRecordForEmptyFileName() throws Exception { - HashMap parms = new HashMap<>(); - parms.put("field1", "hi"); - recorder.record(parms); - } - -} diff --git a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java b/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java deleted file mode 100644 index c696f25b..00000000 --- a/sli/recording/src/test/java/org/onap/ccsdk/sli/core/sli/recording/TestSlf4jRecorder.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - */ -package org.onap.ccsdk.sli.core.sli.recording; - -import static org.junit.Assert.*; -import java.util.HashMap; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -/** - * @author dt5972 - * - */ -public class TestSlf4jRecorder { - - /** - * Test method for {@link org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder#record(java.util.Map)}. - */ - @Test - public void testRecord() { - Slf4jRecorder recorder = new Slf4jRecorder(); - - HashMap parms = new HashMap<>(); - parms.put("field1","hi"); - try { - recorder.record(parms); - } catch (SvcLogicException e) { - fail("Caught SvcLogicException : "+e.getMessage()); - } - } - -} diff --git a/sliapi/.gitignore b/sliapi/.gitignore index b73caf31..1558a77c 100755 --- a/sliapi/.gitignore +++ b/sliapi/.gitignore @@ -29,6 +29,10 @@ out/ .DS_STORE .metadata +## Derby files +sdnctl +derby.log + ## Folders which contain auto generated source code ## yang-gen-config yang-gen-sal diff --git a/sliapi/model/src/main/resources/sli-api.20161110.yaml b/sliapi/model/src/main/resources/sli-api.20161110.yaml new file mode 100644 index 00000000..db60aa1e --- /dev/null +++ b/sliapi/model/src/main/resources/sli-api.20161110.yaml @@ -0,0 +1,271 @@ +--- +swagger: '2.0' +info: + version: 1.0.0 + title: "SLI API" +basePath: '/restconf' +schemes: + - http + - https +paths: + '/restconf/config/SLI-API:test-results': + delete: + produces: + - application/json + - application/xml + responses: + '200': + description: No response was specified + description: Test results + operationId: delete-test-results + get: + produces: + - application/json + - application/xml + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-results' + description: Test results + operationId: get-test-results + post: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml + parameters: + - in: body + name: testResults + required: false + schema: + $ref: '#/definitions/test-results' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-results' + description: Test results + operationId: post-test-results + put: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml + parameters: + - in: body + name: testResults + required: false + schema: + $ref: '#/definitions/test-results' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-results' + description: Test results + operationId: put-test-results + + '/restconf/config/SLI-API:test-results/test-result/{test-identifier}': + delete: + produces: + - application/json + - application/xml + parameters: + - in: path + name: test-identifier + required: true + type: string + responses: + '200': + description: No response was specified + operationId: delete-test-result + get: + produces: + - application/json + - application/xml + parameters: + - in: path + name: test-identifier + required: true + type: string + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-result' + operationId: get-test-result + put: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml + parameters: + - in: path + name: test-identifier + required: true + type: string + - in: body + name: testResult + required: false + schema: + $ref: '#/definitions/test-result' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-result' + operationId: PUT-test-result + + '/restconf/operational/SLI-API:test-results': + get: + produces: + - application/json + - application/xml + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/test-results' + description: Test results + operationId: GET-test-results + '/restconf/operations/SLI-API:execute-graph': + post: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml + parameters: + - in: body + name: executeGraphInput + required: false + schema: + $ref: '#/definitions/execute-graph-input' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/response-fields' + description: ' Method to add a new parameter.' + operationId: execute-graph + '/restconf/operations/SLI-API:healthcheck': + post: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml +# parameters: +# - in: body +# name: healthcheckInput +# required: false +# schema: +# $ref: '#/definitions/healthcheck-input' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/response-fields' + operationId: healthcheck + '/restconf/operations/SLI-API:vlbcheck': + post: + consumes: + - application/json + - application/xml + produces: + - application/json + - application/xml + parameters: + - in: body + name: vlbcheckInput + required: false + schema: + $ref: '#/definitions/vlbcheck-input' + responses: + '200': + description: No response was specified + schema: + $ref: '#/definitions/response-fields' + operationId: vlbcheck + +definitions: + parameter-setting: + type: object + properties: + parameter-name: + type: string + int-value: + type: integer + string-value: + type: string + boolean-value: + type: boolean + + response-fields: + type: object + properties: + response-code: + type: string + ack-final-indicator: + type: string + response-message: + type: string + context-memory-json: + type: string + + test-results: + type: object + properties: + test-results: + type: array + items: + $ref: '#/definitions/test-result' + + test-result: + type: object + properties: + test-identifier: + type: string + results: + type: array + items: + type: string + + execute-graph-input: + properties: + 'mode': + type: string + 'module-name': + type: string + 'rpc-name': + type: string + 'sli-parameter': + items: + $ref: '#/definitions/parameter-setting' + type: array + type: object + + healthcheck-input: + properties: + 'dummy': + type: string + + + vlbcheck-input: + properties: + 'dummy': + type: string + + + + unique_empty_identifier: {} + diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 1d568a42..c8bc164c 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -19,6 +19,7 @@ model provider + springboot installer diff --git a/sliapi/springboot/.swagger-codegen-ignore b/sliapi/springboot/.swagger-codegen-ignore new file mode 100644 index 00000000..d14d7b94 --- /dev/null +++ b/sliapi/springboot/.swagger-codegen-ignore @@ -0,0 +1 @@ +**/RestconfApiController.java diff --git a/sliapi/springboot/README.md b/sliapi/springboot/README.md new file mode 100644 index 00000000..5737072e --- /dev/null +++ b/sliapi/springboot/README.md @@ -0,0 +1,10 @@ +This directory contains a demo springboot implementation of the SLI-API healthcheck method. + +To start this server, run: + +java -jar -DserviceLogicDirectory=src/main/resources target/sliapi-springboot-{version}.jar + +This will start a servlet on port 8080. To test to that servlet, post a blank +message to that port: + +curl http://127.0.0.1:8080/SLI-API:healthcheck -X POST -H "Content-Type: application/json" \ No newline at end of file diff --git a/sliapi/springboot/pom.xml b/sliapi/springboot/pom.xml new file mode 100644 index 00000000..be6bb629 --- /dev/null +++ b/sliapi/springboot/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + + org.onap.ccsdk.parent + spring-boot-starter-parent + 1.5.2-SNAPSHOT + + + org.onap.ccsdk.sli.core + sliapi-springboot + 0.7.1-SNAPSHOT + jar + + sliapi-springboot + + + + io.swagger + swagger-annotations + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + io.springfox + springfox-swagger2 + 2.9.2 + + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + ${project.groupId} + sli-provider + ${project.version} + + + com.google.code.gson + gson + + + org.apache.derby + derby + runtime + + + + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + ${project.basedir}/../model/src/main/resources/sli-api.20161110.yaml + spring + org.onap.ccsdk.sli.core.sliapi.springboot + org.onap.ccsdk.sli.core.sliapi.model + org.onap.ccsdk.sli.core.sliapi.springboot + true + true + ${project.basedir}/.swagger-codegen-ignore + true + + true + 2.2.4-RELEASE + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java new file mode 100644 index 00000000..6c024108 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java @@ -0,0 +1,110 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; + +import com.google.gson.*; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.sli.provider.base.InMemorySvcLogicStore; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + + +@Controller +@EnableAutoConfiguration +public class ExecuteGraphController { + static SvcLogicService svc; + private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteGraphController.class); + + @RequestMapping(value = "/executeGraph", method = RequestMethod.POST) + @ResponseBody + public HashMap executeGraph(@RequestBody String input) { + LOGGER.error("In request"); + LOGGER.error(input); + + HashMap hash = new HashMap(); + Properties parms = new Properties(); + + hash.put("status", "success"); + JsonObject jsonInput = new Gson().fromJson(input, JsonObject.class); + JsonObject passthroughObj = jsonInput.get("input").getAsJsonObject(); + + writeResponseToCtx(passthroughObj.toString(), parms, "input"); + + JsonObject inputObject = jsonInput.get("graphDetails").getAsJsonObject(); + try { + // Any of these can throw a nullpointer exception + String calledModule = inputObject.get("module").getAsString(); + String calledRpc = inputObject.get("rpc").getAsString(); + String modeStr = inputObject.get("mode").getAsString(); + // execute should only throw a SvcLogicException + Properties respProps = svc.execute(calledModule, calledRpc, null, modeStr, parms); + for (Entry prop : respProps.entrySet()) { + hash.put((String) prop.getKey(), (String) prop.getValue()); + } + } catch (NullPointerException npe) { + HashMap errorHash = new HashMap(); + errorHash.put("error-message", "check that you populated module, rpc and or mode correctly."); + return errorHash; + } catch (SvcLogicException e) { + HashMap errorHash = new HashMap(); + errorHash.put("status", "failure"); + errorHash.put("message", e.getMessage()); + return errorHash; + } + return hash; + } + + public static void writeResponseToCtx(String resp, Properties ctx, String prefix) { + JsonParser jp = new JsonParser(); + JsonElement element = jp.parse(resp); + writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + } + + public static void writeJsonObject(JsonObject obj, Properties ctx, String root) { + for (Entry entry : obj.entrySet()) { + if (entry.getValue().isJsonObject()) { + writeJsonObject(entry.getValue().getAsJsonObject(), ctx, root + entry.getKey() + "."); + } else if (entry.getValue().isJsonArray()) { + JsonArray array = entry.getValue().getAsJsonArray(); + ctx.put(root + entry.getKey() + "_length", String.valueOf(array.size())); + Integer arrayIdx = 0; + for (JsonElement element : array) { + if (element.isJsonObject()) { + writeJsonObject(element.getAsJsonObject(), ctx, root + entry.getKey() + "[" + arrayIdx + "]."); + } + arrayIdx++; + } + } else { + ctx.put(root + entry.getKey(), entry.getValue().getAsString()); + } + } + } + + public static void main(String[] args) throws Exception { + InMemorySvcLogicStore store = new InMemorySvcLogicStore(); + SvcLogicLoader loader = new SvcLogicLoader(System.getProperty("serviceLogicDirectory"), store); + + loader.loadAndActivate(); + SvcLogicResolver resolver = new SvcLogicClassResolver(); + + + svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(), resolver); + SpringApplication.run(ExecuteGraphController.class, args); + } +} diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java new file mode 100644 index 00000000..1c22da47 --- /dev/null +++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java @@ -0,0 +1,126 @@ +package org.onap.ccsdk.sli.core.sliapi.springboot; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.*; +import org.onap.ccsdk.sli.core.sli.*; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.sli.provider.base.InMemorySvcLogicStore; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; +import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver; +import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput; +import org.onap.ccsdk.sli.core.sliapi.model.HealthcheckInput; +import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; + +@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00") + +@Controller +public class RestconfApiController implements RestconfApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + private static SvcLogicService svc; + Logger log = LoggerFactory.getLogger(RestconfApiController.class); + + @org.springframework.beans.factory.annotation.Autowired + public RestconfApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + + SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProviderImpl(); + SvcLogicStore store = null; + try { + store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties()); + } catch (SvcLogicException e) { + log.error("Cannot create SvcLogicStore", e); + return; + } + + String serviceLogicDirectory = System.getProperty("serviceLogicDirectory"); + System.out.println("serviceLogicDirectory is "+serviceLogicDirectory); + SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, store); + + try { + loader.loadAndActivate(); + } catch (IOException e) { + log.error("Cannot load directed graphs", e); + } + SvcLogicResolver resolver = new SvcLogicClassResolver(); + + + try { + svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(), resolver); + } catch (SvcLogicException e) { + log.error("Cannot execute directed graph", e); + } + } + + @Override + public ResponseEntity healthcheck() { + SvcLogicContext ctx = new SvcLogicContext(); + ResponseFields resp = new ResponseFields(); + + + try { + + log.info("Calling SLI-API:healthcheck DG"); + Properties inputProps = new Properties(); + Properties respProps = svc.execute("sli", "healthcheck" , null, "sync", inputProps); + if (respProps == null) { + log.info("DG execution returned no properties!"); + } else { + log.info("DG execution returned properties"); + for (String key: respProps.stringPropertyNames()) { + log.info("DG returned property "+key+" = "+respProps.getProperty(key)); + } + } + resp.setAckFinalIndicator(respProps.getProperty("ack-final-indicator", "Y")); + resp.setResponseCode(respProps.getProperty("error-code", "200")); + resp.setResponseMessage(respProps.getProperty("error-message", "Success")); + + return(new ResponseEntity<>(resp, HttpStatus.OK)); + } + catch (Exception e) { + resp.setAckFinalIndicator("true"); + resp.setResponseCode("500"); + resp.setResponseMessage(e.getMessage()); + log.error("Error calling healthcheck directed graph", e); + + } + + return(new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR)); + + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + + + +} diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties new file mode 100644 index 00000000..6218d11f --- /dev/null +++ b/sliapi/springboot/src/main/resources/application.properties @@ -0,0 +1,8 @@ +springfox.documentation.swagger.v2.path=/api-docs +server.contextPath=/restconf +server.port=8080 +spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.RFC3339DateFormat +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false +spring.datasource.url=jdbc:derby:sdnctl;create=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect +spring.jpa.hibernate.ddl-auto=update \ No newline at end of file diff --git a/sliapi/springboot/src/main/resources/graph.versions b/sliapi/springboot/src/main/resources/graph.versions new file mode 100644 index 00000000..9c53eb2c --- /dev/null +++ b/sliapi/springboot/src/main/resources/graph.versions @@ -0,0 +1 @@ +sli healthcheck 0.7.0 sync diff --git a/sliapi/springboot/src/main/resources/sli_healthcheck.xml b/sliapi/springboot/src/main/resources/sli_healthcheck.xml new file mode 100644 index 00000000..bc8e2f70 --- /dev/null +++ b/sliapi/springboot/src/main/resources/sli_healthcheck.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/sliapi/springboot/src/main/resources/svclogic.properties b/sliapi/springboot/src/main/resources/svclogic.properties new file mode 100644 index 00000000..426960f7 --- /dev/null +++ b/sliapi/springboot/src/main/resources/svclogic.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# 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========================================================= +### + +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver +org.onap.ccsdk.sli.jdbc.database = sdnctl +org.onap.ccsdk.sli.jdbc.user = test +org.onap.ccsdk.sli.jdbc.password = test diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java index cc164d04..9ae094f1 100755 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java +++ b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java @@ -55,7 +55,14 @@ public class JREFileResolver implements PropertiesFileResolver { @Override public Optional resolveFile(final String filename) { - final Bundle bundle = FrameworkUtil.getBundle(this.clazz); + final Bundle bundle; + + try { + bundle = FrameworkUtil.getBundle(this.clazz); + } catch (NoClassDefFoundError e) { + return Optional.empty(); + } + final File dataFile; @@ -82,9 +89,13 @@ public class JREFileResolver implements PropertiesFileResolver { } return Optional.of(dataFile); - } catch(final Exception e) { + } catch (NoClassDefFoundError e) { + return Optional.empty(); + } + catch(final Exception e) { return Optional.empty(); } + } @Override -- cgit 1.2.3-korg